linux command summary of the ls command
English full name: That is the meaning of List list, when we learn of something to do to know why, when you know the thing about the future is what your mind will think of a lot of things to learn will quickly.
Format:
1
|
ls
[选项] [目录名]
|
1. ls -a list all files in the file, including the "." At the beginning of the hidden files (Linux file under the hidden files are. At the beginning, if there is .. on behalf of the existence of the parent directory).
Details 2. ls -l List files, such as author, creation time, read and write permissions list of files and so on.
3. ls -F at the end of each file with the file type of the character described. "@" Symbolic link "|" represents FIFOS, "/" indicates a directory, "=" represents a socket.
4. ls -s print out the file size of each file in the back. size (size)
Sort Time 5. ls -t files by time (Time)
6. The LS -A list files except "." and ".." in.
7. ls -R directory and all subdirectories of files are listed, the equivalent of our programming "recursive" to achieve
link name 8. ls -L listed files. Link (Link)
9. LS -S size of the file to be sorted
These are some of the uses of some of the ls command, of course, a lot is not listed, you can man look. Contribute to learning English
ls can be combined with the pipe symbol "|" to conduct some complicated operations. For example: ls | less to implement paging file list, ls calculate the number of files in the current directory:
1
|
ls
-|*|
grep
"^-"
|
wc
-|
|
Finally, talk about the meaning of some colors of linux file under the file (by default, you can modify the color CRT clients)
Green ----> represents the executable file (green for pass means) Oh
red ----> on behalf of compression file
dark blue ----> represents the directory
blue -----> represents the linked files
gray ----> on behalf of a number of other documents
Common examples:
Example One: List details of all files and directories / home / folder
Example II: List detailed current directory to "n" at the beginning of all of the directory, with the following command:
-rw-r--r--. 1 root root 15322 9月 16 2015 network-functions
-rw-r--r--. 1 root root 26134 9月 16 2015 network-functions-ipv6
Example Three: subdirectories under the file list only
.:
ifcfg-eno16777736 ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-ppp
ifdown-isdn ifup-bnep ifup-routes
ifdown-post ifup-eth ifup-sit
Example 4: lists the names of all files in the current working directory is a beginning, the more the more new row back, you can use the following command:
-rwxr-xr-x. 1 root root 1876 4月 2 2015 ifup-TeamPort
-rwxr-xr-x. 1 root root 1755 4月 2 2015 ifup-Team
-rwxr-xr-x. 1 root root 1556 4月 2 2015 ifdown-TeamPort
-rwxr-xr-x. 1 root root 1599 4月 2 2015 ifdown-Team
-rwxr-xr-x. 1 root root 4623 9月 16 2015 init.ipv6-global
-rwxr-xr-x. 1 root root 1740 9月 16 2015 ifup-wireless
-rwxr-xr-x. 1 root root 2682 9月 16 2015 ifup-tunnel
-rwxr-xr-x. 1 root root 3263 9月 16 2015 ifup-sit
-rwxr-xr-x. 1 root root 1925 9月 16 2015 ifup-routes
-rwxr-xr-x. 1 root root 4154 9月 16 2015 ifup-ppp
-rwxr-xr-x. 1 root root 2609 9月 16 2015 ifup-post
-rwxr-xr-x. 1 root root 1043 9月 16 2015 ifup-plusb
-rwxr-xr-x. 1 root root 642 9月 16 2015 ifup-plip
-rwxr-xr-x. 1 root root 10430 9月 16 2015 ifup-ipv6
-rwxr-xr-x. 1 root root 12039 9月 16 2015 ifup-ippp
-rwxr-xr-x. 1 root root 11721 9月 16 2015 ifup-eth
-rwxr-xr-x. 1 root root 859 9月 16 2015 ifup-bnep
-rwxr-xr-x. 1 root root 12631 9月 16 2015 ifup-aliases
-rwxr-xr-x. 1 root root 1462 9月 16 2015 ifdown-tunnel
-rwxr-xr-x. 1 root root 1444 9月 16 2015 ifdown-sit
-rwxr-xr-x. 1 root root 837 9月 16 2015 ifdown-routes
-rwxr-xr-x. 1 root root 1068 9月 16 2015 ifdown-ppp
-rwxr-xr-x. 1 root root 1642 9月 16 2015 ifdown-post
-rwxr-xr-x. 1 root root 4201 9月 16 2015 ifdown-ipv6
-rwxr-xr-x. 1 root root 781 9月 16 2015 ifdown-ippp
-rwxr-xr-x. 1 root root 5817 9月 16 2015 ifdown-eth
-rwxr-xr-x. 1 root root 627 9月 16 2015 ifdown-bnep
-rw-r--r--. 1 root root 254 9月 16 2015 ifcfg-lo
-rwxr-xr-x. 1 root root 10145 11月 20 2015 ifup-ib
-rwxr-xr-x. 1 root root 6196 11月 20 2015 ifdown-ib
lrwxrwxrwx. 1 root root 24 9月 13 21:57 ifdown -> ../../../usr/sbin/ifdown
lrwxrwxrwx. 1 root root 11 9月 13 21:57 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root 22 9月 13 21:57 ifup -> ../../../usr/sbin/ifup
lrwxrwxrwx. 1 root root 9 9月 13 21:57 ifup-isdn -> ifup-ippp
-rw-r--r--. 1 root root 288 9月 13 22:43 ifcfg-eno16777736
Example 5: List all files and directories under the current working directory; the name of the directory to add "/" after the name of the executable file to add "*"
ifcfg-eno16777736 ifdown-post* ifup-eth* ifup-sit*
.ifcfg-eno16777736.swp ifdown-ppp* ifup-ib* ifup-Team*
ifcfg-lo ifdown-routes* ifup-ippp* ifup-TeamPort*
ifdown@ ifdown-sit* ifup-ipv6* ifup-tunnel*
ifdown-bnep* ifdown-Team* ifup-isdn@ ifup-wireless*
ifdown-eth* ifdown-TeamPort* ifup-plip* init.ipv6-global*
ifdown-ib* ifdown-tunnel* ifup-plusb* network-functions
ifdown-ippp* ifup@ ifup-post* network-functions-ipv6
ifdown-ipv6* ifup-aliases* ifup-ppp*
ifdown-isdn@ ifup-bnep* ifup-routes*
例六:计算当前目录下的文件数和目录数
37
[root@hanjiali network-scripts]# ls -l * |grep "d"|wc -l -------目录个数
15
例七: 在ls中列出文件的绝对路径
/etc/sysconfig/network-scriptsifcfg-eno16777736
/etc/sysconfig/network-scriptsifcfg-lo
/etc/sysconfig/network-scriptsifdown
/etc/sysconfig/network-scriptsifdown-bnep
/etc/sysconfig/network-scriptsifdown-eth
/etc/sysconfig/network-scriptsifdown-ib
英文全名:List即列表的意思,当我们学习某种东西的时候要做到知其所以然,当你知道了这个东西大概是个什么了以后你的思维就会联想到很多的东西学习的就会很快。
命令格式:
1
|
ls
[选项] [目录名]
|
1. ls -a 列出文件下所有的文件,包括以“.“开头的隐藏文件(Linux下文件隐藏文件是以.开头的,如果存在..代表存在着父目录)。
2. ls -l 列出文件的详细信息,如创建者,创建时间,文件的读写权限列表等等。
3. ls -F 在每一个文件的末尾加上一个字符说明该文件的类型。"@"表示符号链接、"|"表示FIFOS、"/"表示目录、"="表示套接字。
4. ls -s 在每个文件的后面打印出文件的大小。 size(大小)
5. ls -t 按时间进行文件的排序 Time(时间)
6. ls -A 列出除了"."和".."以外的文件。
7. ls -R 将目录下所有的子目录的文件都列出来,相当于我们编程中的“递归”实现
8. ls -L 列出文件的链接名。Link(链接)
9. ls -S 以文件的大小进行排序
以上是一些关于ls命令的一些用法,当然还有好多没有列出来,大家可以man一下。有助于学习英文
ls可以结合管道符”|“来进行一下复杂的操作。比如: ls | less用于实现文件列表的分页,ls计算当前目录下的文件数量:
1
|
ls
-|*|
grep
"^-"
|
wc
-|
|
最后说一下linux下文件的一些文件颜色的含义(默认,颜色在CRT客户端可以修改)
绿色---->代表可执行文件,(绿色代表通行证的意思)呵呵
红色---->代表压缩文件
深蓝色---->代表目录
浅蓝色----->代表链接文件
灰色---->代表其它的一些文件
常用范例:
例一:列出/home/文件夹下的所有文件和目录的详细资料
例二:列出当前目录中所有以“n”开头的目录的详细内容,可以使用如下命令:
-rw-r--r--. 1 root root 15322 9月 16 2015 network-functions
-rw-r--r--. 1 root root 26134 9月 16 2015 network-functions-ipv6
例三:只列出文件下的子目录
.:
ifcfg-eno16777736 ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-ppp
ifdown-isdn ifup-bnep ifup-routes
ifdown-post ifup-eth ifup-sit
例四:列出目前工作目录下所有名称是a 开头的文件,愈新的排愈后面,可以使用如下命令:
-rwxr-xr-x. 1 root root 1876 4月 2 2015 ifup-TeamPort
-rwxr-xr-x. 1 root root 1755 4月 2 2015 ifup-Team
-rwxr-xr-x. 1 root root 1556 4月 2 2015 ifdown-TeamPort
-rwxr-xr-x. 1 root root 1599 4月 2 2015 ifdown-Team
-rwxr-xr-x. 1 root root 4623 9月 16 2015 init.ipv6-global
-rwxr-xr-x. 1 root root 1740 9月 16 2015 ifup-wireless
-rwxr-xr-x. 1 root root 2682 9月 16 2015 ifup-tunnel
-rwxr-xr-x. 1 root root 3263 9月 16 2015 ifup-sit
-rwxr-xr-x. 1 root root 1925 9月 16 2015 ifup-routes
-rwxr-xr-x. 1 root root 4154 9月 16 2015 ifup-ppp
-rwxr-xr-x. 1 root root 2609 9月 16 2015 ifup-post
-rwxr-xr-x. 1 root root 1043 9月 16 2015 ifup-plusb
-rwxr-xr-x. 1 root root 642 9月 16 2015 ifup-plip
-rwxr-xr-x. 1 root root 10430 9月 16 2015 ifup-ipv6
-rwxr-xr-x. 1 root root 12039 9月 16 2015 ifup-ippp
-rwxr-xr-x. 1 root root 11721 9月 16 2015 ifup-eth
-rwxr-xr-x. 1 root root 859 9月 16 2015 ifup-bnep
-rwxr-xr-x. 1 root root 12631 9月 16 2015 ifup-aliases
-rwxr-xr-x. 1 root root 1462 9月 16 2015 ifdown-tunnel
-rwxr-xr-x. 1 root root 1444 9月 16 2015 ifdown-sit
-rwxr-xr-x. 1 root root 837 9月 16 2015 ifdown-routes
-rwxr-xr-x. 1 root root 1068 9月 16 2015 ifdown-ppp
-rwxr-xr-x. 1 root root 1642 9月 16 2015 ifdown-post
-rwxr-xr-x. 1 root root 4201 9月 16 2015 ifdown-ipv6
-rwxr-xr-x. 1 root root 781 9月 16 2015 ifdown-ippp
-rwxr-xr-x. 1 root root 5817 9月 16 2015 ifdown-eth
-rwxr-xr-x. 1 root root 627 9月 16 2015 ifdown-bnep
-rw-r--r--. 1 root root 254 9月 16 2015 ifcfg-lo
-rwxr-xr-x. 1 root root 10145 11月 20 2015 ifup-ib
-rwxr-xr-x. 1 root root 6196 11月 20 2015 ifdown-ib
lrwxrwxrwx. 1 root root 24 9月 13 21:57 ifdown -> ../../../usr/sbin/ifdown
lrwxrwxrwx. 1 root root 11 9月 13 21:57 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root 22 9月 13 21:57 ifup -> ../../../usr/sbin/ifup
lrwxrwxrwx. 1 root root 9 9月 13 21:57 ifup-isdn -> ifup-ippp
-rw-r--r--. 1 root root 288 9月 13 22:43 ifcfg-eno16777736
例五:列出目前工作目录下所有档案及目录;目录于名称后加"/", 可执行档于名称后加"*"
ifcfg-eno16777736 ifdown-post* ifup-eth* ifup-sit*
.ifcfg-eno16777736.swp ifdown-ppp* ifup-ib* ifup-Team*
ifcfg-lo ifdown-routes* ifup-ippp* ifup-TeamPort*
ifdown@ ifdown-sit* ifup-ipv6* ifup-tunnel*
ifdown-bnep* ifdown-Team* ifup-isdn@ ifup-wireless*
ifdown-eth* ifdown-TeamPort* ifup-plip* init.ipv6-global*
ifdown-ib* ifdown-tunnel* ifup-plusb* network-functions
ifdown-ippp* ifup@ ifup-post* network-functions-ipv6
ifdown-ipv6* ifup-aliases* ifup-ppp*
ifdown-isdn@ ifup-bnep* ifup-routes*
例六:计算当前目录下的文件数和目录数
37
[root@hanjiali network-scripts]# ls -l * |grep "d"|wc -l -------目录个数
15
例七: 在ls中列出文件的绝对路径
/etc/sysconfig/network-scriptsifcfg-eno16777736
/etc/sysconfig/network-scriptsifcfg-lo
/etc/sysconfig/network-scriptsifdown
/etc/sysconfig/network-scriptsifdown-bnep
/etc/sysconfig/network-scriptsifdown-eth
/etc/sysconfig/network-scriptsifdown-ib