Introduction to the CD command
The CD command can be said to be the most basic command in Linux, 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.
command Format
CD [DirName]
Command Function
Toggle current directory to DirName
Common examples
Example 1: Entering the system root directory
Command:
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
Command:
//
Output :
[Email protected] soft]# pwd
/opt/soft
[Email protected] soft]# CD.
[Email protected] opt]# CD. //
[Email protected]/]# pwd
Description:
Enter the system root directory to use the CD. "Always go back and you can reach the 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: Jump to a specified directory
Command: Cd/opt/soft
Output:
[Email protected] ~]# Cd/opt/soft
[Email protected] soft]# pwd
/opt/soft
[Email protected] soft]# CD jdk1.6.0_16/
[Email protected] jdk1.6.0_16]# pwd
/opt/soft/jdk1.6.0_16
[Email protected] jdk1.6.0_16]#
Description
jump to the specified directory, starting with the root directory, the directory name Plus/, the subdirectory in the current directory directly write the name.
Example 4: Return to the directory where it was before entering this directory
Command: CD-
Output:
/opt/soft
/root
/root
/opt/soft
Example 5: Use the parameters of the previous command as CD parameters.
Command: CD!$
Output:
[Email protected] soft]# CD!$
CD-
/root
[Email protected] ~]# CD!$
CD-
/opt/soft
[Email protected] soft]#
Linux Common Commands 2:cd