cd [目錄名]
切換當前目錄至 [目錄名]
命令:
cd /
說明:進入系統根目錄,上面命令執行完後拿ls命令看一下,當前目錄已經到系統根目錄了
輸出:
hc@hc-virtual-machine:~$ pwd
/home/hc
hc@hc-virtual-machine:~$ cd /
hc@hc-virtual-machine:/$ ls
bin dev initrd.img lib64 mnt root snap sys var
boot etc initrd.img.old lost+found opt run srv tmp vmlinuz
cdrom home lib media proc sbin swapfile usr
pwd的作用是查詢當前所在目錄
命令:
cd ..
輸出:
hc@hc-virtual-machine:~/pycharmprojects$ pwd
/home/hc/pycharmprojects
hc@hc-virtual-machine:~/pycharmprojects$ cd ..
hc@hc-virtual-machine:~$ pwd
/home/hc
命令:
cd ../..
輸出:
hc@hc-virtual-machine:~/pycharmprojects$ pwd
/home/hc/pycharmprojects
hc@hc-virtual-machine:~/pycharmprojects$ cd ../..
hc@hc-virtual-machine:/home$ pwd
/home
「當前使用者主目錄」和「系統根目錄」是兩個不同的概念。進入當前使用者主目錄有兩個方法。命令1:
cd
直接輸入cd,然後回車
輸出:
hc@hc-virtual-machine:~/pycharmprojects/my_test$ pwd
/home/hc/pycharmprojects/my_test
hc@hc-virtual-machine:~/pycharmprojects/my_test$ cd
hc@hc-virtual-machine:~$ pwd
/home/hc
上面的命令是我在非root使用者下操作的,現在我切換到root使用者下再操作一遍
hc@hc-virtual-machine:~/pycharmprojects/my_test$ sudo su
root@hc-virtual-machine:/home/hc/pycharmprojects/my_test# pwd
/home/hc/pycharmprojects/my_test
root@hc-virtual-machine:/home/hc/pycharmprojects/my_test# cd
root@hc-virtual-machine:~# pwd
/root
命令2:
cd ~
輸出
hc@hc-virtual-machine:~/pycharmprojects/my_test$ pwd
/home/hc/pycharmprojects/my_test
hc@hc-virtual-machine:~/pycharmprojects/my_test$ cd ~
hc@hc-virtual-machine:~$ pwd
/home/hc
命令
cd /home/hc/pycharmprojects/my_test/
輸出
hc@hc-virtual-machine:/$ pwd
/hc@hc-virtual-machine:/$ cd /home/hc/pycharmprojects/my_test/
hc@hc-virtual-machine:~/pycharmprojects/my_test$ pwd
/home/hc/pycharmprojects/my_test
命令:
cd -
說明:自動跳轉到進入此目錄之前所在的目錄,並輸出所在目錄名稱
輸出:
hc@hc-virtual-machine:/$ pwd
/hc@hc-virtual-machine:/$ cd /home/hc/pycharmprojects/my_test/
hc@hc-virtual-machine:~/pycharmprojects/my_test$ pwd
/home/hc/pycharmprojects/my_test
hc@hc-virtual-machine:~/pycharmprojects/my_test$ cd -
/hc@hc-virtual-machine:/$ pwd
/
命令:
cd !$
輸出:
hc@hc-virtual-machine:~/pycharmprojects/my_test$ pwd
/home/hc/pycharmprojects/my_test
hc@hc-virtual-machine:~/pycharmprojects/my_test$ ls /opt/
google
hc@hc-virtual-machine:~/pycharmprojects/my_test$ cd !$
cd /opt/
hc@hc-virtual-machine:/opt$ pwd
/opt
linux每日命令 2 cd命令
cd 目錄名 切換當前目錄至 目錄名 命令 cd 說明 進入系統根目錄,上面命令執行完後拿ls命令看一下,當前目錄已經到系統根目錄了 輸出 hc hc virtual machine pwd home hc hc hc virtual machine cd hc hc virtual machine...
linux基本命令(2) cd命令
cd命令是linux的最基本命令之一,其它命令的操作都是建立在cd命令之上的。要學習linux基本命令,首先要掌握cd命令的使用方法技巧。1 命令格式 cd 目錄名 2 命令功能 切換當前目錄至dirname 3 常用範例 3.1 例一 進入系統根目錄 命令 cd 說明 進入系統根目錄 上面命令執行...
linux系統命令詳解 2 cd命令
每天乙個linux命令 2 cd命令 linux cd 命令可以說是linux中最基本的命令語句,其他的命令語句要進行操作,都是建立在使用 cd 命令上的。所以,學習linux 常用命令,首先就要學好 cd 命令的使用方法技巧。1.命令格式 cd 目錄名 2.命令功能 切換當前目錄至dirname ...