Displays the absolute path of the current working directory.
The pwd (English full spelling: print working directory) command is used to display the user's current working directory (displayed as an absolute path).
pwd [-LP]
-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.
The return status is success unless an illegal option is given or the current directory cannot be read.
pwd [OPTION]...
-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.
The return status is success unless an illegal option is given or the current directory cannot be read.
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