One Linux command per day (2): cd command

Source: Internet
Author: User
Tags parent directory

1. Function

The CD command is used to switch the working directory to dirname. Where dirname notation can be either an absolute path or a relative path. If the directory name is omitted, it is transformed to the user's home directory (that is, the directory where login was first). In addition, the ~ is also expressed as the meaning of home directory, which is the current directory. Represents the previous level of directory at the current directory location.

2. Grammar
CD    (Options)   (parameters)
3. Options
-P  If the destination directory you want to switch to is a symbolic connection, switch directly to the destination directory that the symbolic connection is pointing to
  -L If the destination directory that you want to switch is a symbolic connection, switch directly to the directory that the character connection name represents, not the destination directory that the symbolic connection points to.
-   when only the "-" option is applied, the current working directory is switched to the directory represented by the environment variable "OLDPWD". Each time you change the directory, the Shell records the previous directory location in the environment variable OLDPWD
4, the instance CD enters the user main directory;
pwd/root
CD ~ Enter the user's home directory;
[[Email protected] ~]# CD ~pwd/~]#
CD-Returns the directory where the directory was before it entered;
pwd/~]# CD/-/pwd/root
CD: Returns the parent directory (if the current directory is "/", then "/"; "..." after execution) The meaning of the parent directory);
pwd/etc/pwd/etc
CD.. /.. Return to the top level two directory;
pwd/etc/init.d[[email protected] init.d]# CD . /pwd/
CD!$ Use the parameters of the previous command as CD parameters.
ls -ld /media/drwxr24096   /media/  /]# CD!  /media/pwd/media

One Linux command per day (2): 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.