2.7 cd命令

cd 等於change directorycode

cd命令
    - 參數,"cd -"進入上一次所在目錄
    只輸入"cd",進入用戶當前home目錄下,也就是登錄系統時用戶的家目錄
    ~ 參數,"cd ~"表示切換到用戶home目錄,等於cd命令
    .. 參數,"cd .."表示切換到上層目錄,逐級返回

cd -

cd -命令,就表示你上一次所在的目錄在哪裏ip

[root@hf-01 ~]# cd /etc/sysconfig
[root@hf-01 sysconfig]# cd -
/root
[root@hf-01 ~]# cd -
/etc/sysconfig
[root@hf-01 sysconfig]# pwd
/etc/sysconfig
[root@hf-01 sysconfig]# cd -
/root
[root@hf-01 ~]# pwd
/root
[root@hf-01 ~]# cd -
/etc/sysconfig
[root@hf-01 sysconfig]# pwd
/etc/sysconfig

cd和cd ~

cd和cd ~命令,都是返回用戶的家目錄network

[root@hf-01 sysconfig]# cd
[root@hf-01 ~]# cd /tmp/
[root@hf-01 tmp]# cd
[root@hf-01 ~]# pwd
/root
[root@hf-01 ~]# cd ~	這個~則表示/root

cd ..

cd .. 命令,表示返回到上層目錄di

[root@hf-01 ~]# cd ..		返回的是根目錄,到達根目錄則沒法返回了
[root@hf-01 /]# cd ..		
[root@hf-01 /]# cd /etc/sysconfig/network-scripts/
[root@hf-01 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@hf-01 network-scripts]# cd ..
[root@hf-01 sysconfig]# pwd
/etc/sysconfig
[root@hf-01 sysconfig]# cd ..		這裏會看見逐級返回上層目錄
[root@hf-01 etc]# pwd
/etc
[root@hf-01 etc]# cd ..
[root@hf-01 /]# pwd
/

當想查看cd的其餘用法,能夠man cd 查看全部cd的用法co

相關文章
相關標籤/搜索