pwd¶
Shows the full path of the directory you are currently in.

Syntax¶
pwd [OPTION]
Options¶
| Option | Description |
|---|---|
-L |
Show the logical path, including symbolic links (default) |
-P |
Show the physical path, with all symbolic links resolved |
Examples¶
Show the current directory:
pwd
/home/nox
Check where you are after changing directory:
cd /etc/ssh
pwd
/etc/ssh
Show the real path behind a symbolic link:
cd /var/run
pwd
pwd -P
/var/run
/run
On current Linux distributions, /var/run is only a link to /run. pwd shows the path
you used, pwd -P shows where you really are.
pwd -P shows where you really are.
Use the current directory in a command:
echo "Backup of $(pwd)"
Backup of /home/nox
When do I need it?¶
- When the prompt only shows a shortened path, or no path at all
- Before running commands with relative paths like
rm *.log, to be sure you are in the right directory - In scripts, to remember the starting directory or to build absolute paths
- To find out the real location when symbolic links are involved (
pwd -P)
Good to know
The shell always stores the current directory in the variable $PWD. echo "$PWD"
prints the same as pwd. The previous directory is stored in $OLDPWD.
Check before you delete
Before rm, chmod -R or chown -R with relative paths, run pwd once.
The same command in the wrong directory can do a lot of damage.