Saturday, 13 September 2014

How to Change Your Command Prompt in UNIX or Linux

If you do not like your command prompt in UNIX or Linux, you can change it with the export PS1= command. In the example below, I started off with a command prompt of UBUNTU > :

UBUNTU > 

... then I changed it to show the name of the directory I was in. Here is one way to do this:

UBUNTU > export PS1='`pwd` > '
/home/andrew > cd Java
/home/andrew/Java > cd /
/ >

... and here is another:

/ > export PS1='$PWD > '
/ > cd
/home/andrew > cd Java
/home/andrew/Java > 

Finally, I changed it to say Andrew's PC: 

/home/andrew/Java > export PS1="Andrew's PC: "
Andrew's PC: