切换目录命令-cd
-
List item
cd命令用来切换工作目录,我们常见的使用方法有:
cd 绝对路径 cd /etc/hostname cd 相对路径 cd test/abc cd . cd ..
-
cd 切换目录
[root@oldboy ~]# cd /tmp [root@oldboy tmp]# pwd /tmp [root@oldboy tmp]# cd
-
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
-
cd ~ 切换回当前用户的家目录
注意:root和普通用户切回的家目录是不同的
[root@oldboy ~]# cd /tmp/ [root@oldboy tmp]# pwd /tmp [root@oldboy tmp]# cd ~ [root@oldboy ~]# pwd /root
-
cd . 代表当前目录,一般在拷贝、移动等情况下使用
[root@oldboy ~]# cd /tmp/ [root@oldboy tmp]# pwd /tmp [root@oldboy tmp]# cd . [root@oldboy tmp]# pwd /tmp
-
cd … 切换回当前目录的上级目录
[root@oldboy ~]# cd /tmp/ [root@oldboy tmp]# pwd /tmp [root@oldboy tmp]# cd .. [root@oldboy /]# pwd /