How to Find Your Current Working Directory in Linux Using the pwd Command

When you navigate through the Linux file system using the command-line interface, it is remarkably easy to lose track of exactly where you are. Unlike graphical file managers that display a constant breadcrumb trail (e.g., C:\Users\John\Documents) at the top of the window, a Linux terminal prompt often only displays the name of the immediate folder you are sitting in.

If you need to know your exact absolute path—perhaps to write a script, configure a web server, or ensure you do not accidentally delete files in the wrong location—you must use the pwd command.

What is the ‘pwd’ Command?

pwd stands for Print Working Directory. It is one of the most fundamental and frequently used commands in Unix-like operating systems.

When executed, it performs a single, simple action: it queries the kernel for your current location and prints the full, absolute path from the root directory (/) down to your current folder directly into the terminal output.

How to Use the Command

The command is almost always used entirely on its own, without any flags or arguments.

pwd

Example Scenario:

If your terminal prompt looks like this: user@server:~/config$

You know you are in a folder called “config” inside your home directory (represented by the ~ tilde symbol). If you type pwd and press Enter, the terminal will output the absolute path:

/home/user/config

Understanding Logical vs. Physical Paths

While pwd is usually run without flags, there is one critical edge case involving symbolic links (symlinks).

Imagine you have a symlink at /home/user/logs that acts as a shortcut pointing to /var/log/apache2/.

  • If you use the cd /home/user/logs command and then type pwd, the system will output the logical path you followed: /home/user/logs. (This is the default behaviour, equivalent to typing pwd -L).
  • However, if you need to know the physical location of the files on the hard drive, you can pass the physical flag: pwd -P. The system will trace the symlink to its origin and output the true physical path: /var/log/apache2.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.