pwd stands for print working directory. pwd outputs the full pathname of the current work directory.

$ pwd

pwd can also be used to store the full path to the current directory.


Useful Options / Information

pwd vs /bin/pwd

  • /bin/pwd ignores symlinks and prints actual directory by default.
  • pwd is a shell builtin provided by bash that links to /bin/pwd
  • /bin/pwd is the binary version of pwd

pwd -L

$ ln -s . test
$ cd test && pwd
$ /bin/pwd
$ /bin/pwd -L
Break it down
  • --logical or -L option displays the logical current working directory.
  • Built in ‘pwd’ includes symlinks by default except when -P is used.
    • /bin/pwd ignore symlinks and prints out the actual directory.
    • For /bin/pwd to get the same result as the built in pwd, you must use the -L option.

pwd -P

$ cd ~/bin
$ pwd
$ pwd -P
Break it down
  • --physical or -P Print a fully resolved name for the current directory. That is, all components of the printed name will be actual directory names–none will be symbolic links.