Linux cd command usage details, linuxcd usage details _ PHP Tutorial

Source: Internet
Author: User
Linux cd command usage details, linuxcd usage details. In linux, the cd command is explained in detail. the cd command is the most basic command statement in Linux, and other command statements need to be operated, are built on the use of cd commands linux cd command usage details, linuxcd use details

The Linux cd command is the most basic command statement in Linux. other command statements are created on the cd command.
Therefore, to learn common Linux commands, you must first learn how to use cd commands.

1. command format:
Cd [directory name]

2. command functions:
Switch the current directory to dirName

3. Common examples

Example 1: enter the system root directory
Command:
Cd/
Output:
[Root @ localhost ~] # Cd/
Note: go to the system root directory. Take a look at the ls command after the above command is executed. the current directory is already in the system root directory.
Command:
Cd... or cd ..//
Output:

The code is as follows:


[Root @ localhost soft] # pwd
/Opt/soft
[Root @ localhost soft] # cd ..
[Root @ localhost opt] # cd ..//
[Root @ localhost/] # pwd
/

Note:
To enter the root directory of the system, you can use "cd .." to continue to return to the root directory.
Command:
Cd ../..//
Output:

The code is as follows:


[Root @ localhost soft] # pwd
/Opt/soft
[Root @ localhost soft] # cd ../..//
[Root @ localhost/] # pwd
/
[Root @ localhost/] #

Note: run the cd command to access the parent directory of the current directory.

Example 2: run the cd command to enter the home directory of the current user.
"Current User home directory" and "system root directory" are two different concepts. There are two methods to enter the current user's home directory.

Command 1:
Cd
Output:

The code is as follows:


[Root @ localhost soft] # pwd
/Opt/soft
[Root @ localhost soft] # cd
[Root @ localhost ~] # Pwd
/Root

Command 2:
Cd ~
Output:

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:

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] #

Note:
Jump to the specified directory, starting from the root directory, and add/before the directory name. you can directly write the name of the subdirectory in the current directory.

Example 4: return the directory before entering this directory
Command:
Cd-
Output:

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 the cd parameter.

Command:
Cd! $
Output:

The code is as follows:


[Root @ localhost soft] # cd! $
Cd-
/Root
[Root @ localhost ~] # Cd! $
Cd-
/Opt/soft
[Root @ localhost soft] #

The cd command in customized Linux can be said to be the most basic command statement in Linux. other command statements must be operated using the cd command...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.