The “Print Working Directory” (pwd) command in Linux is used to show the user’s current working directory. The command shows the location of the user’s current directory and its path.
The command’s fundamental syntax is as follows:
Use of pwd Command Example Syntax
pwd
It rejects all defenses and alternatives. The command will print the complete path to the current working directory to the terminal when you run it.
The result of the command pwd, for instance, will look like this if the user is presently in the directory /home/user/documents:
Input Command:
pwd
Output:
/home/user/documents

While using pwd typically no flags/options are used , but occasionally it might contain one like -L or -P
- -L: The logical current working directory can be seen with this option. Whether or not it is a symbolic link, it follows them and displays the path to the directory the user is now in.
- -P: The -P switch displays the actual current working directory. It will provide you the directory’s true file system path, including with any possible symbolic links.
The pwd command is typically used to verify the user’s current working directory and location before executing additional commands. It is especially helpful when working with relative paths because it enables the user to verify that the relative paths are accurate by viewing the complete path of the current directory.