pwd is a short form for “Print Current/Working Directory” in Linux. As its name suggests this command is used to get the current working directory. That means it gives the path of the folder in which you are currently present. The path format is from the root directory to the current directory.
The syntax for command:
pwd [OPTION]
Let’s use this command
After starting Ubuntu we are on a desktop so, the current directory will be the same
/Desktop$ pwd
/home/myuser/Desktop
Using the “cd” command we step back from the desktop and enter the home directory. And using “pwd”we check whether we step back or not.
/Desktop$ cd ../
$ pwd
/home/myuser
Again using the “cd” command we enter into the Videos directory. And using “pwd” we check whether we enter into the directory or not.
$ cd Videos
/Videos$ pwd
/home/myuser/Videos
We have successfully printed the current working directory and check using “pwd” command.
Let’s have look at options for “pwd” command
$ pwd -L
“pwd -L” gives a symbolic path of the directory.
$ pwd -P
“pwd -P” gives the actual path of the directory.
The default behaviour of pwd is the same as pwd -L.