Use of relative paths, absolute paths, and cd commands
Cd (change directory) directory
Jump to the specified directory
There are two types of path definitions: absolute path (absolute) and relative path (relative)
Absolute path: the file name or directory name written from the root directory (/)
Example:/tmp/test/test1
Relative Path: the file name method relative to the current path
For example,./home/dmtsai or.../home/dmtsai.
The following uses the cd command to explain the relative path and absolute path.
For example, there are two files
/Tmp/test/test1
/Tmp/test/fun/test2
If you want to go to the fun directory, you can do this.
$ Cd/tmp/test/fun
$ Pwd: we can see that the user is now in the fun directory, and the previous directory is test.
If you want to go to the test directory, you can do this.
$ Cd .. this is the method of writing relative paths, directly jump up from the current directory, that is, test
$ Cd/tmp/test: this is the absolute path, or it starts from the root. If the directory is long
The method increases the input, but this is the most accurate method.
Bytes ------------------------------------------------------------------------------------
.: Indicates the current directory./also indicates the current directory.
..: Indicates the previous directory ../is also the meaning of the previous directory
-: Relative to the current directory, the previous directory
For example, using $ cd/from/tmp/test/fun will jump to the root directory and then use
$ Cd-Return to the/tmp/test/fun directory
~ : Indicates the user's home directory
Cd [~] : Jump to the Home Directory of the current user
Cd ~ Username: jump to a user's home directory