The LS command is primarily used to display the details of a directory.
By default, the file information in the current directory is listed (files, folders that do not contain a. Start), and the entries are sorted alphabetically.
The syntax is as follows
The code is as follows:
ls [OPTION] ... [FILE] ...
Parameter introduction (does not contain too uncommon)
-A,--all also displays the contents of the. Beginning, including the. Directory (current directory) and ... Directory (parent directory).
-A,--almost-all also displays the contents of the. beginning, excluding. Directory and. Directory.
--author Displays the creator of the file while using the-l parameter.
-B,--ignore-backups does not show end of file (backup file).
-C (default) in the last modified time to arrange the display entries, the new in front.-lt the entries in the last modified time, and displays the modification time.-L Displays the modification time, but in alphabetical order.
-C list entries for a column.
--color[=when] Sets whether to distinguish the entry category by color, when it is clear for never,always and Auto.never and always, and Auto refers to the standard output and terminal binding to display the color. Color by environment variable Ls_ Colors decided.
-D,--directory lists directory entries and does not list shortcuts.
-F unordered list, enable-au, and disable-ls and--color.
-G is similar to-l but does not show the owner except.
-G,--no-group does not list group names in-L.
-H,--human-readable the file size in the-l format in an easier to understand way. (e.g., 1K 20M)
--si Ibid, but multiples are 1000 instead of 1024.
-I,--inode shows the index number of each entry.
-I,--ignore=pattern does not list entries that match the shell style.
--hide=pattern but will be overwritten by-a or-a.
-L Displays information in a detailed list of patterns.
-m all items are separated by commas.
-N,--numeric-uid-gid is similar to-L, listing both user and group information.
-O is similar to-l but does not list group information.
-P,--indicator-style=slash after the directory Plus/
-R,--reverse reverse sort display.
-R,--recursive lists all subdirectories.
-S,--size shows the space that each file is allocated.
-S to sort files by size.
--sort=word is sorted according to WORD, and can be none,extension,size,time and version.
--time=word in-L, according to WORD to replace the modification time, can be atime,access,use,ctime,status.
-T sort by modified time, new in front.
-U is not sorted, arranged according to the original order of the system.
-V is arranged according to the version number.
-X is arranged in the order of the rows.
-X is sorted according to the extension name.
-11 lines Show only one item.
--help help information.
--version version information.
return value
0 normal.
1 minor problems (e.g., no entry into the subdirectory).
2 serious problem (e.g., cannot enter the directory that the command line argument displays).
Ls-l the results of the show
Using the-l option, you can display directory content in a long format, such as:
In this output, a total of seven columns are displayed:
The first column is the type and authority of the file. There are 10 characters in this column, where the first character represents the type of file. That is,-the representation is a normal file, D is a directory, C is a character device, and B is a block device. The following 10 characters, which can be divided into 3 blocks, each 3 characters, represent the owner, group, and others permissions of this file (directory). where r indicates that read,w indicates that write,x indicates that execute,-represents no permission.
For example, the first line in the above figure,-RW-------, means that this is a normal file, the owner of the file has read and write permission, the file's group has no permissions, others no permissions.
The second column represents the number of hard links (each additional hard link to the file, the number will increase by 1, the default starting from 1, 1 means no hard link files, if it is a directory, its default value should be 2.) Directory is not able to do hard linking).
The third column is the owner of the file (directory).
The group of files (directories) is listed in the list four.
Column Five is the size of the file (directory), in bytes alone.
Column VI is the file (directory) creation time or last access time, in the order of month, day, time, and if the time is too long, displays the year directly.
Seventh column file name.
Because the ls–l command is more commonly used, in some distributions, the LL command has been defined as a ls–l alias.
LS Common options
LS Displays the contents of the contents of the directory, the file is in alphabetical order of A to Z, the priority is as follows:
Digital
A-Z
A-Z
That is, if you do not add any sort options, the first letter of the file name is numeric and will be given precedence, followed by A-Z, and then A-Z. We can add different options to sort the display:
Sort by size of file,-s option;
If it is sorted in reverse order, we need to use the-r option;
Sort by last visit, use the-t option;
Sort by extension to use option-X;
Recursively displays the files of the directory, using the-r option;
Recursively display all the files in the directory, if there are subdirectories under the directory, also will be the directory of files displayed.
LS output content in the terminal display color options--color;
In general, the LS output is colored, such as the directory is blue, compressed file is the display of the red Word. If there is no color, you can add an option. Of course, you can also remove the color.
--color=never indicates no color when output results
--color=auto represents automatic
--color=always indicates that the output is colored
The application of wildcard characters in LS command
* represents 0 or more characters, while [] includes any characters inside, while the? represents any single character.
For example, we show all the files that start with M in the/directory:
We display all the files that begin with a number in the current directory:
Another example: