General

How To: Find Your Present Working Directory

There are times when you need to know your present working directory. You may need to know because the terminal doesn’t output that data, you may need to know for scripting, you may need to know for a variety of reasons.

So, what is the present working directory? Well, it’s simply a fancier name for the directory you happen to be working in – usually in the terminal. If you open your terminal and type something like cd Downloads, then your present working directory is going to be something like /home/<user>/Downloads. It’s pretty simple and this is going to be a pretty basic article. It’ll be a nice and easy exercise, even for a newbie.

There are a couple of ways to determine your present working directory and we’ll share them with you today. It’s really not a very complicated article, and not all articles need to be complicated. Sometimes, you just need new information that will help get you up to speed with your Linux understanding. After all, that’s the stated goal of the site.

Your Present Working Directory:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

As I said above, there are a couple of ways to do this. With your terminal open, why don’t you type something like cd Downloads just to have a different directory than your default directory.

When that’s done, just enter the following command:

pwd

The output should look a little something like this:

See? It’s all pretty basic information that you’ll need to know.

But wait, there’s more! There’s also an environment variable that will show you your present working directory. It’s pretty simple and you can use it like this (among other ways):

echo $PWD

Be sure to make note of the dollar sign and the all caps. You’ll need to include those if you want it to work. Depending on what you’re doing, you may want to use the environment variable (as I understand, it’s better to do this when  you’re scripting).

You can see an example of $PWD usage here.

Closure:

There you have it, another article. This one shows you how to determine you present working directory. As far as articles go, this one is pretty short and easy, aimed at newer Linux users.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Meta: The State Of Linux Tips #23

Today's article is just a meta article, an article that I fail to write every…

11 hours ago

Is Your Storage Drive An SSD Or An HDD?

Today's article aims to answer a simple question, simply is your storage drive an SSD…

2 days ago

Monitor System Resources With “Resources”

Today is one of those days when I'd like to introduce you to new software…

4 days ago

Short: The Halt Command

Today's article is intentionally short because we're simply going to learn about the basics of…

6 days ago

Installing Flatpaks In Linux

Today we're going to have a pretty easy article where you'll learn about installing Flatpaks…

1 week ago

A Quick Look At The Shutdown Command

This is going to be just a quick article about a command many of you…

1 week ago