Linux cd命令用于切换当前工作目录至目标目录。其中目标目录表示法可为绝对路径或相对路径,若目录名称省略,则变换至使用者的 home 目录。
另外,”~” 也表示为 home 目录的意思,”.” 则是表示当前所在的目录,”..” 则表示目前目录位置的上一层目录。
命令格式
| 1 | cd [dir](dir表示要切换的目录) | 
命令功能
切换当前目录至dir。
命令参数
暂无
使用示例
- cd / | cd //
| 1 | [root@hcdn-others-worker-dev100-bjlt local]# pwd | 
进入系统根目录
- cd ..
| 1 | [root@hcdn-others-worker-dev100-bjlt local]# pwd | 
切换到父目录
- cd -
| 1 | [root@hcdn-others-worker-dev100-bjlt local]# pwd | 
切换到上次使用的目录
- cd
| 1 | [root@hcdn-others-worker-dev100-bjlt local]# pwd | 
切换到当前用户主目录
- cd ~
| 1 | [root@hcdn-others-worker-dev100-bjlt ~]# cd /root/usr/local/ | 
切换到当前用户主目录
- cd /root/usr/local/
| 1 | [root@hcdn-others-worker-dev100-bjlt ~]# cd /root/usr/local/ | 
切换到指定目录
- cd !$
| 1 | [root@hcdn-others-worker-dev100-bjlt ~]# cd /root/usr/local/ | 
将上一命令得参数作为 cd 参数使用
Read More: