Debian lenny Colorful Bash prompt and file names

Fancy bash and ls color is helpful feature in linux. Once we install Debian lenny, the bash prompt and ls result will show in normal ( black and white ). so i planed to make some changes in the profile file. This will helpful for Linux server administrators.

To change in to a colorful prompt do following,

Open /etc/profile

It is as follows.

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ “`id -u`” -eq 0 ]; then
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
else
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/games”
fi

if [ “$PS1” ]; then
if [ “$BASH” ]; then
PS1=’\[email protected]\h:\w\$ ‘
else
if [ “`id -u`” -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fi

export PATH

umask 022

Now, we have to replace Line PS1=’\[email protected]\h:\w\$ ‘ with following code

if [[ ${EUID} == 0 ]] ; then
PS1=’${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u\[\033[1;37m\]@\[\033[1;34m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]’
else
PS1=’\[\033[01;32m\]\[email protected]\h\[\033[01;34m\] \w \$\[\033[00m\] ‘
fi

alias ls=’ls –color=auto’
alias grep=’grep –colour=auto’

After the Changes File look like this

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ “`id -u`” -eq 0 ]; then
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
else
PATH=”/usr/local/bin:/usr/bin:/bin:/usr/games”
fi

if [ “$PS1” ]; then
if [ “$BASH” ]; then

if [[ ${EUID} == 0 ]] ; then
PS1=’${debian_chroot:+($debian_chroot)}\[\033[0;31m\]\u\[\033[1;37m\]@\[\033[1;34m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]’
else
PS1=’\[\033[01;32m\]\[email protected]\h\[\033[01;34m\] \w \$\[\033[00m\] ‘
fi

alias ls=’ls –color=auto’
alias grep=’grep –colour=auto’

else
if [ “`id -u`” -eq 0 ]; then
PS1=’# ‘
else
PS1=’$ ‘
fi
fi
fi

export PATH

umask 022

If User have a .bashrc Then find the following line and comment it

#export PS1=’\h:\w\$ ‘

Now restart / reload the profile

See the result

About Albin Sebastian

I am a Technology Blogger, System Administrator by profession and webmaster by passion. Technology blogger, Active in Online and offline tech communities.

Check Also

MySql replication

Disaster recovery of Mysql using DRBD and Heartbeat

Disaster recovery (DR) is the process, policies and procedures that are related to preparing for …

Comments