CentOS Debian Mint openSUSE Red Hat Ubuntu

pwd Command in Linux

pwd Command in Linux

Introduction

pwd stands for print working directory. This command is very useful and is commonly used in Linux. When used the command will print the full path of the root directory to the current directory.

pwd is the command built into the shell or /bin/pwd. You can run the type command to see where pwd is contained:

$ type -a pwd

Output:

Below is the guide on how to use the pwd command in Linux as we go through below.

The syntax of pwd command

To find the current directory, run:

$ pwd

Output:

You can use another way with PWD environment variable:

$ echo $PWD

Output:

Options:

pwd -L: Prints the symlink.

pwd -P: Prints the real path.

By default, if you use the command without option, it will specify -L option.

To understand more clearly, we will create a directory and symlink to the directory:

$ sudo mkdir /usr/directory
$ sudo ln -s /usr/directory /usr/symlink

Next, we will navigate to /usr/symlink:

$ cd /usr/symlink

And now, we will try to use pwd command with -L option:

$ pwd -L

Output:

If you use pwd command with -P option:

$ pwd -P

Output:

Conclusion

You’ve already gone through the details of how to use the pwd command in Linux.

Thanks for reading.

Similar Posts