pwd
Displays the absolute path of the current working directory.
Supplementary instructions
The pwd (English full spelling: print working directory) command is used to display the user's current working directory (displayed as an absolute path).
Built-in commands
Summary
pwd [-LP]
Options
-L (default) Print the value of the environment variable "$PWD", which may be a symbolic link.
-P Prints the physical location of the current working directory.
return value
The return status is success unless an illegal option is given or the current directory cannot be read.
Notice
-
This command is a built-in bash command. For related help information, please see the
helpcommand.
External commands
Summary
pwd [OPTION]...
The main purpose
Options
-L, --logical Print the value of the environment variable "$PWD", which may be a symbolic link.
-P, --physical (default) Print the physical location of the current working directory.
--help Display help information and exit.
--version Display version information and exit.
return value
The return status is success unless an illegal option is given or the current directory cannot be read.
Notice
-
This command is a command in the
GNU coreutilspackage. For related help information, please viewman pwdorinfo coreutils 'pwd invocation'. -
To enable or disable built-in commands, please see the
enablecommand. For issues with the priority of the same name, please see the relevant discussion in the examples section of thebuiltincommand. -
When the built-in is not disabled and the
pwdfunction is not defined in the current environment, use/usr/bin/pwdto point to thepwdofcoreutilsand usepwdto point to the bash built-inpwd.
example
View current path
[root@localhost var]#pwd
/var
Display the file path that the soft link file ultimately points to
[root@localhost ~]# cd /var/ # Enter the /var directory. There is a mail soft link file in this directory.
[root@localhost var]# ls -al
total 164
...
lrwxrwxrwx 1 root root 10 Oct 17 2015 mail -> spool/mail
[root@localhost var]# cd mail/ # Enter the mail directory, where mail is the connection file.
[root@localhost mail]# pwd # By default, the connection file is used and the full path of the connection file is directly displayed.
/var/mail
Using the -P parameter, what is displayed is not the logical path, but the file that the connection (soft link) file ultimately points to.
[root@localhost mail]# pwd -P
/var/spool/mail


