您的位置:首页 > 运维架构 > Linux

深入解析Linux 常用命令--cd

2017-12-20 20:17 447 查看

深入解析Linux常用命令–cd

1.概述

cd常用于切换目录,改变目录(change directory)

2.切换目录

cd [Directory] , [Directory] 可以 为任意存在的目录。

[root@smart Desktop]# pwd
/root/Desktop
[root@smart Desktop]# cd /
[root@smart /]# pwd
/
[root@smart /]# cd /home/
[root@smart home]# pwd
/home


3.切换到上一次目录

cd -

[root@smart /]# cd /opt/rh/
[root@smart rh]# pwd
/opt/rh
[root@smart rh]# cd /home
[root@smart home]# cd -
/opt/rh


4.返回上级目录

cd .. 切换到上级目录

cd ../.. 切换到上级目录的上级目录

[root@smart rh]# pwd
/opt/rh
[root@smart rh]# cd ..
[root@smart opt]# pwd
/opt


5.切换到子目录

cd [子目录名]

[root@smart home]# pwd
/home
[root@smart home]# ls
smart  software  workspace
[root@smart home]# cd smart/
[root@smart smart]# pwd
/home/smart


6.切换到当前用户主目录

cd 默认情况下,cd后不接任何路径,将会切换到用户主目录

cd ~

[root@smart smart]# cd /
[root@smart /]# cd
[root@smart ~]# pwd
/root
[root@smart ~]# cd /
[root@smart /]# cd ~
[root@smart ~]# pwd
/root


Enjoy!

2017/12/24
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux