The Linux pwd command

The Linux command pwd is a very simple utility that allows you to display in the terminal the path to the current folder. Each program when run gets the current directory which will run all the operation with its files unless you specified another path. All relative paths will also be run from this folder.

When you run terminal, the current folder is considered the user’s home directory. If the program is run from a specific folder, its current folder is the folder from which it was launched.

The pwd command in Linux

To just view the current folder Linux enough to run pwd without any parameters:


Also the team has one option -P. If the path to the current folder is a symbolic link, then the utility will show the full path excluding symbolic links:

pwd -P

In most shell pwd is a built-in command. Therefore, the interpreter does not need to call an external utility, and execution time when running very fast.

To see the current directory in the script do not have to use this command. Enough to turn the environment variable PWD:

echo $PWD

But you can also write the output to a variable:


echo $CWD


The pwd command is used rarely, more often we need to change the current folder. This applies to the cd command. As you can see, it’s very simple.


(Visited 31 times, 1 visits today)