The Linux command pwd inserts the entire path of your current working directory into the standard output. The command is essential for main­tain­ing accurate directory tracking in Linux and can be cus­tom­ised various ways.

What is the Linux pwd command?

pwd stands for ‘Print Working Directory’ in Linux. Along with the Linux cd command, it’s one of the most fre­quently used commands for everyday tasks. The main task of pwd is to insert the complete pathname of the current directory into the output. The in­di­vidu­al sub­dir­ect­or­ies are separated by dashes. The pwd command is available as a built-in command and as a stand-alone program. This is included in the standard in­stall­a­tion of all common Linux dis­tri­bu­tions like Debian or Ubuntu.

How does Linux pwd work?

Using the pwd command you get the full path of your current directory in the output. This is ad­vant­age­ous if you fre­quently switch between dir­ect­or­ies or work with numerous sub­dir­ect­or­ies. With Linux pwd you retain an overview of all your paths and can save or access files in a targeted manner, even in extensive projects.

What is the syntax of the pwd command?

The syntax of Linux pwd is simple and always looks like this:

$ pwd [Options]
bash

When you execute the pwd command without any options, it will display the full pathname of your current working directory as output. Thanks to different options you can customise this output.

What are the Linux pwd command options?

The pwd command has two important options which are mutually exclusive:

  • -L: Even if the ‘physical’ option is set in the shell, the pwd command will not resolve symbolic links and will display the symbolic link itself if present.
  • -P: This option resolves a symbolic link.

The program /bin/pwd, on the other hand, re­cog­nises only the ‘–help’ option. By using it, you can retrieve ad­di­tion­al in­form­a­tion about the pwd command, including its usage and available options.

Examples for the pwd command

When you execute the pwd command, it will always display the path of your current working directory as the output. To obtain this result, simply enter the command exactly as shown in the syntax section above. The output will resemble the following:

/home/subfolder
bash

If you use the program, run Linux pwd as follows:

/bin/pwd
bash

The output is as above:

/home/subfolder
bash

If you now add the option ‘-L’, the command looks like this:

/bin/pwd -L
bash

The ap­pro­pri­ate output would look like this:

/home/subfolder/dir_simlink
bash
Go to Main Menu