CentOS学习之常用命令ls

命令格式与目录处理命令ls

 

命令格式:  命令[-选项][参数]

 

例如:  ls -la /etc

 

说明:

 

1)个别命令使用不遵循此格式

 

2)当多个选项时,可以写在一起

 

3)简化选项与完整选项

 

     -a 等于--all

 

PS:在Linux中“.”代表的是隐藏文件。

 

目录处理命令:ls

命令名称

 ls

命令英文原意:

list

命令所在路径:

/bin/ls

执行权限:

所有用户

功能描述:

显示目录文件

语法:

ls 选项[-ald][文件或目录]

 

-a  显示所有文件,包括隐藏文件

 

-l  详细信息显示

 

-d  查看目录属性

#ls -a 查看本目录下的文件(包含隐藏文件)

#ls -l 显示文件的详细信息

 

1 root root  1208 12月  3 06:22 anaconda-ks.cfg

 

1 root root 24772 12月  3 06:22 install.log

 

1 root root  7690 12月  3 06:21 install.log.syslog

 

root 所有者  root 所属组  7690  文件大小

 

下面的ls -lh是将文件大小的字节显示转变成我们所熟悉的Windows

 

1
2
3
4
5
[root@localhost ~]# ls -lh
总用量 44K
-rw-------. 1 root root <span ><strong><span >1.2K</span></strong></span> 12月  3 06:22 anaconda-ks.cfg
-rw-r--r--. 1 root root  25K 12月  3 06:22 install.log
-rw-r--r--. 1 root root 7.6K 12月  3 06:21 install.log.syslog

 

1.2K 和 7690代表的是一个意思,只不过当用ls -lh的时候会将文件大小变成我们所熟悉的K、M、G表示而不是字节表示。

-rw-r--r--

-文件类型(-二进制文件   d表示目录   l表示软链接文件)

 

rw-   r--   r--

 

u     g      o

 

u所有者 g所属组 o其他人

PS: r读 w写 x执行

 

1
2
[root@localhost ~]# ls -lhd /etc
drwxr-xr-x. 102 root root 12K 12月 15 06:36 /etc

 

ls -lhd /etc 是查看etc目录的大小而不是查看ect目录下的所有内容。

 

1
2
[root@localhost ~]# ls -i
795111 anaconda-ks.cfg  786436 install.log  786437 install.log.syslog

 

#ls -i 查看每个文件的id号

posted on 2016-08-08 16:06  用代码书写人生  阅读(6614)  评论(0编辑  收藏  举报