Linux uses the PWD command to view the full path of the current working directory. Simply put, every time you operate on a terminal, you have a current working directory.
When you are unsure of the current position, you use PWD to determine the exact location of the current directory within the file system.
1. Command format:
PWD [Options]
2. Command function:
View the full path to the current working directory
3. Common parameters:
Usually without any arguments
If the directory is a link:
Format: Pwd-p shows the actual path rather than using the connection path.
4. Common examples:
Example 1: View the full path to the default working directory with the PWD command
Command:
Pwd
Output:
[Root@localhost ~]# pwd
/root
[Root@localhost ~] #
Example 2: Use the PWD command to view the specified folder
Command:
Pwd
Output:
[Root@localhost ~]# cd/opt/soft/
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]#
Example three: When a directory connection link, Pwd-p displays the actual path instead of using the connection path; pwd shows the connection path
Command:
Pwd-p
Output:
[Root@localhost soft]# CD/ETC/INIT.D
[Root@localhost init.d]# pwd
/etc/init.d
[Root@localhost init.d]# Pwd-p
/etc/rc.d/init.d
[Root@localhost init.d]#
Instance 4:/bin/pwd
Command:
/bin/pwd [Options]
Options:
-L directory connection link, output connection path
-P Output Physical path
Output:
[Root@localhost init.d]#/bin/pwd
/etc/rc.d/init.d
[Root@localhost init.d]#/bin/pwd--help
[Root@localhost init.d]#/bin/pwd-p
/etc/rc.d/init.d
[Root@localhost init.d]#/bin/pwd-l
/etc/init.d
[Root@localhost init.d]#
Instance five: The current directory is deleted, and the PWD command still displays that directory
Output:
[Root@localhost init.d]# Cd/opt/soft
[Root@localhost soft]# mkdir removed
[Root@localhost soft]# CD removed/
[Root@localhost removed]# pwd
/opt/soft/removed
[Root@localhost removed]# rm.. /removed-rf
[Root@localhost removed]# pwd
/opt/soft/removed
[Root@localhost removed]#/bin/pwd
/bin/pwd:couldn ' t find directory entry in "..." with matching I-node
[Root@localhost removed]# CD
[Root@localhost ~]# pwd
/root
[Root@localhost ~]#
View a full set of articles: Http://www.bianceng.cn/OS/Linux/201301/35075.htm