Linux命令之---cd

命令简介

Linux cd 命令是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的。

命令格式

cd [目录名]

命令功能

切换当前目录至dirName

常用范例

例一:进入系统根目录

命令:cd / 

[root@king ~]# cd /   

说明:进入系统根目录,上面命令执行完后拿ls命令看一下,当前目录已经到系统根目录了 

命令:cd .. 或者 cd .. //

1 [root@king soft]# pwd
2 /opt/soft
3 [root@king soft]# cd ..
4 [root@king opt]# cd ..
5 [root@king /]# pwd
6 /   

说明:进入系统根目录可以使用“ cd .. 一直退,就可以到达根目录 

2:使用 cd 命令进入当前用户主目录

“当前用户主目录”和“系统根目录”是两个不同的概念。进入当前用户主目录有两个方法。

命令1:cd

1 [root@king soft]# pwd
2 /opt/soft
3 [root@king soft]# cd
4 [root@king ~]# pwd
5 /root

命令2cd ~

1   [root@king ~]# cd /opt/soft/
2   [root@king soft]# pwd
3   /opt/soft
4   [root@king soft]# cd ~
5   [root@king ~]# pwd
6   /root   
3:跳转到指定目录

命令: cd /opt/soft

1 [root@king ~]# cd /opt/soft
2 [root@king soft]# pwd
3 /opt/soft

说明:跳转到指定目录,从根目录开始,目录名称前加 / ,当前目录内的子目录直接写名称即可

例四:返回进入此目录之前所在的目录

命令:cd -

1 [root@king soft]# pwd
2 /opt/soft
3 [root@king soft]# cd -
4 /root
5 [root@king ~]# pwd
6 /root
7 [root@king ~]# cd -
8 /opt/soft
9 [root@king soft]# 
例五:把上个命令的参数作为cd参数使用

命令:cd !$

1 [root@king soft]# cd !$
2 cd -
3 /root
4 [root@king ~]# cd !$
5 cd -
6 /opt/soft
7 [root@king soft]# 

说明:相信大家看到这里都会感觉很绕,!$就是相当于上一条命令的参数,不过博客感觉这命令很弱鸡吧,

转载于:https://www.cnblogs.com/liang-io/p/9375941.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值