每天一个Linux命令(2):cd命令
来源:互联网 发布:js二维数组添加新元素 编辑:程序博客网 时间:2024/05/21 17:16
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的。所以,学习Linux
常用命令,首先就要学好 cd 命令的使用方法技巧。
1. 命令格式:
cd [目录名]
2. 命令功能:
切换当前目录至dirName
3. 常用范例
例一:进入系统根目录
命令:
cd /
说明:进入系统根目录,上面命令执行完后拿ls命令看一下,当前目录已经到系统根目录了
命令:
cd .. 或者 cd .. //
输出:
[root@localhost soft]# pwd/opt/soft[root@localhost soft]# cd ..[root@localhost opt]# cd ..//[root@localhost /]# pwd/
说明:
进入系统根目录可以使用“ cd .. ”一直退,就可以到达根目录
命令:
cd ../.. //
输出:
[root@server-xiaoxiang zabbix]# pwd/etc/zabbix[root@server-xiaoxiang zabbix]# cd ../..//[root@server-xiaoxiang /]# pwd/[root@server-xiaoxiang /]#
说明:使用cd 命令实现进入当前目录的父目录的父目录。
例2:使用 cd 命令进入当前用户主目录
“当前用户主目录”和“系统根目录”是两个不同的概念。进入当前用户主目录有两个方法。
命令1:
cd
输出:
[root@server-xiaoxiang zabbix]# pwd/etc/zabbix[root@server-xiaoxiang zabbix]# cd[root@server-xiaoxiang ~]# pwd/root[root@server-xiaoxiang ~]#
命令2:
cd ~
输出:
[root@server-xiaoxiang ~]# cd /etc/zabbix/[root@server-xiaoxiang zabbix]# pwd/etc/zabbix[root@server-xiaoxiang zabbix]# cd ~[root@server-xiaoxiang ~]# pwd/root[root@server-xiaoxiang ~]#
例3:跳转到指定目录
命令:
cd /etc/sysconfig
输出:
[root@server-xiaoxiang ~]# pwd/root[root@server-xiaoxiang ~]# cd /etc/sysconfig/[root@server-xiaoxiang sysconfig]# pwd/etc/sysconfig[root@server-xiaoxiang sysconfig]#
说明:
跳转到指定目录,从根目录开始,目录名称前加 / ,当前目录内的子目录直接写名称即可
例四:返回进入此目录之前所在的目录
命令:
cd –
输出:
[root@server-xiaoxiang sysconfig]# pwd/etc/sysconfig[root@server-xiaoxiang sysconfig]# cd -/root[root@server-xiaoxiang ~]# pwd/root[root@server-xiaoxiang ~]# cd -/etc/sysconfig[root@server-xiaoxiang sysconfig]# pwd/etc/sysconfig[root@server-xiaoxiang sysconfig]#
例五:把上个命令的参数作为cd参数使用。
命令:
cd !$
输出:
[root@server-xiaoxiang ~]# cd -/root[root@server-xiaoxiang ~]# cd !$cd -/root[root@server-xiaoxiang ~]#
0 0
- 每天一个linux命令(2)--cd
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- 每天一个linux命令(2):cd命令
- php类文件的自动加载机制
- C 的__VAR_ARGS__宏
- Java学习笔记1
- OpenGL ES简单讲解
- Linux内核复习
- 每天一个Linux命令(2):cd命令
- caffe在ubuntu16.04下的安装
- Android屏幕适配方案
- linux基本命令
- 安装配置解压版Mysql方法
- 《从零开始写JavaWeb框架》(4-5章)学到的东西
- 《逗鸟外传》
- dpkg、rpm 和 apt-get、yum 的区别
- [BZOJ3940][Usaco2015 Feb]Censoring(AC自动机+栈)