In this article, we will show you about pwd command in Linux. How to find out your current working directory using the pwd command. The pwd command is also known as the print working directory. This command shows the current working directory where you are in. This command shows you the full path of your current directory. The syntax for pwd command:
What is the Current Working Directory
The current working directory is the directory where the user is currently working in. Each time you interact with your command prompt, you are working within a directory.
Syntax
- pwd -L: Prints the symbolic path.
- pwd -P: Prints the actual path.
The pwd command writes to standard output the full path name of your current directory (from the root directory). All directories are separated by a / (slash). The root directory is represented by the first /, and the last directory name is your current directory.
Flags
-L
Displays the value of the PWD environment variable if the PWD environment variable contains an absolute path name of the current directory that does not contain the file names. (dot) or .. (dot-dot). Otherwise, the -L flag behaves the same as the -P flag.
-P
Displays the absolute path name of the current directory. The absolute path name displayed with the -P flag does not contain file names that, in the context of the path name, refer to files of type symbolic link.
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.
How to Find your Current Working Directory
To find out what directory you are currently in, type pwd in your terminal:
$ pwd
The output will look something like this:
/home/linuxips
What the pwd does is print the PWD environment variable.
You will get the same output if you type:
$ echo $PWD
/home/linuxips
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/directory ln -s /tmp/directory /tmp/symlink
Now if you navigate to the /tmp/symlink directory and you type pwd in your terminal.
Conclusion
So this is the pwd Command in Linux. 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.
Related Linux Tutorials: