15 Basic ls Command Ehemplo alang sa Linux Beginners
Ang ls nga sugo usa sa labing kanunay nga gigamit nga mga sugo sa Linux. Nagtuo ko nga ang ls nga sugo mao ang una nga sugo nga mahimo nimong gamiton kung mosulod ka sa command prompt sa Linux Box.
Gigamit namo ang ls command tricks.
[ Tingali ganahan ka usab: 5 Mapuslanon nga mga Himan sa Paghinumdom sa Linux Command sa Kahangturan ]
Niini nga artikulo, atong hisgutan ang mga sukaranan sa mga pananglitan sa ls command sa tanan nga magamit nga mga parameter sa Linux.
Ang pagpadagan sa ls nga sugo nga walay kapilian nga listahan sa mga file ug mga direktoryo sa usa ka hubo nga format diin dili namo makita ang mga detalye sama sa mga tipo sa file, gidak-on, giusab nga petsa ug oras, pagtugot ug mga link, ug uban pa.
# ls 0001.pcap Desktop Downloads index.html install.log.syslog Pictures Templates anaconda-ks.cfg Documents fbcmd_update.php install.log Music Public Videos
Dinhi, ang ls -l (-l usa ka karakter, dili usa) nagpakita sa file o direktoryo, gidak-on, giusab nga petsa ug oras, ngalan sa file o folder ug tag-iya sa file, ug ang pagtugot niini.
# ls -l total 176 -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
Ilista ang tanang mga payl lakip ang mga tinago nga mga payl sugod sa ‘.
‘.
# ls -a . .bashrc Documents .gconfd install.log .nautilus .pulse-cookie .. .cache Downloads .gnome2 install.log .netstat.swp .recently-used.xbel 0001.pcap .config .elinks .gnome2_private .kde .opera .spice-vdagent anaconda-ks.cfg .cshrc .esd_auth .gtk-bookmarks .libreoffice Pictures .tcshrc .bash_history .dbus .fbcmd .gvfs .local .pki Templates .bash_logout Desktop fbcmd_update.php .ICEauthority .mozilla Public Videos .bash_profile .digrc .gconf index.html Music .pulse .wireshark
Uban sa kombinasyon sa -lh nga kapilian, nagpakita sa mga gidak-on sa usa ka pormat nga mabasa sa tawo.
# ls -lh total 176K -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap -rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads -rw-r--r--. 1 root root 21K Aug 12 12:42 fbcmd_update.php -rw-r--r--. 1 root root 46K Jul 31 09:58 index.html -rw-r--r--. 1 root root 48K Jul 31 02:17 install.log -rw-r--r--. 1 root root 12K Jul 31 02:13 install.log.syslog drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos
Ang paggamit sa -F nga opsyon uban sa ls nga sugo magdugang sa /
nga karakter sa katapusan sa matag direktoryo.
# ls -F 0001.pcap Desktop/ Downloads/ index.html install.log.syslog Pictures/ Templates/ anaconda-ks.cfg Documents/ fbcmd_update.php install.log Music/ Public/ Videos/
Ang mosunod nga sugo nga adunay ls -r nga opsyon magpakita sa mga file ug mga direktoryo sa reverse order.
# ls -r Videos Public Music install.log fbcmd_update.php Documents anaconda-ks.cfg Templates Pictures install.log.syslog index.html Downloads Desktop 0001.pcap
Ang ls -R nga kapilian maglista sa taas kaayo nga listahan sa mga punoan sa direktoryo. Tan-awa ang usa ka pananglitan sa output sa command.
# ls -R total 1384 -rw-------. 1 root root 33408 Aug 8 17:25 anaconda.log -rw-------. 1 root root 30508 Aug 8 17:25 anaconda.program.log ./httpd: total 132 -rw-r--r-- 1 root root 0 Aug 19 03:14 access_log -rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-20120812 ./lighttpd: total 68 -rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26 access.log -rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-20120819 ./nginx: total 12 -rw-r--r--. 1 root root 0 Aug 12 03:17 access.log -rw-r--r--. 1 root root 390 Aug 12 03:17 access.log-20120812.gz
Ang kombinasyon sa -ltr magpakita sa pinakabag-o nga modification file o petsa sa direktoryo sa kataposan.
# ls -ltr total 176 -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
Uban sa usa ka kombinasyon sa -lS nagpakita sa gidak-on sa file sa han-ay, ipakita ang dako sa gidak-on una.
# ls -lS total 176 -rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log -rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html -rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php -rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos -rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg -rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
Makita namo ang pipila ka numero nga giimprinta sa wala pa ang ngalan sa file/direktoryo. Uban sa -i nga mga kapilian nga lista sa file/direktoryo nga adunay numero sa inode.
# ls -i 20112 0001.pcap 23610 Documents 23793 index.html 23611 Music 23597 Templates 23564 anaconda-ks.cfg 23595 Downloads 22 install.log 23612 Pictures 23613 Videos 23594 Desktop 23585 fbcmd_update.php 35 install.log.syslog 23601 Public
Susiha ang bersyon sa ls nga sugo.
# ls --version ls (GNU coreutils) 8.4 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Richard M. Stallman and David MacKenzie.
Ang panid sa tabang sa ls nga mando sa ilang kapilian.
# ls --help Usage: ls [OPTION]... [FILE]...
Uban sa ls -l command list files ubos sa direktoryo /tmp. Diin sa -ld nga mga parameter nagpakita sa impormasyon sa /tmp directory.
# ls -l /tmp total 408 drwx------. 2 narad narad 4096 Aug 2 02:00 CRX_75DAF8CB7768 -r--------. 1 root root 384683 Aug 4 12:28 htop-1.0.1.tar.gz drwx------. 2 root root 4096 Aug 4 11:20 keyring-6Mfjnk drwx------. 2 root root 4096 Aug 16 01:33 keyring-pioZJr drwx------. 2 gdm gdm 4096 Aug 21 11:26 orbit-gdm drwx------. 2 root root 4096 Aug 19 08:41 pulse-gl6o4ZdxQVrX drwx------. 2 narad narad 4096 Aug 4 08:16 pulse-UDH76ExwUVoU drwx------. 2 gdm gdm 4096 Aug 21 11:26 pulse-wJtcweUCtvhn -rw-------. 1 root root 300 Aug 16 03:34 yum_save_tx-2012-08- 16-03-34LJTAa1.yumtx
# ls -ld /tmp/ drwxrwxrwt. 13 root root 4096 Aug 21 12:48 /tmp/
Aron ipakita ang UID ug GID sa mga file ug direktoryo. gamita ang opsyon -n uban ang ls command.
# ls -n total 36 drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Downloads drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Music drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Pictures -rw-rw-r--. 1 500 500 12 Aug 21 13:06 tmp.txt drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Videos
Naghimo kami og usa ka alyas alang sa ls nga sugo, kung among ipatuman ang ls nga sugo kini magkuha sa -l nga kapilian pinaagi sa default ug magpakita sa usa ka taas nga listahan sama sa gihisgutan sa sayo pa.
# alias ls="ls -l"
Mubo nga sulat: Makita namo ang ubay-ubay nga mga alyas nga anaa sa imong sistema nga adunay ubos nga alias command ug ang parehas mahimong unalias sama sa gipakita sa ubos nga pananglitan.
# alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Aron makuha ang usa ka alias nga gihubit kaniadto, gamita lang ang unalias nga sugo.
# unalias ls
[ Tingali ganahan ka usab: Giunsa Paghimo ug Paggamit ang Alias Command sa Linux ]
Sa among sunod nga artikulo, magtabon kami og dugang o mag-interbyu sa mga pangutana sa ls nga sugo, ug usab kung kami nasipyat sa bisan unsa sa lista, palihug i-update kami pinaagi sa seksyon sa komentaryo.