One day a linux Base command Directory Management Class command CD

Source: Internet
Author: User
Tags parent directory

CD Switch Directory command

1. Command format

CD [option] [directory name]

2. Command function

Switch working directory

3. Common examples

Example 1:CD ~

Description: ~ default is the home directory of the root, if the ~ after the user name, you can enter the home directory of the specified user

[Email protected] ~]#

[[Email protected] ~]# CD/

[Email protected]/]# pwd

/

Note: Enter the system root directory, the above command after the implementation of the PWD command to see, the current directory has been to the system root directory .

[Email protected]/]# CD ~

[Email protected] ~]# pwd

/root

Description: Use the CD command to access the home directory of the root user.

[Email protected] ~]# CD ~STU1

[Email protected] stu1]# pwd

/home/stu1

Description: Use the CD command to access the home directory of the normal user stu1.

Example 2: Jump to the specified directory Cd/var/log

[Email protected] stu1]# cd/var/log/

[Email protected] log]# pwd

/var/log

[[email protected] log]# ls

[Email protected] log]# CD httpd

[Email protected] httpd]# pwd

/var/log/httpd

[Email protected] httpd]#

description : Jump to the specified directory, starting from the root directory name plus/, the current directory of subdirectories directly write the name; relative path: The path starting at the current position

Example 3 : CD- : Returns the directory where it was before entering this directory

[Email protected] httpd]# cd/usr/share/yum-

[Email protected] httpd]# cd/usr/share/yum-plugins/

[Email protected] yum-plugins]# CD-

/var/log/httpd

[Email protected] httpd]# CD-

/usr/share/yum-plugins

[Email protected] yum-plugins]#

Example 4: use cd!$ The parameters of the previous command as CD parameters

[Email protected] ~]# ls/var/log/

Anaconda.ifcfg.log btmp DMESG maillog-20161129 PPP Spice-vdagent.log

[Email protected] ~]# CD!$

cd/var/log/

[Email protected] log]# pwd

/var/log

[Email protected] log]#

Example 5: Return to the parent directory CD of the current directory.

[Email protected] log]# pwd

/var/log

[Email protected] log]# CD.

[Email protected] var]# pwd

/var

[Email protected] var]#


This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1879772

One day a linux Base command Directory Management Class command CD

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.