How to use the Linux cd command?

  
                

The most basic command in cd-command Linux commands is one of the most commonly used commands. When using Linux commands, almost all cd commands are used. Therefore, to learn Linux commands, cd commands must be mastered. Xiaobian together to learn more about the cd command.

1. Command Format:

cd [directory name]

2. Function:

change the current directory to dirName

3. Common Examples

3.1 Example 1: Entering the System Root

Command:

cd /

Output:

[root@localhost ~]# cd /

Description: Enter the system root directory. After the above command is executed, take the ls command to see that the current directory has reached the system root directory.


cd . . Or cd. . //

Output:

1 [root@localhost soft]# pwd

2 /opt/soft

3 [root@localhost soft]# Cd. .

4 [root@localhost opt]# cd . . //

5 [root@localhost /]# pwd

6 /

Description:

You can use “ cd to enter the system root directory. . ” Always retreat, you can reach the root directory

Command:

cd . . /. . //

Output:

1 [root@localhost soft]# pwd

2 /opt/soft

3 [root@localhost soft]# Cd. . /. . //

4 [root@localhost /]# pwd

5 /

6 [root@localhost /]#

Description: Use the cd command Implements the parent directory of the parent directory that goes into the current directory.

Example 2: Using the cd command to enter the current user home directory

“The current user home directory” and “system root directory” are two different concepts. There are two ways to enter the current user home directory.

Command 1:

cd

Output:

1 [root@localhost soft]# pwd

2 /opt/soft

3 [root@localhost soft]# cd

4 [root@localhost ~]# pwd

5 /root
Previous12Next 2 pages

Copyright © Windows knowledge All Rights Reserved