- 论坛徽章:
- 0
|
转自Easy Linux 社 区 原帖地址:http://www.1zlinux.com/bbs/thread-249-1-1.html
ls也是Linux下一个比较常用的命令,其使用频率与cd相比不相上下。
下面我们来讲解ls命令。
ls命令介绍
1.名称:ls
2.使用对象:所有使用者
3.命令格式:cd ls [-ailrAFR1] [dirName/name……]
4.作用:显示指定目录下内容信息或指定文件信息
5.参数详解:
-a 显示所有文件及目录(ls默认不会显示以"."开头的隐藏文件)
-i 输出文件i节点索引信息
-l 列出文件的详细信息。包括文件名称,权限,所有者,文件大小,最后修改日期等信息
-r 将文件相反次序显示(默认依英文次序显示)
-A 作用同-a,但不会显示"."和".."
-F 在文件后加一符号以表示文件类型,常见符号为:"*"表示可执行文件;"/"表示目录;
"@"表示符号链接;"|"表示FIFOs……
-R 同时列出所有子目录下的文件
-1 每行只输出一个文件
6.命令实例:
- [root@snms /]# ls #单独使用ls为查看当前目录下文件信息
- bin dev home lost+found mnt proc sbin srv tmp var
- boot etc lib media opt root selinux sys usr
- [root@snms /]# ls -a /root #查看所有文件(含隐藏)
- . .bash_logout .cshrc .gnome2 .scim
- .. .bash_profile .dbus .gnome2_private .subversion
- anaconda-ks.cfg .bashrc .gconf install.log .tcshrc
- .bash_history .chewing .gconfd install.log.syslog .xauthE2RMHb
- [root@snms /]# ls -i #查看文件节点信息
- 367921 bin 2 home 98113 mnt 564145 sbin 1030177 tmp
- 2 boot 645905 lib 1455329 opt 1 selinux 1267281 usr
- 371 dev 11 lost+found 1 proc 1537089 srv 972945 var
- 179873 etc 801249 media 1357217 root 1 sys
- [root@snms /]# ls -i /root
- 1360373 anaconda-ks.cfg 1357218 install.log 1357219 install.log.syslog
- [root@snms /]# ls -l /root #查看文件详细信息
- 总计 72
- -rw------- 1 root root 1595 03-17 05:34 anaconda-ks.cfg
- -rw-r--r-- 1 root root 55683 03-17 05:34 install.log
- -rw-r--r-- 1 root root 5332 03-17 05:32 install.log.syslog
- [root@snms /]# ls -r /root #反序查看文件
- install.log.syslog install.log anaconda-ks.cfg
- [root@snms /]# ls -A /root #作用同a,解释见上
- anaconda-ks.cfg .bashrc .gconf install.log .tcshrc
- .bash_history .chewing .gconfd install.log.syslog .xauthE2RMHb
- .bash_logout .cshrc .gnome2 .scim
- .bash_profile .dbus .gnome2_private .subversion
- [root@snms /]# ls -F /boot #查看文件类型
- config-2.6.27.5-117.fc10.i686 lost+found/
- efi/ System.map-2.6.27.5-117.fc10.i686
- grub/ vmlinuz-2.6.27.5-117.fc10.i686*
- initrd-2.6.27.5-117.fc10.i686.img
- [root@snms /]# ls -R /boot #显示子目录下内容
- /boot:
- config-2.6.27.5-117.fc10.i686 lost+found
- efi System.map-2.6.27.5-117.fc10.i686
- grub vmlinuz-2.6.27.5-117.fc10.i686
- initrd-2.6.27.5-117.fc10.i686.img
- /boot/efi:
- EFI
- /boot/efi/EFI:
- redhat
- /boot/efi/EFI/redhat:
- grub.efi
- /boot/grub:
- device.map grub.conf minix_stage1_5 stage2
- e2fs_stage1_5 iso9660_stage1_5 reiserfs_stage1_5 ufs2_stage1_5
- fat_stage1_5 jfs_stage1_5 splash.xpm.gz vstafs_stage1_5
- ffs_stage1_5 menu.lst stage1 xfs_stage1_5
- /boot/lost+found:
- [root@snms /]# ls -1 /boot #一行只显示一个文件
- config-2.6.27.5-117.fc10.i686
- efi
- grub
- initrd-2.6.27.5-117.fc10.i686.img
- lost+found
- System.map-2.6.27.5-117.fc10.i686
- vmlinuz-2.6.27.5-117.fc10.i686
- [root@snms /]# ls -laF /boot #联合使用
- 总计 6810
- drwxr-xr-x 5 root root 1024 03-17 05:20 ./
- drwxr-xr-x 22 root root 4096 04-02 05:36 ../
- -rw-r--r-- 1 root root 90889 11-19 01:30 config-2.6.27.5-117.fc10.i686
- drwxr-xr-x 3 root root 1024 03-17 05:18 efi/
- drwxr-xr-x 2 root root 1024 04-02 05:56 grub/
- -rw------- 1 root root 3156690 03-17 05:20 initrd-2.6.27.5-117.fc10.i686.img
- drwx------ 2 root root 12288 03-17 05:06 lost+found/
- -rw-r--r-- 1 root root 1089949 11-19 01:30 System.map-2.6.27.5-117.fc10.i686
- -rwxr-xr-x 1 root root 2570960 11-19 01:30 vmlinuz-2.6.27.5-117.fc10.i686*
- [root@snms /]#
复制代码 另ls后也可跟具体文件名,跟文件名时为查看指定文件的信息
7.命令使用技巧
1).可以使用"*"通配符,如:
- [root@snms /]# ls /boot/grub/
- device.map fat_stage1_5 grub.conf jfs_stage1_5 minix_stage1_5 splash.xpm.gz stage2 vstafs_stage1_5
- e2fs_stage1_5 ffs_stage1_5 iso9660_stage1_5 menu.lst reiserfs_stage1_5 stage1 ufs2_stage1_5 xfs_stage1_5
- [root@snms /]# ls /boot/grub/f*
- /boot/grub/fat_stage1_5 /boot/grub/ffs_stage1_5
- [root@snms /]#
复制代码 2).如果使用的比较老Linux系统版本可以用--color参数使文件以不同颜色显示,以区分各种文件。
比较新的Linux版本的这个功能应该是集成的,你可以使用--color=no来查看,这时文件将不使用彩色区分。
为方便起见,你也可以编辑/etc/bashrc文件达到一劳永逸的目的,在此文件中加入”alias ls="ls --color"“。
3).想了解更多有关ls的内容或选项,你可以使用"ls --help"或"man ls"命令来查看。
[ 本帖最后由 十年梦生 于 2009-4-2 00:35 编辑 ] |
评分
-
查看全部评分
|