Pwd Command in Linux (Current Working Directory)
Updated on
•6 min read

In this article, we will show you how to determine your current working directory using the pwd command.
What is the 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 log 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:
cd /tmpIf you have a customized bash or zsh prompt, the path to the current working directory may be shown in the shell prompt.
user@host:/tmp#
pwd Command
The pwd command stands for print working directory. It is one of the most basic and frequently used commands in Linux. When invoked the command prints the complete path of the 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
command to display all locations containing pwd:
type -a pwdpwd 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 is used whenever you type pwd. If you want to use the standalone pwd binary type the full path to the file /bin/pwd
How to Find your Current Working Directory
To find out what directory you are currently in, type pwd in your terminal:
pwdThe output will look something like this:
/home/linuxize
What the pwd does is printing the PWD environment variable
.
You will get the same output if you type:
echo $PWD/home/linuxize
The pwd command can accept only two arguments:
-L(--logical) - Do not resolve symlinks.-P(--physical) - Display the physical directory, without any symbolic links.
By default, id no option is used, pwd behaves as if -L option is specified.
To better illustrate how the -P option works, let’s create a directory
and symlink
pointing to the directory:
mkdir /tmp/directoryln -s /tmp/directory /tmp/symlink
Now if you navigate to the /tmp/symlink directory and you type pwd in your terminal:
pwdThe output will show that your current working directory is /tmp/symlink:
/tmp/symlink
If you run the same command using the -P option:
pwd -PThe command will print the directory to which the symlink points to:
/tmp/directory
Conclusion
The current working directory is the directory from which you invoke commands in your terminal.
The pwd command is used to display the current working directory.
If you have any questions or feedback, feel free to leave a comment.


