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:
[Root@localhost ~]# 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:
Cd.. or CD. //
Output:
Copy the Code code as follows:
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD.
[Root@localhost opt]# CD. //
[Root@localhost/]# pwd
/
Description
Enter the system root directory to use the CD. "Always back, you can reach the root directory
Command:
Cd.. /.. //
Output:
Copy the Code code as follows:
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD. /.. //
[Root@localhost/]# pwd
/
[Root@localhost/]#
Description: Use the CD command to implement the parent directory into the parent directory of the current 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:
Copy the Code code as follows:
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD
[Root@localhost ~]# pwd
/root
Command 2:
CD ~
Output:
Copy the Code code as follows:
[Root@localhost ~]# cd/opt/soft/
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD ~
[Root@localhost ~]# pwd
/root
Example 3: Jump to a specified directory
Command:
Cd/opt/soft
Output:
Copy the Code code as follows:
[Root@localhost ~]# Cd/opt/soft
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD jdk1.6.0_16/
[Root@localhost jdk1.6.0_16]# pwd
/opt/soft/jdk1.6.0_16
[Root@localhost jdk1.6.0_16]#
Description
Jump to the specified directory, starting from the root directory, the directory name plus/, the current directory in the subdirectory directly write the name can be
Example four: Return to the directory in which it was before entering this directory
Command:
CD-
Output:
Copy the Code code as follows:
[Root@localhost soft]# pwd
/opt/soft
[Root@localhost soft]# CD-
/root
[Root@localhost ~]# pwd
/root
[Root@localhost ~]# CD-
/opt/soft
[Root@localhost soft]#
Example five: Use the parameters of the previous command as CD parameters.
Command:
CD!$
Output:
Copy the Code code as follows:
[Root@localhost soft]# CD!$
CD-
/root
[Root@localhost ~]# CD!$
CD-
/opt/soft
[Root@localhost soft]#