pwd stands for print working directory. This command will basically 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
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux commands queries.
In this context, we shall look into how to use the pwd command in Linux.
As we have already stated, pwd command will find the current directory. Its syntax is provided below:
$ pwd
You can use another way with PWD environment variable:
$ echo $PWD
Its command Options is explained below:
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
If you use pwd command with -P option:
$ pwd -P
This article covers how to use the pwd command in Linux. In fact, pwd Linux command is mainly used for printing the name of the current working directory. Examples of printing the current working directory, avoiding symlinks and how to get the current working directory in shell scripts.