How to Check Your Current Working Directory in Linux Using pwd

Unlike a graphical desktop environment where you can constantly see folder windows and breadcrumb trails at the top of your screen, a Linux terminal can be incredibly disorienting.

When you log into a server via SSH, you are often greeted by a blank prompt that looks like this: user@server:~$. If you immediately start running destructive commands like rm -r * (delete everything), you need to be absolutely certain you know exactly which folder you are currently standing inside.

The command to figure out your exact location is pwd.

What Does pwd Stand For?

The command pwd stands for Print Working Directory.

In Linux terminology, your “Working Directory” is simply the folder your terminal is currently focused on. “Print” means to output the text to the screen.

How to Use the pwd Command

The pwd command is one of the simplest commands in all of Linux because it requires no arguments, flags, or configuration. You simply type it and press Enter.

Example:

pwd

Output:

/var/www/html/public_images

The command will always return the absolute path. An absolute path always begins at the very root of the Linux filesystem (the initial forward slash /), proving exactly where you are in the hierarchy.

Why the Tilde (~) is Misleading

You might wonder why you need pwd when the terminal prompt often gives you a hint. For example, if you see user@server:~/Downloads$, it seems obvious you are in the Downloads folder.

However, the default prompt often uses a tilde (~). The tilde is a shortcut symbol representing the current user’s personal home directory.

If you are logged in as the root administrator, the tilde represents /root. If you are logged in as a normal user named Sarah, the tilde represents /home/sarah.

If you see ~/Downloads and you run a script that creates files, where did those files actually go? To be 100% sure, you run pwd.

The terminal will output /home/sarah/Downloads, removing all ambiguity and proving the absolute, full path to your current location.

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.