Home > Backend Development > PHP Tutorial > Detailed explanation of the use of cd command in linux, detailed explanation of the use of linuxcd_PHP tutorial

Detailed explanation of the use of cd command in linux, detailed explanation of the use of linuxcd_PHP tutorial

WBOY
Release: 2016-07-13 10:10:04
Original
1787 people have browsed it

Detailed explanation of how to use cd command in linux, detailed explanation of how to use linuxcd

The Linux cd command can be said to be the most basic command statement in Linux. Other command statements are based on the use of the cd command.
Therefore, to learn common Linux commands, you must first learn how to use the cd command.

1. Command format:
cd [directory name]

2. Command function:
Switch the current directory to dirName

3. Common examples

3.1 Example 1: Enter the system root directory
Command:
cd /
Output:
[root@localhost ~]# cd /
Note: Enter the system root directory. After executing the above command, use the ls command to see that the current directory has reached the system root directory
Command:
cd .. or cd .. //
Output:

Copy code The code is as follows:

[root@localhost soft]# pwd
/opt/soft
[root@localhost soft]# cd ..
[root@localhost opt]# cd ..//
[root@localhost /]# pwd
/

Description:
To enter the root directory of the system, you can use "cd .." to back out until you reach the root directory
Command:
cd ../.. //
Output:

Copy code The code is as follows:

[root@localhost soft]# pwd
/opt/soft
[root@localhost soft]# cd ../.. //
[root@localhost /]# pwd
/
[root@localhost /]#

Instructions: Use the cd command to enter the parent directory of the parent directory of the current directory.

Example 2: Use the cd command to enter the current user’s home directory
"Current user home directory" and "system root directory" are two different concepts. There are two ways to enter the current user's home directory.

Command 1:
cd
Output:

Copy code The code is as follows:

[root@localhost soft]# pwd
/opt/soft
[root@localhost soft]# cd
[root@localhost ~]# pwd
/root

Command 2:
cd ~
Output:

Copy code The 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:

Copy code The 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, add / before the directory name, and just write the name of the subdirectory in the current directory

Example 4: Return to the directory you were in before entering this directory
Command:
cd -
Output:

Copy code The 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 parameters of the previous command as cd parameters.

Command:
cd !$
Output:

Copy code The code is as follows:

[root@localhost soft]# cd !$
cd -
/root
[root@localhost ~]# cd !$
cd -
/opt/soft
[root@localhost soft]#

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/939399.htmlTechArticleDetailed explanation of the use of the cd command in Linux, detailed explanation of the use of linuxcd The Linux cd command can be said to be the most basic command statement in Linux. Other command statements are based on using the cd command...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template