阿Q的Linux运维学习之路(day5-3)-切换目录命令-cd

切换目录命令-cd
  1. List item

    cd命令用来切换工作目录,我们常见的使用方法有:

    cd 绝对路径 cd /etc/hostname
    cd 相对路径 cd test/abc cd . cd ..
    
  2. cd 切换目录

    [root@oldboy ~]# cd /tmp
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd
    
  3. cd - 切换回上一次所在的目录

    [root@oldboy ~]# cd /tmp/
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd
    [root@oldboy ~]# pwd
    /root
    
    [root@oldboy ~]# cd -
    /tmp
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd -
    /root
    
  4. cd ~ 切换回当前用户的家目录

    注意:root和普通用户切回的家目录是不同的

    [root@oldboy ~]# cd /tmp/
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd ~
    [root@oldboy ~]# pwd
    /root
    
  5. cd . 代表当前目录,一般在拷贝、移动等情况下使用

    [root@oldboy ~]# cd /tmp/
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd .
    [root@oldboy tmp]# pwd
    /tmp
    
  6. cd … 切换回当前目录的上级目录

    [root@oldboy ~]# cd /tmp/
    [root@oldboy tmp]# pwd
    /tmp
    [root@oldboy tmp]# cd ..
    [root@oldboy /]# pwd
    /
    
发布了38 篇原创文章 · 获赞 0 · 访问量 609

猜你喜欢

转载自blog.csdn.net/qq_39095114/article/details/104657749
今日推荐