Linux Basics Command (2) CD command

Source: Internet
Author: User
Tags parent directory root directory

Linux CD commands can be said to be the most basic Linux command statements, other command statements to operate, are based on the use of the CD command.

So, learn Linux commonly used commands, first of all, learn how to use the CD command techniques.

1. Command format:

CD [Directory name]

2. Command function:

Toggle current directory to DirName

3. Common examples

3.1 Example One: Enter the system root directory

Command:

CD/

Output:

[Root@localhost ~]# CD/

Description: Enter the system root directory, the above command to take the LS command to look at the current directory has been to the system root directory

Command:

Cd.. or CD. //

Output:

[Root@localhost soft]# 

pwd   
 /opt/soft   
 [root@localhost soft]# CD.   
 [Root@localhost opt]# CD ...   
 [root@localhost/]# pwd   
 /

Description

Enter the system root directory to use the CD. "Go straight back and you can get to the root directory

Command:

Cd.. /.. //

Output:


[Root@localhost soft]# pwd   
 /opt/soft   
 [root@localhost soft]# CD. /..   
 [root@localhost/]# pwd   
 /   
 [root@localhost/]#

Description: Uses the CD command to implement a parent directory that enters the current directory.

Example 2: Use the CD command to enter the current user home directory

"Current User home Directory" and "system root" are two different concepts. There are two ways to enter the current user home directory.

Command 1:

Cd

Output:

[Root@localhost soft]# 

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

Command 2:

CD ~

Output:

[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:

[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

Jumps to the specified directory, starting with the root directory name plus/, the subdirectory in the current directory directly write the name

Example four: Return to the directory before entering this directory

Command:

CD-

Output:

[Root@localhost soft]# pwd   
 /opt/soft   
 [root@localhost soft]# CD-   
 /root   
 [root@localhost ~]# pwd   
 / Root   
 [root@localhost ~]# CD-   
 /opt/soft   
 [root@localhost soft]#

Example five: Use the parameters of the previous command as a CD parameter.

Command:

CD!$

Output:

[Root@localhost soft]# 

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

View a full set of articles: Http://www.bianceng.cn/OS/Linux/201301/35075.htm

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.