linux命令:cd命令學習與使用,linux命令cd學習

來源:互聯網
上載者:User

linux命令:cd命令學習與使用,linux命令cd學習

Linux cd命令可以說是Linux中最基本的命令語句,其他的命令語句要進行操作,都是建立在使用cd命令上的。

所以,學習Linux常用命令,首先就要學好cd命令的使用方法技巧。

1.命令格式:

cd[目錄名]

2.命令功能:

切換目前的目錄至dirName

3.常用範例

3.1例一:進入系統根目錄

命令:

cd/

輸出:

[root@localhost~]#cd/

說明:進入系統根目錄,上面命令執行完後拿ls命令看一下,目前的目錄已經到系統根目錄了

命令:

cd..或者cd..//

輸出:

1[root@localhostsoft]#pwd

2/opt/soft

3[root@localhostsoft]#cd..

4[root@localhostopt]#cd..//

5[root@localhost/]#pwd

6/

說明:

進入系統根目錄可以使用“cd..”一直退,就可以到達根目錄

命令:

cd../..//

輸出:

1[root@localhostsoft]#pwd

2/opt/soft

3[root@localhostsoft]#cd../..//

4[root@localhost/]#pwd

5/

6[root@localhost/]#

說明:使用cd命令實現進入目前的目錄的父目錄的父目錄。

例2:使用cd命令進入目前使用者主目錄

“目前使用者主目錄”和“系統根目錄”是兩個不同的概念。進入目前使用者主目錄有兩個方法。

命令1:

cd

輸出:

1[root@localhostsoft]#pwd

2/opt/soft

3[root@localhostsoft]#cd

4[root@localhost~]#pwd

5/root

命令2:

cd~

輸出:

1  [root@localhost~]#cd/opt/soft/

2  [root@localhostsoft]#pwd

3  /opt/soft

4  [root@localhostsoft]#cd~

5  [root@localhost~]#pwd

6  /root

例3:跳轉到指定目錄

命令:

cd/opt/soft

輸出:

1[root@localhost~]#cd/opt/soft

2[root@localhostsoft]#pwd

3/opt/soft

4[root@localhostsoft]#cdjdk1.6.0_16/

5[root@localhostjdk1.6.0_16]#pwd

6/opt/soft/jdk1.6.0_16

7[root@localhostjdk1.6.0_16]#

說明:

跳轉到指定目錄,從根目錄開始,目錄名稱前加/,目前的目錄內的子目錄直接寫名稱即可

例四:返回進入此目錄之前所在的目錄

命令:

cd-

輸出:

1[root@localhostsoft]#pwd

2/opt/soft

3[root@localhostsoft]#cd-

4/root

5[root@localhost~]#pwd

6/root

7[root@localhost~]#cd-

8/opt/soft

9[root@localhostsoft]#

例五:把上個命令的參數作為cd參數使用。

命令:

cd!$

輸出:

1[root@localhostsoft]#cd!$

2cd-

3/root

4[root@localhost~]#cd!$

5cd-

6/opt/soft

7[root@localhostsoft]#

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.