Transferred from: http://www.cnblogs.com/peida/archive/2012/10/24/2736501.html
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 Example: 3.1 Example one: Enter the system root directory
Command: CD/
Output: [[email protected] ~] #cd/
Description: 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:
1 pwd 2 /opt/soft3[[email protected] soft]# CD . 4 [[email protected] opt]# CD. // 5 pwd 6 /
Description: You can use the CD to enter the system root directory. Go back and you can reach the root directory.
Command: CD. /.. //
Output:
1 pwd 2 /opt/soft3//4pwd5 /6
Description: Use the CD command to enter the parent directory of the current directory's parent directory.
Example two: 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 ways to access the current user home directory:
Command 1:CD
Output:
1 pwd 2 /opt/soft3[[email protected] soft]# CD4pwd5 /root
Command 2:CD ~
Output:
1 [[email protected] ~]# cd/opt/soft/2pwd3 /opt/soft4 [[email] Protected] soft]# CD ~5pwd6 /root
Example three: Jump to the specified directory
Command: Cd/opt/soft
Output:
1 [[email protected] ~]# cd/opt/soft2pwd3 /opt/soft4 [Email protected] soft]# CD JDK1. 6. 0_16/5 [[email protected] jdk1. 6pwd6 /opt/soft/jdk1. 6 . 0_16 7 [[email protected] jdk1. 6. 0_16]#
Description: Jump to the specified directory, starting from the root directory, the directory name plus/, the current directory of subdirectories directly write the name.
Example four: Return to the directory in which it was before entering this directory
Command: CD-
Output:
1 pwd 2 /opt/soft3 [[email protected] soft]# CD-4 /root5pwd 6 /root7 [[email protected] ~]# CD-8 /opt/soft9 [[ Email protected] soft]#
Example five: Use the parameters of the previous command as CD parameters.
Command: CD!$
Output:
1 [[email protected] soft]# CD! $ 2 CD-3 /root4 [[email protected] ~]# CD! $ 5 CD-6 /opt/soft7 [[email protected] soft]#
One Linux command per day (2): CD