The Linux command line LS

Source: Internet
Author: User

Pinch refers to a count, this cock wire into the Linux industry has been two years, although now in the shell to knock command to hit the wind, but suddenly look back, only to find that in fact, their orders are only smattering.

In the start-up phase of using Linux, knocking commands to solve problems quickly, enjoy the sense of accomplishment, this is my motivation, I enjoy the "direct" and the bottom of the system dialogue and solve the problem of the process; However, people can not stay at that level, the Linux command line is profound, I would like to upgrade this enjoyment, The inevitable melted down-re-understanding the commands used before, and the system in mind, is the only way to be more effective and accurate with this powerful tool to solve various problems.

Today, I start with the most basic LS command.
LS is the abbreviation of the list, as its name implies that it is listed or displayed. The parameter general directory after LS, LS will list which files (including directories) are in these directories. The basic format of the command is:
LS option file list
The options can be omitted, and each file in the file list is separated by a space. A file can be either a directory or an ordinary text file, but it's not really meaningful for plain text files to simply display them on the command line. If there is nothing behind LS, it defaults to the current directory as the parameter, which lists the files in the current directory.
* When the LS output is sorted in dictionary order by column, this can actually be observed by yourself *

Then go to the key topic: LS option.

    • -A: Lists hidden files, including hidden directories
      Many directories contain hidden files, that is, the dot "." The files that begin with. If you do not add the-a option, these files will not be exported by default. Also in the graphical interface, you can open your home directory, you can see is not the home directory of all, in the Ubuntu system, you can press "Ctrl + H", there will be a lot of other files immediately.

    • -F: Add forward slash "/" after the directory file
      This parameter is used to distinguish between directory files and ordinary files. In fact, by default, the output of LS, catalog files and ordinary files will be displayed in different colors, but some terminals do not support color, resulting in all files using the same color, you can use the-f parameter to distinguish.

    • -R: Recursively lists the files in the parameter subdirectory. That is, the subdirectories, the Sun directory, and all the files in the descendant directory will be listed.

    • -L: This parameter is also useful for ordinary text files, it will list the individual files in the form of the detailed information of each file, each line of information from left to right: file type, file permissions, the total number of hard links to file, the file belongs to the user and group, file size (in bytes), File last modified time, file name. As follows:

[Email protected]:~/program/c_codes$ ll Total dosage +Drwxrwxr- x 5Mm4096  5Month A  +: - ./Drwxr-XR- x 9Mm4096  5Month6  A: - ../Drwxrwxr- x 2Mm4096  5Month A  -: AAlgorithms/-RWXRWXR- x 1Mm7314  5MonthTen  -: -A.Out*Drwxrwxr- x 8Mm4096  5Month A  -: A .Git/-RW-RW- R-- 1Mm -  5Month4 xx: the .Gitignore-RW-RW- R-- 1Mm1399  4Month -  -: -Stone_scissors_cloth.C-RW-RW- R-- 1Mm322  5Month A  +: -Test.Cdrwxrwxr- x 3Mm4096  4Month -  One: -Tools/

The total amount of the above is what I have not figured out, later added.

    • -C: Sorted by the last modification time of the file, most recently in the first
    • -D: All files are treated as normal files. Sometimes we just want to know the information about a directory itself, and we don't want to list which files it contains, as follows:
m@sys:~/program/C_codes/algorithms$ 15312288  51220:16 /etc/
    • -R: Reverse order

    • -S: Sort by the actual size of the file:

[Email protected]:~/program/c_codes/algorithms$ ls-SLTotal dosage +-RWXRWXR- x 1Mm7399  5Month A  -: OneA.Out-RW-RW- R-- 1Mm1298  5Month6  -:TenHeapsort.C-RW-RW- R-- 1Mm1139  5Month4  A: -Merge_sort.C-RW-RW- R-- 1Mm915  5Month9  -: +Quicksort.C-RW-RW- R-- 1Mm909  5Month A  -: A Stack.C-RW-RW- R-- 1Mm782  5Month4  -: -Search_array_sum.C-RW-RW- R-- 1Mm687  5Month2  +: -Binary_search.C-RW-RW- R-- 1Mm566  5Month4 xx:TenInsert_sort.C-RW-RW- R-- 1Mm the  4Month7  -: AReadme.Md
    • -S: Shows the number of chunks (blocks) of the disk allocated for each file, just explaining the doubts about the total usage of the-l parameter above:
[Email protected]:~/program/c_codes/algorithms$ ls-SLTotal dosage +8 -RWXRWXR- x 1Mm7399  5Month A  -: OneA.Out4 -RW-RW- R-- 1Mm687  5Month2  +: -Binary_search.C4 -RW-RW- R-- 1Mm1298  5Month6  -:TenHeapsort.C4 -RW-RW- R-- 1Mm566  5Month4 xx:TenInsert_sort.C4 -RW-RW- R-- 1Mm1139  5Month4  A: -Merge_sort.C4 -RW-RW- R-- 1Mm915  5Month9  -: +Quicksort.C4 -RW-RW- R-- 1Mm the  4Month7  -: AReadme.Md4 -RW-RW- R-- 1Mm782  5Month4  -: -Search_array_sum.C4 -RW-RW- R-- 1Mm909  5Month A  -: A Stack.C
    • -1: Do not allow all files to be squeezed in one line, only a single file is displayed per line. Note that the number "1"
    • -U: Sort by last access time, with-l and-t see man ls

This is the result of my review, selected some of their own less familiar or fun options.

The Linux command line 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.