2 Methods to Get Current Working Directory in Linux

2 Methods to Get Current Working Directory in Linux

When working with files and directories in Linux, can be useful to determine current working directory. It is directory in which the user is currently working in. This tutorial provides 2 methods how to get current working directory in Linux.

Method 1 - pwd command

The pwd command prints the full path to the current working directory.

pwd

Output example:

/home/john

Method 2 - PWD environment variable

The full path to the current working directory is stored in the PWD environment variable. It can be printed as follows:

echo $PWD

Leave a Comment

Cancel reply

Your email address will not be published.