Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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)$ '
share|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? – Jake Orben 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. – Jake Orben Nov 16 '12 at 22:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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