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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 8 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

Execute the following commands to automatically set it up everytime you open a terminal -

$touch .bashrc
$nano .bashrc

Goto to the last line and add -

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

Press Ctrl+X and hit Y.

share|improve this answer
I've done the same thing you just did a few times, but just as an fyi the question you answered is 4 years old and already has an accepted answer. No harm. – Argonauts May 14 at 14:58
This is very similar to the accepted answer. Could you explain further what it is you are doing differently? – Burgi May 14 at 15:54
@Burgi Please understand that I'm not so very experienced when it comes to Linux. I had trouble understanding the accepted answer and had to struggle a bit in order to figure it out. So, I thought it would be beneficial for other fledglings like me: if the steps are clearly enumerated, as I've done in my answer. I really don't think my answer deserves a downvote, unless my answer is wrong. – PrinceGautham May 16 at 14:07

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.