دستورهای خط فرمان لینوکس برای نمایش لیست فایل ها _دستور ls در لینوکس
gameover.blog.ir
ترجمه: گیم اور
لیست تمام فایل ها:
$ ls [options] [file|dir]
مثال:
$ ls
لیست تمام فایل ها(حتی فایل های مخفی hidden که با کاراکتر نقطه '.' آغاز می شوند):
لیست فایلها با فرمت طولانی تر:
total 4
drwxr-xr-x 2 user user 80 2011-08-17 16:52 Desktop
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Documents
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Downloads
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Music
drwxr-xr-x 2 user user 120 2011-08-17 18:14 Pictures
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Public
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Templates
-rw-r--r-- 1 user user 131 2011-08-17 18:07 todo.txt
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Videos
$
ls -la: long listing format with hidden files:
$ ls -la
total 40
drwxr-xr-x 25 user user 680 2011-08-17 18:07 .
drwxr-xr-x 3 root root 60 2011-08-17 16:19 ..
-rw-r--r-- 1 user user 220 2011-08-17 16:19 .bash_logout
-rw-r--r-- 1 user user 3353 2011-08-17 16:19 .bashrc
drwx------ 7 user user 220 2011-08-17 17:58 .cache
drwx------ 9 user user 220 2011-08-17 18:02 .config
drwx------ 3 user user 60 2011-08-17 16:19 .dbus
drwxr-xr-x 2 user user 80 2011-08-17 16:52 Desktop
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Documents
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Downloads
-rw------- 1 user user 16 2011-08-17 16:20 .esd_auth
drwxr-xr-x 2 user user 100 2011-08-17 17:56 .fontconfig
drwx------ 4 user user 80 2011-08-17 16:52 .gconf
drwx------ 2 user user 60 2011-08-17 18:14 .gconfd
drwx------ 5 user user 100 2011-08-17 16:52 .gnome2
drwxr-xr-x 2 user user 60 2011-08-17 17:58 .gstreamer-0.10
-rw-r--r-- 1 user user 142 2011-08-17 16:52 .gtk-bookmarks
dr-x------ 2 user user 0 2011-08-17 16:52 .gvfs
-rw------- 1 user user 318 2011-08-17 16:52 .ICEauthority
drwxr-xr-x 3 user user 60 2011-08-17 17:56 .libreoffice
drwxr-xr-x 3 user user 60 2011-08-17 16:52 .local
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Music
drwxr-xr-x 2 user user 40 2011-08-17 16:52 .nautilus
drwxr-xr-x 2 user user 120 2011-08-17 18:14 Pictures
-rw-r--r-- 1 user user 675 2011-08-17 16:19 .profile
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Public
drwx------ 2 user user 160 2011-08-17 16:20 .pulse
-rw------- 1 user user 256 2011-08-17 16:20 .pulse-cookie
drwxr-xr-x 5 user user 100 2011-08-17 17:58 .shotwell
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Templates
drwx------ 3 user user 60 2011-08-17 18:02 .thumbnails
-rw-r--r-- 1 user user 131 2011-08-17 18:07 todo.txt
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Videos
-rw------- 1 user user 8030 2011-08-17 18:16 .xsession-errors
$
لیست فایل ها با ترتیب نزولی حروف الفبا(r به معنی reverse یا معکوس است):
Videos Templates Pictures Downloads Desktop
todo.txt Public Music Documents
$
لیست بازگشتی یا Recursive:
.:
Desktop Downloads Pictures Templates Videos
Documents Music Public todo.txt
./Desktop:
examples.desktop ubiquity-gtkui.desktop
./Documents:
./Downloads:
./Music:
./Pictures:
ls-a.png ls-full-path.png ls-l.png ls-s.png
./Public:
./Templates:
./Videos:
$
.:
total 4
drwxr-xr-x 2 user user 80 2011-08-17 16:52 Desktop
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Documents
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Downloads
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Music
drwxr-xr-x 2 user user 120 2011-08-17 18:14 Pictures
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Public
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Templates
-rw-r--r-- 1 user user 131 2011-08-17 18:07 todo.txt
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Videos
./Desktop:
total 12
-rwxr-xr-x 1 user user 203 2011-08-17 16:52 examples.desktop
-rwxr-xr-x 1 user user 7672 2011-08-17 16:19 ubiquity-gtkui.desktop
./Documents:
total 0
./Downloads:
total 0
./Music:
total 0
./Pictures:
total 556
-rw-r--r-- 1 user user 94114 2011-08-17 18:13 ls-a.png
-rw-r--r-- 1 user user 254129 2011-08-17 18:14 ls-full-path.png
-rw-r--r-- 1 user user 102761 2011-08-17 18:13 ls-l.png
-rw-r--r-- 1 user user 77374 2011-08-17 18:12 ls-s.png
./Public:
total 0
./Templates:
total 0
./Videos:
total 0
$
لیست فایل به همره size آن ها:
total 4
0 Desktop 0 Downloads 0 Pictures 0 Templates 0 Videos
0 Documents 0 Music 0 Public 4 todo.txt
$
لیست فایل ها با سایز و طولانی:
$ ls -ls
total 4
0 drwxr-xr-x 2 user user 80 2011-08-17 16:52 Desktop
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Documents
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Downloads
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Music
0 drwxr-xr-x 2 user user 120 2011-08-17 18:14 Pictures
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Public
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Templates
4 -rw-r--r-- 1 user user 131 2011-08-17 18:07 todo.txt
0 drwxr-xr-x 2 user user 40 2011-08-17 16:52 Videos
$
لیست فایل ها با سایز و به حالت مرتب(S=Sort):
todo.txt Desktop Downloads Public Videos
Pictures Documents Music Templates
$
لیست فایل ها به همراه تاریخ و زمان time/date:
$ ls -lt
total 4
drwxr-xr-x 2 user user 120 2011-08-17 18:14 Pictures
-rw-r--r-- 1 user user 131 2011-08-17 18:07 todo.txt
drwxr-xr-x 2 user user 80 2011-08-17 16:52 Desktop
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Documents
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Downloads
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Music
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Public
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Templates
drwxr-xr-x 2 user user 40 2011-08-17 16:52 Videos
$
لیست فایل ها و پوشه ها با نمایش کامل مسیر مطلق آنها:
$ ls -d $PWD/*
/home/user/Desktop /home/user/Music
/home/user/Templates
/home/user/Documents /home/user/Pictures /home/user/todo.txt
/home/user/Downloads /home/user/Public /home/user/Videos
$
مثال بعدی:
$ ls -ld $PWD/*
total 4
drwxr-xr-x 2 user user 80 2011-08-17 16:52 /home/user/Desktop
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Documents
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Downloads
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Music
drwxr-xr-x 2 user user 120 2011-08-17 18:14 /home/user/Pictures
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Public
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Templates
-rw-r--r-- 1 user user 131 2011-08-17 18:07 /home/user/todo.txt
drwxr-xr-x 2 user user 40 2011-08-17 16:52 /home/user/Videos
$