命令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
例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]#
说明:
跳转到指定目录,从根目录开始,目录名称前加 / ,当前目录内的子目录直接写名称即可
例四:返回进入此目录之前所在的目录
命令:
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]#
例五:把上个命令的参数作为cd参数使用。
命令:
cd !$
输出:
1 [root@localhost soft]# cd !$
2 cd -
3 /root
4 [root@localhost ~]# cd !$
5 cd -
6 /opt/soft
7 [root@localhost soft]#
上面就是Linux cd命令的介绍了,cd命令可以说是Linux使用率最高的两个命令之一,以后你在Linux的操作中会经常使用到它。