How to show current working directory's path on Linux

Note: Before delving into this Answer, an overview of Linux may be helpful.

Knowing our current location within a file system is crucial for managing files inside Linux. One of the most basic command for this purpose is pwd, which stands for “print working directory.” In this Answer, we’ll explore how to use the pwd command to display the path of the current working directory on a Linux system.

When we open a terminal in a Linux system, we start in a specific directory known as the user’s home directory. As we navigate through the file system using commands like cd (change directory), our current working directory changes accordingly. Enter ls in the terminal above to see the content of the current directory.

For this example, cd into any directory. An example of one such command is:

cd usercode

Now, we’ll use the pwd command:

pwd

This will output the full path of the directory we’re currently in, i.e., /usercode.

Flags

Let’s explore some flags we can append to this command.

The -logical flag

We can use -L or –logical as a flag:

pwd -L

This option above displays the logical current working directory. It does not resolve symbolic links, showing the path exactly as we navigate to it. For example, if we are in usercode directory, the above command will display /usercode as the output.

The -physical flag

We can use -P or –physical as a flag:

pwd -P

This option displays the physical current working directory. It resolves symbolic links, showing the “real” path.

For this example, we’ve created an example directory. Navigate to it as follows:

cd ~/logical_physical_demo/main_directory/symlink_to_subdirectory

Test both of these commands in the terminal provided prior.

Implementation

Use the terminal below to enter commands:

Terminal 1
Terminal
Loading...

Knowledge test

Now we have understood how to display the current working directory path in Linux, let's test our knowledge on this:

1

What does the pwd command stand for in a Linux system?

A)

Present working directory

B)

Print working directory

C)

Path working directory

D)

Position working directory

Question 1 of 30 attempted

Summary

Summary of -P and -L Flags

Flag

Description

Example

-P

Displays the physical current working directory by resolving the symbolic links.

pwd -P

-L

Displays the logical current working directory, without resolving the symbolic links.

pwd -L

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved