Summary
- The working directory in Linux is essential for navigating the file system via the terminal.
- Use the cd command to change the working directory, with either absolute or relative paths.
- The pwd command displays the working directory’s path, with options for logical or physical paths.
When you’re working in a Linux terminal, a specific directory will always be active. Linux refers to this as the working directory, and this essential concept lets you navigate your file system, list files, and run commands.
What Is the Working Directory?
The “working directory” (or “current directory,” “current working directory”) is a concept that’s specific to the Linux command line, although it should be familiar even if you’ve never opened a terminal. You can think of the working directory as an equivalent of a directory that you might be viewing in your file manager, like Files or Dolphin:
When you open a terminal, your working directory will usually start as your home directory (e.g. /home/$USER). You can navigate to different directories by changing your current working directory, using the cd command. For example, typing cd / will set your working directory to the root directory. Some commands you run—like ls, for example—will operate on the working directory, by default:
Without arguments, ls lists the contents of the working directory. You can override this behavior by passing at least one path to a file or directory as an argument to ls.
You don’t always need to change the working directory because many commands can operate on any directory or file you pass as an argument. But changing directories can make things much more convenient: you can get away without typing long paths, for a start.
How to Change Working Directory
The cd command is very straightforward. You’ll almost always use it like this:
cd [directory]
So cd / will change to the root directory and cd /usr/local/bin will change to the directory that contains local binaries on your machine:
It’s usually more practical to use relative paths instead of typing full absolute paths like in the previous example. So, if your current working directory is /usr/local, you can run cd bin to change to the directory named “bin” that is inside your working directory.

Related
How to Use the cd Command on Linux
You probably use the cd command on Linux without thinking much about it. But it’s packed with lots of extra features!
The cd command also has special behavior when you don’t pass it a directory, i.e. cd. In this case, it will attempt to run cd $HOME which makes it a very quick way of returning to your home directory.
Note that your shell will usually display the name of your working directory in the prompt at the beginning of each line. This can help to orient you, acting as a handy “you are here” reminder. But if your prompt doesn’t include this, or you choose to remove it, you can always use the pwd command to discover your current directory.
All About the pwd Command
The pwd command stands for “print working directory.” It writes the full path of your working directory to output:
There’s not much more to it, but pwd does support a pair of complementary options: -L and -P. These determine how the command deals with symbolic links. Consider the following case:
In this example, a directory contains a subdirectory and a link to that subdirectory. If you change to the notes directory, pwd will output “…/notes” as you’d expect. However, if you change to the link-to-notes directory—which is a symbolic link to notes—you’ll get a different response: “…/link-to-notes.”
What’s happening here is that pwd is showing the logical current directory. This makes sense as the default; it uses the symbolic links you’ve already defined and used, presumably for good reason. However, if you want the physical path to your working directory instead, use the -P option:
If you want to be sure of the logical behavior, instead of relying on it as the default, use -L. This will account for any aliases that may have altered the default behavior, for example. The cd command also supports -P and -L options which have the same corresponding effect.

Related
How to Create and Use Symbolic Links (aka Symlinks) on Linux
Let’s get symbologic.
What About the PWD Environment Variable?
The pwd command uses an environment variable called PWD to carry out its work. This environment variable should be set by any command that alters the current working directory, like cd. You can verify this by inspecting the value of $PWD:
This means that, in effect, you don’t really need pwd, although PWD will always contain the logical path, not the physical one.

Related
How to Set Environment Variables in Bash on Linux
A great way to save yourself some time.
When you change your working directory, your shell will also keep track of the directory you just left in OLDPWD. This is useful for the cd command, which will treat cd – the same as cd $OLDPWD, returning you to your previous working directory. If you need to continuously toggle your working directory between two specific directories, you can do so with repeated cd – commands.
Leave a Comment
Your email address will not be published. Required fields are marked *