1. Command function
CD: Toggle the current working directory
2. Command format
CD [directory name or directory path]
3. Command instances
Example 1: Switching the root directory
[Email protected] ~]# pwd
/root
[[Email protected] ~]# CD/
[Email protected]/]# pwd
/
Example 2: Switch to the top level directory
[Email protected] ~]# pwd
/root
[Email protected] ~]# CD.
[Email protected]/]# pwd
/
Example 3: Switch to the host directory: [~] can be omitted
[Email protected] ~]# cd/etc/init.d/
[Email protected] init.d]# pwd
/etc/init.d
[Email protected] init.d]# CD ~
[Email protected] ~]# pwd
/root
Example 4: Switch to the specified directory
[Email protected] ~]# pwd
/root
[Email protected] ~]# cd/etc/init.d/
[Email protected] init.d]# pwd
/etc/init.d
[Email protected] init.d]# cd/dev/
[Email protected] dev]# pwd
/dev
Example 5: Switch to a directory before switching
[Email protected] ~]# cd/etc/
[Email protected] etc]# pwd
/etc
[Email protected] etc]# cd/dev/
[Email protected] dev]# pwd
/dev
[Email protected] dev]# CD-
/etc
[Email protected] etc]# pwd
/etc
[Email protected] etc]# CD-
/dev
[Email protected] dev]# pwd
/dev
This article is from the "cold-blooded Killer" blog, please be sure to keep this source http://deathkiller.blog.51cto.com/9130248/1592320
CD of Common Linux commands