7.4 "Linux learning is not difficult" file/directory management (4): cd command to change the working directory path
Use the cd command to change the user's working directory path. The working directory path can use an absolute path name or a relative path name. The absolute path starts from / (root) and then proceeds to the desired directory, and the relative path starts from the current directory.
Command syntax:
cd [options] [directory]
The meaning of each option in the command is shown in the table.
Options |
Meaning of options |
-P |
If a link path, the source physical path into the link path |
The cd command is used in combination with various symbols as shown below.
cd: enter the user's home directory;
cd ~: enter the user's home directory;
cd -: Return to the directory where you were before entering this directory;
cd .. : Return to the upper-level directory (if the current directory is "/", it will still be at "/" after execution.);
cd ../..: return to the upper two levels of the directory;
Example: Change the user working directory path to /etc.
[root@rhel ~]# cd /etc
Example: Change the path location of the user's working directory to the parent directory of the current directory.
[root@rhel etc]# cd .. [root@rhel /]# pwd /
Example: Change the path location of the user's working directory to the user's home directory.
[root@rhel /]# cd ~ [root@rhel ~]# pwd /root
This article is excerpted from the textbook " Linux Learning Is Not Difficult" , which is the most practical and practical Linux introductory textbook. To read the entire book, please visit the Linux operator ( www.linuxywz.com ) website .