cd命令--linux
来源:互联网 发布:photozoom pro mac 编辑:程序博客网 时间:2024/06/05 03:33
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的。
所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧。
1. 命令格式:
cd [目录名]
2. 命令功能:
切换当前目录至dirName
3. 常用范例
3.1 例一:进入系统根目录
命令:
cd /
输出:
[root@localhost ~]# cd /
说明:进入系统根目录,上面命令执行完后拿ls命令看一下,当前目录已经到系统根目录了
命令:
cd .. 或者 cd .. //
输出:
1 [root@localhost soft]# pwd
2 /opt/soft
3 [root@localhost soft]# cd ..
4 [root@localhost opt]# cd ..//
5 [root@localhost /]# pwd
6 /
2 /opt/soft
3 [root@localhost soft]# cd ..
4 [root@localhost opt]# cd ..//
5 [root@localhost /]# pwd
6 /
说明:
进入系统根目录可以使用“ cd .. ”一直退,就可以到达根目录
命令:
cd ../.. //
输出:
1 [root@localhost soft]# pwd
2 /opt/soft
3 [root@localhost soft]# cd ../.. //
4 [root@localhost /]# pwd
5 /
6 [root@localhost /]#
2 /opt/soft
3 [root@localhost soft]# cd ../.. //
4 [root@localhost /]# pwd
5 /
6 [root@localhost /]#
说明:使用cd 命令实现进入当前目录的父目录的父目录。
例2:使用 cd 命令进入当前用户主目录
“当前用户主目录”和“系统根目录”是两个不同的概念。进入当前用户主目录有两个方法。
命令1:
cd
输出:
1 [root@localhost soft]# pwd
2 /opt/soft
3 [root@localhost soft]# cd
4 [root@localhost ~]# pwd
5 /root
2 /opt/soft
3 [root@localhost soft]# cd
4 [root@localhost ~]# pwd
5 /root
命令2:
cd ~
输出:
1 [root@localhost ~]# cd /opt/soft/
2 [root@localhost soft]# pwd
3 /opt/soft
4 [root@localhost soft]# cd ~
5 [root@localhost ~]# pwd
6 /root
2 [root@localhost soft]# pwd
3 /opt/soft
4 [root@localhost soft]# cd ~
5 [root@localhost ~]# pwd
6 /root
例3:跳转到指定目录
命令:
cd /opt/soft
输出:
1 [root@localhost ~]# cd /opt/soft
2 [root@localhost soft]# pwd
3 /opt/soft
4 [root@localhost soft]# cd jdk1.6.0_16/
5 [root@localhost jdk1.6.0_16]# pwd
6 /opt/soft/jdk1.6.0_16
7 [root@localhost jdk1.6.0_16]#
2 [root@localhost soft]# pwd
3 /opt/soft
4 [root@localhost soft]# cd jdk1.6.0_16/
5 [root@localhost jdk1.6.0_16]# pwd
6 /opt/soft/jdk1.6.0_16
7 [root@localhost jdk1.6.0_16]#
说明:
跳转到指定目录,从根目录开始,目录名称前加 / ,当前目录内的子目录直接写名称即可
例四:返回进入此目录之前所在的目录
命令:
cd -
输出:
1 [root@localhost soft]# pwd
2 /opt/soft
3 [root@localhost soft]# cd -
4 /root
5 [root@localhost ~]# pwd
6 /root
7 [root@localhost ~]# cd -
8 /opt/soft
9 [root@localhost soft]#
2 /opt/soft
3 [root@localhost soft]# cd -
4 /root
5 [root@localhost ~]# pwd
6 /root
7 [root@localhost ~]# cd -
8 /opt/soft
9 [root@localhost soft]#
例五:把上个命令的参数作为cd参数使用。
命令:
cd !$
输出:
1 [root@localhost soft]# cd !$
2 cd -
3 /root
4 [root@localhost ~]# cd !$
5 cd -
6 /opt/soft
7 [root@localhost soft]#
2 cd -
3 /root
4 [root@localhost ~]# cd !$
5 cd -
6 /opt/soft
7 [root@localhost soft]#
0 0
- 【linux命令】cd命令
- linux命令:cd命令
- linux命令:cd命令
- linux 命令 cd
- Linux cd 命令
- linux cd命令介绍
- linux cd 命令
- Linux 命令之 cd
- linux中cd ~命令
- linux命令:cd
- linux cd 命令
- Linux cd命令
- Linux 学习 CD命令
- Linux cd 命令
- cd命令--linux
- linux命令-cd
- Linux常用命令:cd命令
- linux命令:cd ~/..ssh/
- 树的相关术语
- JAAVA 带包编译
- 程序员为什么要当项目经理
- 【HNOI2010】【BZOJ2000】stone 取石头游戏
- C++容易被忽略的法则
- cd命令--linux
- Oracle保存中文数据和读取数据页面显示乱码解决方案
- 记一次更换域名ip遇到的坑
- [翻译]android中如何使得ListView滑动流畅
- PCIe 复位:Clod reset、warm reset、Hot reset、Function level reset
- 开源Java论坛
- 动态规划简介
- 每日总结之Adapter的缓存机制
- C语言判断给定的字符串是否为合法的ip地址