Linux current directory FAQ: How do I show what directory I'm currently in on a Unix or Linux system?
Just use the Unix/Linux pwd
command, like this:
pwd
If you're in a directory named /home/al, the output looks like this:
$ pwd /home/al
If you're in a directory named /tmp, the output looks like this:
$ pwd /tmp
That's all there is to the pwd
command.
Putting the current directory in your Linux prompt
In the old days we had to type this command all the time, but in these more modern times we can just display the current directory in our prompt symbol by setting it like this:
PS1='$PWD> '
Note that it's very important to use single quotes in this command and not double quotes.
Myself, I prefer a longer, multiline Linux prompt, so I put this PS1 setting in my ~/.bash_profile file on my Unix and Linux systems:
PS1=' $PWD ==> '
This gives me a prompt like this, which I prefer, especially with longer directories:
/Users/al/foo/bar/baz ==> _
Unix/Linux pwd command examples
I hope these Unix and Linux pwd
command examples and command prompt examples have been helpful.