One Linux command per day-CD

Source: Internet
Author: User

The CD command in Linux, used to switch directories, is one of the most commonly used commands in Linux.

    1. Command function

      Switch the current directory to the specified directory

    2. Command format

      CD [Diretory]

    3. Common examples

      Example one: Go to/directory

      Command:

CD/

Output:

[[Email protected] ~]# CD/[[email protected]/]# Pwd/[[email protected]/]#

Use the PWD command to view the absolute path to the current directory.

Example two: Returns the current directory of the previous level of the directory, using: /.. The usage can be returned to the upper-level directory,. /.. /.., and so on.

Command:

Cd..

Output:

[Email protected] network-scripts]# Pwd/etc/sysconfig/network-scripts[[email protected] network-scripts]# CD. [Email protected] sysconfig]# Pwd/etc/sysconfig[[email protected] sysconfig]# CD. [[email protected] etc]# pwd/etc[[email protected] ~]# Cd/etc/sysconfig/network-scripts/[[email protected] network-scripts]# Pwd/etc/sysconfig/network-scripts[[email protected] network-scripts]# CD. /.. [Email protected] etc]# Pwd/etc[[email protected] etc]#

Example three: Go to your home directory

Command:

cd# not take any parameters by default returned to the user home directory CD ~# "~" indicates the user's home directory

Output:

[[email protected] network-scripts]# cd[[email protected] ~]# pwd/root[[email protected] ~]# cd/etc/sysconfig/ Network-scripts/[[email protected] network-scripts]# CD ~[[email protected] ~]# Pwd/root[[email protected] ~]#

Example four: Returning a directory before entering this directory

Command:

CD-

Output:

[[Email protected] network-scripts]# CD ~[[email protected] ~]# Pwd/root[[email protected] ~]# CD-/etc/sysconfig/network -scripts[[email protected] network-scripts]# Pwd/etc/sysconfig/network-scripts[[email protected] network-scripts]# CD-/root[[email protected] ~]#

Example five: Use the parameters of the previous command as CD parameters

Command:

CD!$

Output

[[email protected] ~]# Cd/etc/sysconfig/network-scripts/[[email protected] network-scripts]# CD-/root[[email Protected] ~]# CD-/etc/sysconfig/network-scripts[[email protected] network-scripts]# CD! $CD-/root[[email protected] ~ ]# CD! $CD-/etc/sysconfig/network-scripts[[email protected] network-scripts]#




One Linux command per day-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.