【Linux命令】每天一个Linux命令(2):cd命令
2023-6-2 00:3:36 Author: 利刃信安攻防实验室(查看原文) 阅读量:12 收藏

每天一个Linux命令(2):cd命令

命令:
cd
描述:cd(change directory)用于更改当前工作目录。它允许用户在不同的目录之间切换,进入指定的目录。
语法:
cd [目录路径]

示例:

1.

切换到指定目录:
cd directory/

这将进入名为 directory 的目录。

2.

返回上一级目录:
cd ..

这将返回当前目录的上一级目录。

3.

返回到用户的主目录:
cd

这将返回用户的主目录,通常是 /home/username。

4.

切换到根目录:
cd /
这将切换到根目录 /。

5.
切换到上次访问的目录:
cd -
这将切换到上次访问的目录,可以在不同目录之间进行快速切换。

说明: 
cd 命令是一个基本的目录导航工具,用于在不同的目录之间进行切换。它是命令行界面中经常使用的命令之一。使用 cd 命令时,请确保提供正确的目录路径,以便切换到所需的目录。可以使用相对路径(相对于当前目录)或绝对路径(从根目录开始)来指定目录路径。
[[email protected] ~]# cd --helpcd: cd [-L|[-P [-e]] [[email protected]]] [dir]    Change the shell working directory.        Change the current directory to DIR.  The default DIR is the value of the    HOME shell variable.        The variable CDPATH defines the search path for the directory containing    DIR.  Alternative directory names in CDPATH are separated by a colon (:).    A null directory name is the same as the current directory.  If DIR begins    with a slash (/), then CDPATH is not used.        If the directory is not found, and the shell option `cdable_vars' is set,    the word is assumed to be  a variable name.  If that variable has a value,    its value is used for DIR.        Options:      -L        force symbolic links to be followed: resolve symbolic                links in DIR after processing instances of `..'      -P        use the physical directory structure without following                symbolic links: resolve symbolic links in DIR before                processing instances of `..'      -e        if the -P option is supplied, and the current working                directory cannot be determined successfully, exit with                a non-zero status      [email protected]        on systems that support it, present a file with extended                attributes as a directory containing the file attributes        The default is to follow symbolic links, as if `-L' were specified.    `..' is processed by removing the immediately previous pathname component    back to a slash or the beginning of DIR.        Exit Status:    Returns 0 if the directory is changed, and if $PWD is set successfully when    -P is used; non-zero otherwise.


文章来源: http://mp.weixin.qq.com/s?__biz=MzU1Mjk3MDY1OA==&mid=2247504361&idx=2&sn=9d98ee4101ea5b792b210d1f655e0d35&chksm=fbfb6124cc8ce832c65534f38d149195cbd427cada0e013b53ff1416b682dfe027e8fb0b25c6#rd
如有侵权请联系:admin#unsafe.sh