Linux pwd command: display the current path

Because there are many Linux file system directory, when the user performs a Linux command and no directory where the command or parameter specifies the time, Linux system will first search command or its arguments in the current directory (the current working directory). Therefore, the user before executing the command, it is often necessary to determine the current working directory is located, that is, the current directory.

 

When the user logs Linux system, its current directory is its home directory. So, how to determine the current directory it? Linux systems can use the pwd command to display the absolute path of the current directory.

pwd command, a Print Working Directory (print working directory) abbreviation is a function in which the user's current working directory. The basic format of the command is:

[root@localhost ~]# pwd

【Example 1】

[root@localhost ~]# whoami
root
[root@localhost ~]# pwd
/root

whoami command is used to determine the user currently logged in, follow-up will be described in detail. We can see that the current directory is the root user's home directory it / root.

[Example 2]

[demo@localhost ~]# whoami
demo
[demo@localhost ~]# pwd
/home/demo

The above code shows that the current system is the user login Linux demo, the current directory is the home directory of the demo / home / demo.

Note that, in  [demo@localhost ~]# this section, although also shows current directory (e.g., ~ represents the home directory), but the position of the entire route lists only that the last directory, such as:

[root@localhost ~]# cd /var/mail
[root@localhost mail]# pwd
/var/mail

We know that different directories, directory name can be repeated, therefore, only through  [root@localhost mail] the mail, can not determine the specific location in which it is, and use the pwd command, you can output the current full path to the directory.

Published 33 original articles · won praise 0 · Views 400

Guess you like

Origin blog.csdn.net/linuxanz/article/details/103474949