????????Linux?cd?命令可以說是Linux中最基本的命令語句,其他的命令語句要進行操作,都是建立在使用?cd?命令上的。所以,學習Linux?常用命令,首先就要學好?cd?命令的使用方法技巧。
????1.?命令格式:
????????cd?[目錄名]
? ? 2.?命令功能:
????????切換當前目錄至dirName
? ? 3.?常用范例
????????3.1?例一:進入系統根目錄
????????????????命令:
????????????????cd?/?
????????????????輸出:
????????????????[root@localhost?~]#?cd?/???
????????????????說明:進入系統根目錄,上面命令執行完后拿ls命令看一下,當前目錄已經到系統根目錄了?
????????????例2:使用?cd?命令進入當前用戶家目錄
??????????????“當前用戶主目錄”和“系統根目錄”是兩個不同的概念。進入當前用戶主目錄有兩個方法。
????????????????命令1:
????????????????cd
????????????????輸出:
????????????????[root@localhost?soft]#?pwd
????????????????/opt/soft
????????????????[root@localhost?soft]#?cd
????????????????[root@localhost?~]#?pwd
?????????????????/root
????????????????命令2:
????????????????cd?~
????????????????輸出:
????????????????[root@localhost?~]#?cd?/opt/soft/
????????????????[root@localhost?soft]#?pwd
????????????????/opt/soft
????????????????[root@localhost?soft]#?cd?~
????????????????[root@localhost?~]#?pwd
????????????????/root? ?
????????????例3:使用?cd?命令進入當前目錄的上一個目錄
????????????????命令:
????????????????cd?..
????????????????輸出:
?????????????????[root@localhost?soft]#?pwd
????????????????/opt/soft
????????????????[root@localhost?soft]#?cd?..???????????????
?????????????????[root@localhost?/]#?pwd
????????????????/opt
?????????????例4:跳轉到指定目錄
????????????????命令:?
????????????????cd?/opt/soft
????????????????輸出:
????????????????[root@localhost?~]#?cd?/opt/soft
????????????????[root@localhost?soft]#?pwd
????????????????/opt/soft
????????????例5:返回進入此目錄之前所在的目錄
????????????????命令:
????????????????cd?-
????????????????輸出:
????????????????[root@localhost?soft]#?pwd
?????????????????/opt/soft
????????????????[root@localhost?soft]#?cd?-
????????????????/root
????????????????[root@localhost?~]#?pwd
?????????????????/root
?????????????????[root@localhost?~]#?cd?-
????????????????/opt/soft
?????????????????[root@localhost?soft]#?
?
轉載于:https://blog.51cto.com/xuelinux/1708487