一个简单的linux命令——cd

一个简单的linux命令——cd

cd可以算是linux中最基本而且最简单的命令。
主要用于跳转目录

常用范例:

1.例一:进入系统根目录

命令:
cd / 
输出:
[root@localhost ~]# cd /   
说明:进入系统根目录,上面命令执行完后拿ls命令看一下,当前目录已经到系统根目录了 

2.进入上级目录

命令:
cd .. 或者 cd .. //
输出:
[root@localhost soft]# pwd
/opt/soft
[root@localhost soft]# cd ..
[root@localhost opt]# cd ..//
[root@localhost /]# pwd
/ 

3.进入当前用户主目录

命令1:
cd
输出:
1 [root@localhost soft]# pwd
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       

4.跳转到指定目录

命令: 
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]# 

5.跳转到之前所在的目录

命令:
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]# 

6.把上个命令的参数作为cd参数使用

命令:
cd !$
输出:
1 [root@localhost soft]# cd !$
2 cd -
3 /root
4 [root@localhost ~]# cd !$
5 cd -
6 /opt/soft
7 [root@localhost soft]# 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值