Linux CD commands can be said to be the most basic Linux command statements, the other command statements to operate, are based on the use of the CD command. Therefore, to learn the common Linux commands, the first step is to learn how to use the CD command skills.
1. Command format:
CD [Directory name]
2. Command function:
Toggle current directory to DirName
3. Common examples
3.1 Example One: Enter the system root directory
Command:
CD/
Output:
[[email protected] ~]# CD/
Note: Enter the system root directory, the above command after the execution of the LS command to see, the current directory has been to the system root directory
Example 2: Using the CD command to enter the current user home directory
The "Current User home Directory" and "system root" are two different concepts. There are two methods to enter the current user home directory.
Command 1:
Cd
Output:
[Email protected] soft]# pwd
/opt/soft
[[Email protected] soft]# CD
[Email protected] ~]# pwd
/root
Command 2:
CD ~
Output:
[Email protected] ~]# cd/opt/soft/
[Email protected] soft]# pwd
/opt/soft
[Email protected] soft]# CD ~
[Email protected] ~]# pwd
/root
Example 3: Using the CD command to enter the previous directory in the current directory
Command:
Cd..
Output:
[Email protected] soft]# pwd
/opt/soft
[Email protected] soft]# CD.
[Email protected]/]# pwd
/opt
Example 4: Jump to a specified directory
Command:
Cd/opt/soft
Output:
[Email protected] ~]# Cd/opt/soft
[Email protected] soft]# pwd
/opt/soft
Example 5: Return to the directory where it was before entering this directory
Command:
CD-
Output:
[Email protected] soft]# pwd
/opt/soft
[Email protected] soft]# CD-
/root
[Email protected] ~]# pwd
/root
[Email protected] ~]# CD-
/opt/soft
[Email protected] soft]#
This article is from the "Linux Personal Summary" blog, please be sure to keep this source http://xuelinux.blog.51cto.com/9927651/1708487
Linux Learning one command a day (2) [CD command]