pwd Command in Linux with Examples


This tutorial explains Linux “pwd” command, options and its usage with examples.

pwd- print working directory.


The pwd command is considered as one of the most frequently used commands on Linux, AIX, HP-UX, *BSD, and other UNIX like operating systems along with the ls, and cd commands. It can be used for the following purposes under Apple OS X or UNIX or Linux operating systems:

1. Find the full path to the current directory.
2. Store the full path to the current directory in the shell variable.
3. Verify the absolute path.
4. Verify the physical path i.e exclude symbolic links.


pwd [OPTION]…

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!


-L, –logical
use PWD from environment, even if it contains symlinks.
-P, –physical
avoid all symlinks.


1. Simple usage of pwd(self explanatory)

$ pwd
$ cd ..
$ pwd

2. To display the logical current working directory, enter

$ pwd -L

The -L option cause pwd to use $PWD from environment, even if it contains symlinks. If the contents of the environment variable PWD provide an absolute name of the current directory with no . or .. components, but possibly with symbolic links, then output those contents.

3. Display the physical current working directory (all symbolic links resolved)


For example, ~/bin/ is symbolic link:

$ pwd
$ ls -l ~/bin/

Sample outputs:

lrwxrwxrwx 1 abc abc 35 May 13  2012 /home/abc/bin -> /home/abc/realdata/scripts/utils/

cd to ~/bin/ and verify the current working directory with pwd:

$ cd ~/bin/
$ pwd

Sample output:


To see actual physical current working directory and avoid avoid all symlink called /home/abc/bin, enter:

$ pwd -P

Sample outputs:


Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.