How to use cd commands in a linux system
This article will explain in detail how to use the cd command in the linux system. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
1. Command format:
Cd [directory name]
two。 Command function:
Switch the current directory to dirName
3. Common examples
Case 1: enter the root directory of the system
Command:
Cd /
Output:
[root@localhost ~] # cd /
Description: enter the system root directory. After the above command is executed, take a look at the ls command. The current directory has already reached the system root directory.
Command:
Cd.. Or cd.. / /
Output:
The copy code is as follows:
[root@localhost soft] # pwd
/ opt/soft
[root@localhost soft] # cd..
[root@localhost opt] # cd.. / /
[root@localhost /] # pwd
/
Description:
If you enter the root directory of the system, you can use "cd.." to go straight back to the root directory.
Command:
Cd.. /.. / /
Output:
The copy code is as follows:
[root@localhost soft] # pwd
/ opt/soft
[root@localhost soft] # cd.. /.. / /
[root@localhost /] # pwd
/
[root@localhost /] #
Description: use the cd command to enter the parent directory of the current directory.
Example 2: use the cd command to enter the current user's home directory
The current user home directory and the system root directory are two different concepts. There are two ways to enter the current user's home directory.
Command 1:
Cd
Output:
The copy code is as follows:
[root@localhost soft] # pwd
/ opt/soft
[root@localhost soft] # cd
[root@localhost ~] # pwd
/ root
Command 2:
Cd ~
Output:
The copy code is 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 the specified directory
Command:
Cd / opt/soft
Output:
The copy code is 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 is preceded by /, and the subdirectories in the current directory can write the name directly.
Example 4: return to the directory where you were before you entered this directory
Command:
Cd-
Output:
The copy code is 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 5: use the parameter of the previous command as the cd parameter.
Command:
Cd! $
Output:
The copy code is as follows:
[root@localhost soft] # cd! $
Cd-
/ root
[root@localhost ~] # cd! $
Cd-
/ opt/soft
[root@localhost soft] #
On how to use the cd command in the linux system to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.