加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux cd命令怎么使用?

发布时间:2023-05-19 13:27:01 所属栏目:Linux 来源:
导读: Linux cd命令用于切换当前工作目录至 dirName(目录参数)。其中 dirName 表示法可为绝对路径或相对路径。若目录名称省略,则变换至使用者的 home 目录 (也就是刚 login 时所在的目录)。另外,"~" 也表示为 home 目录
 Linux cd命令用于切换当前工作目录至 dirName(目录参数)。其中 dirName 表示法可为绝对路径或相对路径。若目录名称省略,则变换至使用者的 home 目录 (也就是刚 login 时所在的目录)。另外,"~" 也表示为 home 目录 的意思,"." 则是表示目前所在的目录,".." 则表示目前目录位置的上一层目录。

    一、Linux cd命令语法

cd [dirName]
    dirName:要切换的目标目录。

    二、Linux cd命令实例

    跳入test目录:

[root@/root/linuxdaxue.com]#cd testDir/
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
    跳至上层目录

[root@/root/linuxdaxue.com/testDir]#cd ..
[root@/root/linuxdaxue.com]#ls
testDir
    跳至上上层目录

[root@/root/linuxdaxue.com/testDir]#cd ../../
[root@/root]#ls
    跳入用户主目录

[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
[root@/root/linuxdaxue.com/testDir]#cd ~/
[root@/root]#pwd
/root
    使用绝对路径

[root@/root]#cd /root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
    使用环境变量

[root@/root]#cd $TEST_PATH
[root@/root/linuxdaxue.com/testDir]#ls
file1  file2  file3
    跳入上次使用目录

[root@/root]#pwd
/root
[root@/root]#cd -
/root/linuxdaxue.com/testDir
[root@/root/linuxdaxue.com/testDir]#
    cd命令比较简单,主要用来切换工作目录,希望大家能熟练掌握。

    以上就是linux下的cd命令的使用介绍啦,希望大家阅读完这篇文章能有所收获,如果还想要了解更多Linux下其他命令的使用,大家可以继续浏览相关的文章。

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章