In this article, we will learn about how to determine your current working directory using the
pwd command. How to use pwd command in Linux.
What is the Current Working Directory
The current working directory is where the user currently working that directory is currently working directory. Each time you open the terminal, 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. If you want to change the working directory use the
For example, to change the current working directory to
/dev directory you would run the following command in the terminal:
$ cd /dev
If you have a customized
zsh prompt, the path to the current working directory may be shown in the shell prompt.
pwdcommand stands for print working directory. It is one of the most basic and frequently used commands in Linux. When we use this command, it prints the complete path of the current working directory.
How to Find your Current Working Directory
To find out what directory you are currently in, type
pwd command in your terminal:
pwd command can accept four arguments:
- -L (–logical) – Do not resolve symlinks.
- -P (–physical) – Avoid all symlinks.
- –help – Display this help and exit.
- –version – Output version information and exit.
By default, id no option is used,
pwd behaves as if the -L option is specified.
How the -P option works, we have to create a directory and symlink pointing to the directory:
$ mkdir /tmp/test$ ln -s /tmp/test /tmp/symlink
Now if we use the
pwd command in the terminal to navigate
The output will show that your current working directory is /tmp/symlink:
If you run the same command using the -P option:
$ pwd -P
The current working directory is the directory where you run the commands in your terminal.
pwd command is used to display the current working directory.
If you have any questions, feel free to leave a comment.