Monday, June 29, 2009

Understanding Bash (Part 2)

I like to customise my BASH prompt to be a bit more colourful and informative. You can also do it. But before that you must understand some basis syntax. There are more to the options below

Selected Options for Bash Prompt:
\h (Hostname)
\u (Username of the current user)
\w (current working directory, with the top-level directory as ~)
\W (base name of the current working directory, with top-level directory as ~)

How do we get BASH to look like below under CentOS
[root@test ~/scratch/tmp]$
# vim .bashrc
# export PS1='\e[1;33m[\u@\h \w]\$ \e[m'

\e[a;bm \e[m
(marks the start of the character the colour apply to.)
(a;bm is the color code)
(a can have a value of both 0 and 1. 1 will be the lighter colour of the 0)

For Color Codes, see Changing Colour for ls on BASH Blog

Special Feature Writeup of ISC09

A good collection of Articles and Commentaries dedicated to ISC 09 Conference
HPCwire's special section dedicated to ISC09

Grand unification of supercomputing and cloud computing?

There were a posting by Michael Feldman, editor of HPCwire on the title High Performance Cloud Computing Still an Oxymoron.

A good article where experts provide differing view on the feasibility of Cloud Computing on HPC infrastructure.

Saturday, June 27, 2009

Understanding Bash (Part 1)

When you logged on there are 4 files that are associated with BASH

  • .bash_history (list of previously entered commands)
  • .bash_logout (run a script when Bash exit)
  • .bashrc (basic settings for prompt actions)
  • .bash_profile (additional configuration. If .bash_profile is not present, the user account will use /etc/profile)

Adding a Directory to a Path
To add a directory to a path, edit the .bash_profile
$ vim .bash_profile

export PATH

Putting Aliases
One of the appropriate place to put aliases is in .bashrc

Friday, June 26, 2009

Using mrxvt

mrxvt is a cool alternative terminal emulator. It is extremely flexible and the most interesting feature is the tabbed-oriented design. mrxvt can be easily obtained from a number of distribution.

For more information,

Thursday, June 25, 2009

Changing Color for ls on Bash

Adapted from Paint your BASH (pdf) by Heike Jurik (Linux Magazine)

Have you noticed that on a tty console, the colour of the directory is dark blue. It is so hard to read the blue text. How do we change the colours?

Step 1: Pipe the information from Dircolors and save as .dircolors
$ dircolors -p > ~/.dircolors

Step 2: Change the contents of .dircolors
$ vim .dircolors

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory

Color Codes (Foreground):
00;35 Magenta

01;31=Light Red
01;32=Light green
01;34=Light Blue
01;36=Light Cyan
01;37=Light Gray

Introduce DirColors to the new configuration
$ dircolors -b ~/.dircolors

Horray done.


Monday, June 22, 2009

Using wget to download entire website

This article is taken from Downloading an Entire Web Site with wget by Linux Journal dated 5th Sept 08. The purpose is for off-line viewing or backup.

Remember that downloading entire website that is not yours is unethical and illegal as well.

# wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains \
--no-parent \

The options are:

  • --recursive: download the entire Web site.

  • --domains don't follow links outside

  • --no-parent: don't follow links outside the directory tutorials/html/.

  • --page-requisites: get all the elements that compose the page (images, CSS and so on).

  • --html-extension: save files with the .html extension.

  • --convert-links: convert links so that they work locally, off-line.

  • --restrict-file-names=windows: modify filenames so that they will work in Windows as well.

  • --no-clobber: don't overwrite any existing files (used in case the download is interrupted and

MPI Tutorials Information

Free Online MPI Tutorials and documentation
  1. Intro to MPI Course Overview
  2. Parallel Programming with MPI

Sunday, June 21, 2009

Using Text-Mode Web Browser

There are several Text-Mode Web Browser to browse website from a console
  1. elinks
  2. links
  3. lynx
If you are using Redhat Derivatives such as CentOS, Fedora, RHEL, just a
# yum install elinks links lynx

If you are using Debian Derivatives such as Linux Mint
# apt-get install elinks links lynx

To surf
$ elinks
$ links
$ lynx

The one I used the most is lynx.

Saturday, June 20, 2009

Understanding Cat commands

Cat key usage is to concatenate files together. In addition, cat command can be used to display files

1. To join files and display them on the screen
# cat file1 file2

2. To join 2 files together and save them on file 3
# cat file1 file2 > file3

3. To display the file with line numbering
# cat -n file1

Using yum effectively (Part 2)

This is the 2nd part of using yum effectively. See information Using yum effectively (Part 1)

There is one utility seldom used which is part of yum ie yumdownloader. Yumdownloader is a cool utility to download the rpm package instead of installing directly

Using yumdownloader# yum install yum-utils (download the yum-utils package)
# yumdownloader (package-name)
# yumdownloader alpine (For example)
# yumdownloader --source (package-name) (source packages)

Using the GUI yum installer
# yum install pirut
# pirut

Using yum effectively (Part 1)

Yum (Yellow Dog Updater, Modified) is used by CentOS, RHEL, Fedora an an interface to the underlying rpm system.

Some important usages:

1. To install package
# yum install (package-name)
# yum -y install (package-name)

2. To update package
# yum update (package-name)

Launch the GUI for yum update
# yum install pirut
# pup

3. To use yum to install instead of rpm.
(Yum will search for dependencies and repositories)
# yum localinstall (package-name)

4. Uninstalling Package
# yum remove (package-name)

5. Listing Package
# yum list (package-name)

6. Group Install
# yum groupinstall (group-package-name)

Sunday, June 14, 2009

Linux Mint 7 "Gloria" is ready for x86

Linux Mint 7 "Gloria" is ready for download. Horray.....

Distro of Choice for Desktop and Server

After writing more than 100 entries on Linux, I thought I write something about my personal choice of Linux Distribution

I have tested OpenSuse 10.3, Fedora 9, Ubuntu, I finally settled on Linux Mint. Its elegance and layout really "wow" me after I have installed and never look back. Besides, it has a whole load of software from Debian/Ubuntu Repository. I like the compilation of codecs which I can install with a click on the icon "Install Multimedia Codecs"

As for the Server OS of choice, I think CentOS is still my choice. No special reasons except that I just got used to Redhat Distro since I started using Redhat 6 on our servers.

Installing Dropbox on Linux Mint 6 (Ubuntu 8.10)

I have returned a very brief entry on Dropbox on 12 December 2008. I thought I will write up how I install the Dropbox on Linux Mint which is the Desktop of choice for me.

Step 1: Add the Dropbox repository to the Linux Mint package source file. The most suitable place in my opinion will be the application specific setup list ie /etc/apt/source.list.d/dropbox.list

# cd /etc/apt/source.list.d/
# touch dropbox.list
# vim dropbox.list

Go to and cut and paste the repository information for Ubuntu 8.10 into /etc/apt/source.list.d/dropbox.list
deb intrepid main
deb-src intrepid main

Step 2: Update the Repository
# apt-get update

Step 3: Install Dropbox
# apt-get install nautilus-dropbox

Step 4: Restart Nautilus to start Dropbox
# killall nautilus

Step 5: Menu > Applications > Dropbox
The rest is as straight-forward as you can get.

Friday, June 12, 2009

Using vim more effectively

Like many Linux administrator, vim is an editor of choice. However, I fail to exploit the many shortcuts and tricks that make it stand-out. I will list a couple of commands of frequent use

1. Searching
Create a .vimrc in your own home directory. With this you can you place useful commands settings
set incsearch (incremental search function)
set ignorecase (ignore case-sensitive function)
set smartcase (used in conjunction with ignorecase. By default it search for any case unless the user specify uppercase character)

2. Movement from the keyboard.
h (move left)
l (move right)
j (move up)
k (move down)

3. Editing
x (delete the character under the cursor) 
y (copy the characters from the current cursor) 
p (paste previous deleted or copied text after the current cursor position) 
d (delete the characters from the cursor position)

4. File Browser and Screen
e .(To make vim act as a file browser) 
:split (To split the screen into seperate segments. Use Crtl+W and arrow keys to change screen)

5. UsingTab
# vim -p file1 file2 (2 file with tabs will show)

:tabn (next tab) 
:tabp (previous tab) 

6. Spell Check
: setlocal spell spelllang=en_us (enable spell checking)
: help spell (spell help)
]s (Go to the next misspelled word)
z= (Display suggestions for correct spelling)

Interesting Articles:
Vim Introduction and Tutorial

Monday, June 8, 2009 Repository, a repository of add-on RPM packages for Fedora as well as RHEL (version 5 and later) and its compatible derivates like CentOS.

In 2008 merged with two other package repositories into RPM Fusion. All packages have been moved there except one that RPM Fusion for various reasons didn't want to take.

# wget
# rpm -Uvh livna-release.rpm

RPM Fusion Repository

RPM Fusion is a merger of Dribble, Freshrpms, and Livna; our goal is to simplify end-user experience by grouping as much add-on software as possible in a single location.

Step 1:
You need to enable EPEL on RHEL5 or compatible distributions like CentOS before you enable RPM Fusion for EL.

Step 2: Download and install rpm package for CentOS
# wget
RPM Fusion free for RHEL5 or compatible like CentOS
RPM Fusion nonfree for RHEL5 or compatible like CentOS

For more information for Fedora and the above information, go to RPM Fusion Configuration

Friday, June 5, 2009

Understanding Login Sequence

Taken from Application Environment Setup Using /etc/profile.d/*

When a user login, the environment variables are set following the below order

  1. /etc/profile (for all users)
  2. /etc/profile.d (Application specific setup)
  3. ~/.bash_profile
  4. ~/.bashrc

For further information, read Login Sequence

Wednesday, June 3, 2009

Changing the hostname on CentOS

Step 1: Edit on /etc/sysconfig/network
# vim /etc/sysconfig/network

Step 2: Edit /etc/hostname
# vim /etc/hostname

Step 3: Run hostname
# hostname -F /etc/hostname

Monday, June 1, 2009

Setting hardware Clock to System Time

Have you encountered that after a reboot your hardware clock is not in sync with the system clock as the hardware clock keeps the time when power is turned off, you may want to sync the hardware clock to the system time once it is accurate. This is a followup of the Article "How to setup NTP Server for local network"

# hwclock --systohc

Setting up NTP Server for Local Network

First for definition. From Wikipedia

The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over packet-switched, variable-latency data networks. NTP uses UDP on port 123 as its transport layer.

Setting Up NTP Server

Step 1: Install NTP Server and Client
# yum install ntp

Step 2: Configuration at /etc/ntp.conf
(The Basic Configuration is sufficient. A few things to note)
# vim /etc/ntp.conf

(Inside the /etc/ntp.conf) This statement is to allow local network to access the Server...
restrict mask nomodify notrap

(Inside the /etc/ntp.conf) Ensure the localhost has full access without any restructing password

Step 3: Start the Services

# chkconfig --levels 235 ntpd on
# ntpdate
# service ntpd start

Check whether it is working
# ntpq -p

Setting Up NTP Clients to sync with the local NTP Server and NTP Client

Step 1: Install the ntpd services
# yum install ntp

Step 2: Configure the /etc/ntp.conf
# vim /etc/ntp.conf

(Inside the /etc/ntp.conf) Point to the local NTP Server

Step 3: Start the Services
# chkconfig --levels 235 ntpd on
# ntpdate
# service ntpd start

Check whether it is working
# ntpq -p
For more readings:
  1. How to Setup a Time Server in Linux from TechGuruLive (Debian-Based Server)