Linux

Master the Use of pwd Command in Linux

Introduction

CLI is a text-based interface used to control software and operating systems. CLI is characterized by the ease of writing commands and executing them quickly. This process requires a small computing resource, which cannot be achieved with the graphical interface, which consumes more resources. One of the advantages of the command line interface is the ability to create batch files for automated tasks.

Linux has a large list of commands that can be used in the CLI. Among these commands are ls, cd, and cp. But in this article, we will focus on pwd Command, short for print working directory. We will learn about the purpose of using the pwd command and what its syntax is. We will review a list of options and many practical examples.

What is pwd Command?

pwd command works as a GPS tool that helps you know where you are inside Linux. In other words, writing this command will show you the path name of the working directory starting from the root (/). It is an important tool for users who lose their position.

pwd Command Syntax

When writing pwd command, you must follow this syntax:

pwd [option]

pwd Command Options

Below is a table of all the options with a description of each one:

OptionDescription
-LLogical Path: prints the logical current working directory.
-PPhysical Path: prints the physical current working directory.
–versionVersion: displays version information for the pwd command.
–helpHelp: showing the available options and their descriptions

You may be wondering what the difference is between Logical Path and Physical Path. Let us explain that:

Logical Path Meaning

  • Logical Path is the path that you see and use to navigate through directories. It follows symbolic links.

Physical Path Meaning

  • Physical Path is the path that represents the actual physical location of a file or directory in the file system without following symbolic links.

Practical Examples of the pwd Command

Display the Current Working Directory:

pwd

Display the Logical Path:

pwd -L

Display the Physical Path:

pwd -P

Display help information:

pwd –help

Displays version information:

pwd –version

Conclusion

As we previously mentioned, Linux includes many commands, and the pwd command is one of this list. The goal of pwd is to display the working directory. It is an important tool for users, especially those who lose their way. If you have any suggestions or questions, you can use the comment box below. If you liked the article, do not forget to put it in your favorites. You may need it another day.

We use cookies and other tracking technologies to improve your browsing experience on our site, show personalized content and targeted ads, analyze site traffic, and understand where our audiences come from. By choosing Accept, you consent to our use of cookies and other tracking technologies.