SSH Commands: PWD

On this page
  1. Understanding Absolute vs. Relative Pathways
  2. Command Execution and Output Analysis

In server administration, backend web development, and cloud systems engineering, managing remote environments via Secure Shell (SSH) requires continuous awareness of your current position within the server’s file system tree.

The pwd command stands for Print Working Directory. It is a fundamental, POSIX-standard command-line utility used to display the exact file path of the directory you are currently working in.

Understanding Absolute vs. Relative Pathways

When you execute commands inside a terminal window, you are always positioned within a specific folder called your current working directory. The pwd command returns the absolute path to this folder.

  • Absolute Paths: A complete, unambiguous route that defines a file or folder’s position from the absolute base of the file system. It always begins with a forward slash (/), which represents the root directory of the server. An example of an absolute path within a shared hosting ecosystem is /home/mybox/yourlogin.
  • Relative Paths: A path built in relation to your current working position rather than the system root. For example, if you are inside your home folder and want to navigate into a subfolder named public_html, the string public_html is a relative path.

Command Execution and Output Analysis

To use this utility, establish an active SSH connection to your server using a terminal application or a client tool like PuTTY. Once logged in, type the command in lowercase letters and press Enter:

pwd

The system will instantly evaluate your current location and return a single line of text displaying the full directory path:

/home/mybox/yourlogin/public_html/staging

Common Navigational Scenarios

Knowing your absolute path is highly beneficial when moving between folders using the cd (Change Directory) command:

  1. Logging In: When you first open your SSH terminal session, the server automatically places you inside your personal user home directory. Running pwd will show your base path.
  2. Moving Deeper: If you execute cd public_html, you move into your web directory. Running pwd again will show your path updated with /public_html appended to the end.
  3. Tracking Context: When executing automated bash scripts, installing application dependencies via Composer, or running command-line utilities, executing pwd first ensures you are running those actions inside the correct folder workspace.

Didn't find an answer?

Our support team is here for you 24/7 – write to us and we will help you sort it out.