The Linux pwd command (and Linux command line prompts)

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:


If you're in a directory named /home/al, the output looks like this:

$ pwd

If you're in a directory named /tmp, the output looks like this:

$ pwd

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:

==> '

This gives me a prompt like this, which I prefer, especially with longer directories:

==> _

Unix/Linux pwd command examples

I hope these Unix and Linux pwd command examples and command prompt examples have been helpful.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.