pwd is Unix command to Print Current Working directory. You may find it referred as Present Working Directory in some books.
Below are the options:
- -L – logical use PWD from environment, even if it contains symlinks
- -P – physic avoid all symlinks
- –help – display this help and exit
- –version – output version information and exit
pwd is shell built-in as well as function. If the shell has its own version it supersedes function shell.
Run below command to check pwd command path and type.
$ type -a pwd pwd is a shell builtin pwd is /bin/pwd
-L and –P options are applicable to pwd shell built-in. /bin/pwd supports all above four options. Check below example for details.
Let’s create a symbolic link to a directory to demonstrated -L and -P option.
Physical Directory: /home/atech/physical_dir
Logical Directory:/Home/atech/logical_dir. It is symbolic directory pointing to Physical Dir
$ls -l *cal_dir* lrwxrwxrwx. 1 atech admin 12 Oct 24 09:15 logical_dir -> physical_dir physical_dir: total 0
$ cd logical_dir $ pwd /home/atech/logical_dir $ echo $PWD /home/atech/logical_dir $ pwd -L /home/atech/logical_dir $ pwd -P /home/atech/physical_dir
$ pwd --help -bash: pwd: --: invalid option pwd: usage: pwd [-LP]
You can clearly see –help is not supported for pwd as it is shell built-in. Let’s see /bin/pwd
/bin/pwd --help Usage: /bin/pwd [OPTION]... Print the full filename of the current working directory. -L, --logical use PWD from environment, even if it contains symlinks -P, --physical avoid all symlinks --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. Report pwd bugs to [email protected] GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> For complete documentation, run: info coreutils 'pwd invocation'
$ /bin/pwd --version pwd (GNU coreutils) 8.4 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Jim Meyering.