Example Analysis of path under Linux
This article mainly introduces the example analysis of the path under Linux, which is very detailed and has a certain reference value. Friends who are interested must finish it!
In general, when we use shell calls, or how you call your application, note that your current path is the path of your called program.
Paths are divided into absolute paths and relative paths:
Absolute path:
In Linux, absolute paths start with / (also known as root), such as / usr, / etc/X11. If a path starts from /, it must be an absolute path, so it is easy to understand
[root@localhost] # pwd Note: determine the current location of the user, that is to say, where he is.
/ root Note: the user is currently located at / root
[root@localhost ~] # cd / usr/share/doc/ Note: we enter the / usr/share/doc directory by absolute path
[root@localhost doc] # pwd Note: determine the current location of the user
/ usr/share/doc Note: the user is located at / usr/share/doc, which seems to have achieved our goal.
Relative path
The relative path is based on. Or; or It started. Represents the location of the user's current operation, and.. Represents the parent directory; in the path,. Represents the directory where the user is currently located, and.. The superior directory needs to be transferred. And... Look at it as a catalog.
[root@localhost ~] # pwd Note: use pwd to determine the location of the current user
/ root Note: find out that the directory is in / root directory
[root@localhost] # cd. Note: we enter.
[root@localhost ~] # pwd Note: determine the location of the current user
/ root Note: get in the / root directory
[root@localhost] # cd. Note: we cut into the parent directory of / root
[root@localhost /] # pwd Note: determine the location of the current user.
/ Note: the user is currently in / (root directory)
The description of some special symbols in the path
These symbols are used in relative paths, and these symbols can bring us convenience, so it is necessary to talk about them.
. Represents the current directory where the user is located
.. Represents the parent directory
~ represents the current user's own home directory
~ USER indicates that the user name is the home directory of USER, where USER is the user name that exists in / etc/passwd.
The above is all the contents of the article "sample Analysis of paths under Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!