CD Switch Directory command
1. Command format
CD [option] [directory name]
2. Command function
Switch working directory
3. Common examples
Example 1:CD ~
Description: ~ default is the home directory of the root, if the ~ after the user name, you can enter the home directory of the specified user
[Email protected] ~]#
[[Email protected] ~]# CD/
[Email protected]/]# pwd
/
Note: Enter the system root directory, the above command after the implementation of the PWD command to see, the current directory has been to the system root directory .
[Email protected]/]# CD ~
[Email protected] ~]# pwd
/root
Description: Use the CD command to access the home directory of the root user.
[Email protected] ~]# CD ~STU1
[Email protected] stu1]# pwd
/home/stu1
Description: Use the CD command to access the home directory of the normal user stu1.
Example 2: Jump to the specified directory Cd/var/log
[Email protected] stu1]# cd/var/log/
[Email protected] log]# pwd
/var/log
[[email protected] log]# ls
[Email protected] log]# CD httpd
[Email protected] httpd]# pwd
/var/log/httpd
[Email protected] httpd]#
description : Jump to the specified directory, starting from the root directory name plus/, the current directory of subdirectories directly write the name; relative path: The path starting at the current position
Example 3 : CD- : Returns the directory where it was before entering this directory
[Email protected] httpd]# cd/usr/share/yum-
[Email protected] httpd]# cd/usr/share/yum-plugins/
[Email protected] yum-plugins]# CD-
/var/log/httpd
[Email protected] httpd]# CD-
/usr/share/yum-plugins
[Email protected] yum-plugins]#
Example 4: use cd!$ The parameters of the previous command as CD parameters
[Email protected] ~]# ls/var/log/
Anaconda.ifcfg.log btmp DMESG maillog-20161129 PPP Spice-vdagent.log
[Email protected] ~]# CD!$
cd/var/log/
[Email protected] log]# pwd
/var/log
[Email protected] log]#
Example 5: Return to the parent directory CD of the current directory.
[Email protected] log]# pwd
/var/log
[Email protected] log]# CD.
[Email protected] var]# pwd
/var
[Email protected] var]#
This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1879772
One day a linux Base command Directory Management Class command CD