Linux command ls

Source: Internet
Author: User
Tags parent directory

LS English full name: list is the meaning of lists, is one of the most frequently used in Linux system commands, I believe that the LS command must be you enter a Linux system of the computer to open a command prompt after the first command to use. We use the LS command frequently every day. In this article, I discuss as much as possible some of the more important common LS command parameters.

In addition , it is interesting to say that when we learn something, we need to know the reason why, when you know that this thing is probably what your thinking will be associated with a lot of things will soon learn. So it is necessary to learn the LS command well.


Command format:

LS [options] [directory name]


Command function:

Lists all subdirectories and files in the destination directory.


Common parameters:

  1. -a,–all lists all files under the directory, including the. The implied file at the beginning

  2. -A with-a, listed in addition to "." (represents the current directory) and ".." (representing the parent directory of the current directory)

  3. - C mate-lt: Sort and display CTime based on CTime (the time the file state last changed) mate-L: Show CTime but sort by name otherwise: Sort by CTime

  4. –color[=when] Controls whether to use color-resolved files. When can be ' never ', ' always ' or ' auto ' one of them, you can use aliases alias ls= "ls--color=auto" for ease of use

  5. -d,–directory Displays the directory as a file, rather than displaying the file below it

  6. -h,–human-readable list file sizes in an easy-to-understand format (e.g. 1K 234M 2G)

  7. -i,–inode Prints the inode number of each file

  8. -l lists the permissions, owner, file size, and so on, in addition to the file name.

  9. -l,–dereference when displaying the file information for a symbolic link, displays the object indicated by the symbolic link instead of the information of the symbolic link itself

  10. -r,–recursive listing all subdirectory tiers at the same time

  11. -s sort by file size

  12. -T sorted by file modification time

  13. -1 list only one file per line

  14. Help display this help message and leave

  15. –version display version information and leave

Extended:

Calculate the number of files in the current directory

Ls-l *|grep "^-" | Wc-l

The meaning of some file colors in Linux files

Display a list of color catalogs
Open/ETC/BASHRC and add the following line:
Alias ls= "LS--color"
The next time you start bash, you'll be able to display a list of colored catalogs as you would in Slackware, where the meanings of colors are as follows:
1. Blue---Directory
2. Green---executable file
3. Red--Compress files
4. Light blue--linked files
5. Gray--Other files


Common demonstrations:

Example one: List the details of all files in/tmp, including hidden files starting with.

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/A1/wKioL1hTbfigXbw9AABtEOySk3A204.png-wh_500x0-wm_3 -wmp_4-s_808437731.png "title=" qq picture 20161216123017.png "Width=" "height=" 117 "border=" 0 "hspace=" 0 "vspace=" 0 " Style= "WIDTH:600PX;HEIGHT:117PX;" alt= "Wkiol1htbfigxbw9aabteoysk3a204.png-wh_50"/>

Example two: List all files and directories starting with 1 in/tmp

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8B/A5/wKiom1hTdCTBBW2zAAAwLb-zSQQ726.png-wh_500x0-wm_3 -wmp_4-s_2619373909.png "title=" qq picture 20161216125644.png "Width=" "height=" 131 "border=" 0 "hspace=" 0 "vspace=" 0 " Style= "width:600px;height:131px;" alt= "Wkiom1htdctbbw2zaaawlb-zsqq726.png-wh_50"/>


Suddenly I don't feel the need









Linux command ls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.