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.
1. Usage:
CD (options) [contents]
2. Function:
Toggle current directory to DirnamE
3. Options:
(1)-p If the destination directory to switch to is a symbolic connection, switch directly to the destination directory to which the symbolic connection is directed
(2)-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 to which the symbolic connection is pointing.
(3)-When only the "-" option is applied, the current working directory will be switched to the directory represented by the environment variable "OLDPWD".
4. Example:
(1) CD into the user's home directory, CD ~ Enter the user's home directory;
[[Email protected] ~]$ CD// * Just open terminal terminal, is the user's home directory */ * "CD/" intothe root directory *//]$ CD ~]$/ * The default home directory is this "~" */
[[Email protected] ~]$ CD// * "CD" Command and "CD ~" can achieve the same function*//]$ CD ~
(2) CD-Returns the directory in which it was located before entering this directory;
[Email protected]/]$ cd/home/Sunjimeng/* from the root directory into the user directory */[[email protected]~]$ ll//list directories and files under User directory total0drwxr-xr-x.2Sunjimeng Sunjimeng6May1 on: atDESKTOPDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atDOCUMENTSDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atDOWNLOADSDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atMUSICDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atPICTURESDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atPUBLICDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atTEMPLATESDRWXR-xr-x.2Sunjimeng Sunjimeng6May1 on: atVideos[[email protected]~]$ CD Desktop//Choose to go to the Desktop folder [[email protected] desktop]$ CD-//"CD-" Command function: (1) The name of the directory before the output and (2) return to the previous directory. /home/sunjimeng
(3) CD. Return to the parent directory (if the current directory is "/", then "/"; "..." after execution) For the meaning of the parent directory); CD. /.. Return to the top level two directory;
[Email protected]/]$ CD . /]$ cd/home/sunjimeng/Desktop //Enter your custom folder [[email protected] desktop]$ CD . ~]$ CD. /.. /]$
(4) CD!$ Use the parameters of the previous command as CD parameters.
[[email protected] ~]$ cd/home/sunjimeng/Desktop ! $ /home/sunjimeng/
~]$ CD! $CD: [Email protected] home]$
One Linux command per day (2) CD command