Read in 3 minutes
Determine Your Current Working Directory in Linux Using the pwd Command
In this tutorial, we will show you how to use the pwd command to determine your current working directory.
What is Current Working Directory
The current working directory is the directory in which the user is currently working in. Each time you interact with your command prompt, you are working within a directory.
By default, when you logging into your Linux system your current working directory is set to your home directory. To change the working directory use the cd command. For example, to change the current working directory to
/tmp you would type:
On some Linux distributions, or if you have a customized bash or zsh prompt, the path to your current working directory may be shown in the shell prompt.
pwd command stands for print working directory. It one of the most basic and frequently used commands in Linux. When executed the command will print the complete path of your current working directory.
pwd is a shell builtin in most modern shells such as bash and zsh. Its behavior is slightly different than the standalone
/bin/pwd executable. You can use the
type -a to display all locations containing the
type -a pwd
pwd is a shell builtin pwd is /bin/pwd
As you can see from the output below, the shell builtin has priority over the standalone executable and it will be used whenever you type
pwd. If you want to use the standalone pwd command you’ll need to use the full path to the binary
How to Find your Current Working Directory
To find out what directory you are currently in, type
pwd in your terminal:
The command will display the path of your current working directory:
What the command does is printing the
PWD environment variable. You will get the same output if you type:
pwd command can accept only two arguments:
--logical) - Display the value of the
$PWDvariable. By default,
pwdbehaves as if
-Loption is specified.
--physical) - Display the physical directory, without any symbolic links
mkdir /tmp/directory ln -s /tmp/directory /tmp/symlink
Now if you navigate to the
/tmp/symlink directory and you type
pwd in your terminal:
The output will show that your current working directory is
If you run the same command using the
Your current working directory is
/tmp/directory, the directory to which the symlink points to.
By now you should have a good understanding of what is the current working directory and how to use the pwd command to find your current working directory.
If you have any question or feedback feel free to leave a comment.