官术网_书友最值得收藏!

  • Linux就該這么學
  • 劉遄
  • 924字
  • 2019-01-05 05:54:01

2.5 工作目錄切換命令

工作目錄指的是用戶當前在系統中所處的位置。由于工作目錄會牽涉系統存儲結構相關的知識,因此第6章將詳細講解這部分內容。讀者只需簡單了解一下這里的操作實驗即可,如果不能完全掌握也沒有關系,畢竟Linux系統的知識體系太過龐大,每一位初學人員都需要經歷這么一段時期。

1.pwd命令

pwd命令用于顯示用戶當前所處的工作目錄,格式為“pwd [選項]”。

        [root@linuxprobe etc]# pwd
        /etc

2.cd命令

cd命令用于切換工作路徑,格式為“cd [目錄名稱]”。

這個命令應該是最常用的一個Linux命令了。可以通過cd命令迅速、靈活地切換到不同的工作目錄。除了常見的切換目錄方式,還可以使用“cd -”命令返回到上一次所處的目錄,使用“cd..”命令進入上級目錄,以及使用“cd ~”命令切換到當前用戶的家目錄,亦或使用“cd ~username”切換到其他用戶的家目錄。例如,可以使用“cd路徑”的方式切換進/etc目錄中:

        [root@linuxprobe ~]# cd /etc

同樣的道理,可使用下述命令切換到/bin目錄中:

        [root@linuxprobe etc]# cd /bin

此時,要返回到上一次的目錄(即/etc目錄),可執行如下命令:

        [root@linuxprobe bin]# cd -
        /etc
        [root@linuxprobe etc]#

還可以通過下面的命令快速切換到用戶的家目錄:

        [root@linuxprobe etc]# cd ~
        [root@linuxprobe ~]#

3.ls命令

ls命令用于顯示目錄中的文件信息,格式為“ls [選項] [文件] ”。

所處的工作目錄不同,當前工作目錄下的文件肯定也不同。使用ls命令的“-a”參數看到全部文件(包括隱藏文件),使用“-l”參數可以查看文件的屬性、大小等詳細信息。將這兩個參數整合之后,再執行ls命令即可查看當前目錄中的所有文件并輸出這些文件的屬性信息:

        [root@linuxprobe ~]# ls -al
        total 60
        dr-xr-x---. 14 root root 4096 May  4 07:56 .
        drwxr-xr-x. 17 root root 4096 May  4 15:55 ..
        -rw-------.  1 root root 1213 May  4 15:44 anaconda-ks.cfg
        -rw-------.  1 root root  957 May  4 07:54 .bash_history
        -rw-r--r--.  1 root root   18 Dec 28  2013 .bash_logout
        -rw-r--r--.  1 root root  176 Dec 28  2013 .bash_profile
        -rw-r--r--.  1 root root  176 Dec 28  2013 .bashrc
        drwx------. 10 root root 4096 May  4 07:56 .cache
        drwx------. 15 root root 4096 May  4 07:49 .config
        -rw-r--r--.  1 root root  100 Dec 28  2013 .cshrc
        drwx------.  3 root root   24 May  4 07:46 .dbus
        drwxr-xr-x.  2 root root    6 May  4 07:49 Desktop
        drwxr-xr-x.  2 root root    6 May  4 07:49 Documents
        drwxr-xr-x.  2 root root    6 May  4 07:49 Downloads
        -rw-------.  1 root root   16 May  4 07:49 .esd_auth
        -rw-------.  1 root root  628 May  4 07:56 .ICEauthority
        -rw-r--r--.  1 root root 1264 May  4 07:48 initial-setup-ks.cfg
        drwx------.  3 root root   18 May  4 07:49 .local
        drwxr-xr-x.  2 root root    6 May  4 07:49 Music
        drwxr-xr-x.  2 root root    6 May  4 07:49 Pictures
        drwxr-xr-x.  2 root root    6 May  4 07:49 Public
        -rw-r--r--.  1 root root  129 Dec 28  2013 .tcshrc
        drwxr-xr-x.  2 root root    6 May  4 07:49 Templates
        drwxr-xr-x.  2 root root    6 May  4 07:49 Videos
        -rw-------.  1 root root 1962 May  4 07:54 .viminfo

如果想要查看目錄屬性信息,則需要額外添加一個-d參數。例如,可使用如下命令查看/etc目錄的權限與屬性信息:

        [root@linuxprobe ~]# ls -ld /etc
        drwxr-xr-x. 132 root root 8192 Jul 10 10:48 /etc
主站蜘蛛池模板: 三门峡市| 云南省| 葫芦岛市| 涿州市| 潞城市| 保德县| 甘肃省| 敦化市| 伽师县| 乃东县| 遂平县| 资中县| 崇信县| 阿克| 土默特右旗| 惠州市| 交城县| 靖江市| 太谷县| 岳普湖县| 威宁| 普兰县| 西乡县| 会宁县| 香格里拉县| 改则县| 延长县| 博罗县| 辽源市| 黄龙县| 大石桥市| 政和县| 乌海市| 固始县| 永清县| 青神县| 根河市| 当阳市| 科技| 海安县| 开平市|