Blog Datasheets Home About me Clients My work Services Contact

G2Labs Grzegorz Grzęda

Linux 'pwd' command

May 9, 2024

Understanding the ‘pwd’ Command in Linux

The ‘pwd’ command in Linux is used to display the present working directory. It provides the absolute path of the current directory you are in. In this blog post, we will explore this command in detail, including its usage and examples.

Command Syntax

The ‘pwd’ command follows a simple syntax:

1
pwd [OPTION]

Basic Usage

Without any options, the ‘pwd’ command will display the absolute path of your current working directory. For example:

1
2
$ pwd
/home/username/Documents

Here, the output displays the absolute path of the ‘Documents’ directory.

Useful Options

The ‘pwd’ command provides several options that can be used to modify its behavior. Here are some of the most commonly used ones:

Examples

Let’s look at some practical examples to better understand the ‘pwd’ command:

Example 1: Display the current directory

1
2
$ pwd
/home/username/Documents

In this example, ‘pwd’ displays the absolute path of the current working directory, which is ‘/home/username/Documents’.

Example 2: Use -L option to display the physical path

1
2
$ pwd -L
/home/username/Documents

By using the -L option, ‘pwd’ displays the physical path of the current directory, unaffected by any symbolic links.

Example 3: Use -P option to display fully resolved physical path

1
2
$ pwd -P
/home/username/MySymLink/Documents

In this example, the -P option resolves the symbolic links and displays the fully resolved physical path.

Example 4: Display the help message

1
$ pwd --help

Using the --help option, ‘pwd’ displays the help message, providing information about the command and its available options.

Example 5: Display the version information

1
2
$ pwd --version
pwd (GNU coreutils) 8.32

With the --version option, ‘pwd’ displays the version of the command utility.

Conclusion

The ‘pwd’ command in Linux is a simple and useful tool for displaying the current working directory. By understanding the options available, you can enhance your usage and tailor it to your specific needs. Using the examples provided in this blog post, you are well-equipped to master the ‘pwd’ command in Linux. Happy coding!


➡️ Introductory Guide to Working with SPI and I2C on ESP32


⬅️ Leveraging Bluetooth in ESP32: Creating Smart IoT Devices


Go back to Posts.