I have been searching around for a while and have not been able to find an answer to this. Whenever I use the command line in Ubuntu it always lists the full directory back to my home directory, how to I set it to only show the current working directory.


Best guess for default Ubuntu install

Find where your PS1 variable is set and change \w to \W.

You can do an initial check of this method thus:

user@computer:~/full/path/to/directory$ echo $PS1
user@computer:~/full/path/to/directory$ export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '

It is probably being set in your .bashrc. If not, check /etc/bashrc and override the variable there in your .bashrc. You will of course have to do an exec bash or source your .bashrc for changes made there to take effect.

Other setups

There are different variations on how to do this depending on what shell you are using and how it is set up. For example, you might conceivably have your prompt set up like this:

export PS1='$USER@$(hostname):$PWD$ '

In which case you will want to do:

export PS1='$USER@$(hostname):$(basename $PWD)$ '
| improve this answer | |
  • Hey, I just logged back in and found out that the settings did not save. They worked at first, however they are gone now, any ideas? – Steve Nov 16 '12 at 22:14
  • Did you make the changes in your $HOME/.bashrc, as I said? If not, you will of course have to make the change every time you open a terminal. Your .bashrc is your initialization file. – Kazark Nov 16 '12 at 22:16
  • Haha, that was silly, I forgot to wq, thanks for the quick help. – Steve Nov 16 '12 at 22:18

Add this line to your ~/.bashrc file

PS1='${debian_chroot:+($debian_chroot)}\u@\h: \W\$ '

This should work on debian based systems.

Alternatively, you can add the following line at the end of ~/.bashrc file


1 indicates show only the current directory. If you set to 2 the current directory and its parent will be shown.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.