1. 程式人生 > >linux命令(ls ,cd,pwd)

linux命令(ls ,cd,pwd)

body init.d time mil linux mes total 主目錄 隱藏

1,ls 命令 ls用來打印出當前目錄的清單 ls -l/-h/-a -h 人性化顯示 -a 連同隱藏文件都顯示出 -F 可執行文件特殊顯示帶上*

[ligang@centos6 test4]$ ls file file1 folder folder2 folder3 [ligang@centos6 test4]$ touch .haha [ligang@centos6 test4]$ ls file file1 folder folder2 folder3
[ligang@centos6 test4]$ ls -a
. .. file file1 folder folder2 folder3 .haha [ligang@centos6 test4]$ ls
-lh total 12K -rw-r--r-- 1 ligang trainning 0 Mar 8 05:28 file -rw-r--r-- 1 ligang trainning 0 Mar 8 05:29 file1 drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:29 folder drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:30 folder2 drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:29 folder3 [ligang@centos6 test4]$ ls
-la total 20 drwxr-xr-x 5 ligang trainning 4096 Mar 8 06:08 . drwx------ 15 ligang trainning 4096 Mar 8 04:41 .. -rw-r--r-- 1 ligang trainning 0 Mar 8 05:28 file -rw-r--r-- 1 ligang trainning 0 Mar 8 05:29 file1 drwxr-xr-x 2 ligang trainning 4096 Mar 8 05:29 folder drwxr-xr-x 2 ligang trainning 4096
Mar 8 05:30 folder2 drwxr-xr-x 2 ligang trainning 4096 Mar 8 05:29 folder3 -rw-r--r-- 1 ligang trainning 0 Mar 8 06:08 .haha [ligang@centos6 test4]$ ls -lah total 20K drwxr-xr-x 5 ligang trainning 4.0K Mar 8 06:08 . drwx------ 15 ligang trainning 4.0K Mar 8 04:41 .. -rw-r--r-- 1 ligang trainning 0 Mar 8 05:28 file -rw-r--r-- 1 ligang trainning 0 Mar 8 05:29 file1 drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:29 folder drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:30 folder2 drwxr-xr-x 2 ligang trainning 4.0K Mar 8 05:29 folder3 -rw-r--r-- 1 ligang trainning 0 Mar 8 06:08 .haha

2,dir 切換當前目錄至dirName

cd/cd~ 回到用戶主目錄 cd / 進入系統根目錄 cd - 返回進入此目錄之前所在目錄
[ligang@centos6 test4]$ cd /
[ligang@centos6 /]$ cd
[ligang@centos6 ~]$ 
[root@localhost soft]# pwd
/opt/soft
[root@localhost soft]# cd -
/root
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd -
/opt/soft
[root@localhost soft]#
3,pwd pwd 命令來查看”當前工作目錄“的完整路徑 pwd顯示的是連接路徑 pwd -P 顯示出實際路徑 /bin/pwd 選項
[ligang@centos6 init.d]$ pwd
/etc/init.d
[ligang@centos6 init.d]$ /bin/pwd
/etc/rc.d/init.d
[ligang@centos6 init.d]$ pwd
/etc/init.d
[ligang@centos6 init.d]$ pwd -L
/etc/init.d
[ligang@centos6 init.d]$ pwd -P
/etc/rc.d/init.d

linux命令(ls ,cd,pwd)