pwd
pwd stands for print working directory. pwd outputs the full pathname of the current work directory.
$ pwd
/home/bo/Desktop
pwd can also be used to store the full path to the current directory.
x=$(pwd)
Useful Options / Information
pwd vs /bin/pwd
/bin/pwdignores symlinks and prints actual directory by default.pwdis a shell builtin provided by bash that links to/bin/pwd/bin/pwdis the binary version of pwd
pwd -L
$ ln -s . test
$ cd test && pwd
/home/bo/Desktop/test
$ /bin/pwd
/home/bo/Desktop
$ /bin/pwd -L
/home/bo/Desktop/test
Break it down
--logicalor-Loption displays the logical current working directory.- Built in ‘pwd’ includes symlinks by default except when
-Pis used./bin/pwdignore symlinks and prints out the actual directory.- For
/bin/pwdto get the same result as the built inpwd, you must use the-Loption.
pwd -P
$ cd ~/bin
$ pwd
/home/bo/bin
$ pwd -P
/home/bo/realdata/scripts/utils
Break it down
--physicalor-PPrint 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.