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

admin 2023年6月2日08:40:03评论39 views字数 1649阅读5分29秒阅读模式

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

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

示例:

1.

切换到指定目录:
cd directory/

这将进入名为 directory 的目录。

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

2.

返回上一级目录:
cd ..

这将返回当前目录的上一级目录。【Linux命令】每天一个Linux命令(2):cd命令

3.

返回到用户的主目录:
cd

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

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

4.

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

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

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

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

说明: 
cd 命令是一个基本的目录导航工具,用于在不同的目录之间进行切换。它是命令行界面中经常使用的命令之一。使用 cd 命令时,请确保提供正确的目录路径,以便切换到所需的目录。可以使用相对路径(相对于当前目录)或绝对路径(从根目录开始)来指定目录路径。
[root@iZb5dlyg1ebe6oZ ~]# cd --helpcd: cd [-L|[-P [-e]] [-@]] [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      -@        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.

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

原文始发于微信公众号(利刃信安攻防实验室):【Linux命令】每天一个Linux命令(2):cd命令

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年6月2日08:40:03
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【Linux命令】每天一个Linux命令(2):cd命令http://cn-sec.com/archives/1781132.html

发表评论

匿名网友 填写信息