How to Print The Current Working Directory using the Terminal on Linux Mint

Share
In this tutorial, we'll learn how to print the current working directory using the terminal on Linux Mint, and a bit about how it works.

The current working directory (CWD) or present working directory (PWD) refers to which directory you're currently "in" while using the terminal. Many terminal commands have their behavior affected by what is the current working directory.

To print the current working directory, simply execute the following terminal command [how?]:

pwd

The current working directory is also available through the environment variable PWD, so we can also use the echo command to view it by passing it as the first argument.

echo $PWD

Additionally, the current working directory is part of the shell prompt by default on Linux Mint.

Your shell prompt should be something like john@pc:~$. The tilde (~) in this text code refers to the home directory, and its position in the shell prompt indicates the current working directory. In other words, this shell prompt is telling us that we're currently "in" the home directory. This will affect the behavior of commands like ls that depend on the value of the current working directory.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments