Generally, new linux users confused for directory navigation using command-line. In this article, we explains how you can determine your current working directory using the pwd command.
Current Working Directory
A directory where currently you are working in is know as Current Working Directory. By default, when you log in to your system, your current working directory is home directory. You can use simple cd command to navigate to directory.
For example, if you would like to navigate to
/var directory, just type:
The pwd command is one of the most basic and frequently used commands in Linux. This 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. To view all locations containing pwd use the type command:
type -a pwd
It will show output as below:
pwd is a shell builtin pwd is /bin/pwd
Find your Current Working Directory
You can find currently in which directory you are. Type pwd command in your terminal as below:
It will look like below:
You can also show by printing environment variable.
It will give same output as pwd.
You can pass two arguments along with pwd command:
- -L (–logical) – It don’t resolve symlinks.
- -P (–physical) – It will display the physical directory not any symbolic links.
By default, pwd command used without any arguments and it will behave as
For example, there is a directory
/home/tecnstuff/test and symlink
/tmp/testsymlink points to that directory.
Now once you navigate to the
/tmp/testsymlink directory and you type
pwd in your terminal:
It will show output that your current directory is
But if you will execute same command with
-P argument, It will show print the directory to which the symlink points:
In this article, we explain how you can determine the current directory using
pwd command in Linux systems.
If you have any questions or feedback, feel free to leave a comment.