Understanding of the LS command

Source: Internet
Author: User
Tags control characters iso 8601 iso 8601 format month name rfc

LS Note just show the size of the file, not take up disk space, this sentence is mainly for the folder, LS is a statistical directory structure in the folder node size, not the size of all files under the folder, the sum of all the files under the Statistics folder, using the du command, specific reference:/HTTP blog.csdn.net/ysdaniel/article/details/6922055

Du--max-depth=1, which can view the size information for the current folder.

ll is equivalent to ls-l,l. Show only hidden files and directories, such as "." and ".."

Explanation: File modification time, file status change time, file access time
Change time and modification time (modification times), the difference between change and modification is whether to change the label of a component or alter its contents.
Access time (access time), which is the last time the file was read. So reading a file updates its access time, but its change time does not change (the information about the file has not been changed), and its modification time is the same (the file itself has not been changed).
Specific explanations:
St_atime
time when file data is last accessed. Changed by the following functions:creat (), Mknod (), pipe (), Utime (2), and read (2).

St_mtime
Time when data is last modified. Changed by the following functions:creat (), Mknod (), pipe (), Utime (), and write (2).

St_ctime
time when file status is last changed. Changed by the following Functions:chmod (), Chown (), creat (), Link (2), Mknod (), pipe (), unlink (2), Utime (), a nd write ().

Source Reference URL: http://blog.sina.com.cn/s/blog_67178440010101gr.html

Understand the LS command by function:
1, how to display, by row, by column, whether to show the owner or group, etc.
--author
With-l, print the author of each file
Parameter-L has been able to show the author, and I don't know why I need this parameter.

-c List Entries by columns
Depending on the screen size, the results of the search are displayed in columns, for example, for a total of two rows, the first two as the second column, and then, and so on, as in the following:
1 3 5) 7 9
2 4 6 8

--format=word
Across (Landscape)-X, commas (horizontal display by comma)-M, horizontal (horizontal display, that is, horizontal)-X, Long (single-row verbose display)-L, Single-column (single-line display)-1, verbose (single-row verbose display)-l , Vertical (shown by column)-C

-L Use a long listing format
Single Line detail display

-M fill width with a comma separated list of entries
Horizontal comma display

-N,--numeric-uid-gid
Like-l, but list numeric user and group IDs
Display numbers do not display names when the owning person and group are displayed

-x list entries by lines instead of by columns
is displayed as a line, not as a column, such as 1 2 3 4, not
1 3
2 4

-1 List one file per line
Single-column display

2. Conditional filter Display
-A,--all
Do not ignore entries starting with.
Do not ignore "." and "." means that the two special representations of "current directory, parent directory" are not ignored
-A,--almost-all
Do not list implied. and..
Ignore "current directory, parent directory" (That is, ".", "...") ) These two special directories
-B,--ignore-backups
Do not list implied entries ending with ~
Ignore the backup file, that is the file name last with ~
-G like-l, but does not list owner
Single-line detail display, does not show the owning person

-O like-l, but does not list group information
Single-line verbose display, group not displayed

-G,--no-group
In a long listing, don ' t print Group names
Do not display the group, if only use-G, do not display the details

--hide=pattern
Do not list implied entries matching shell PATTERN (overridden by-a or-a)
Do not display files or folders matching pattern, note that this parameter will be overwritten by-A and-a

-I.,--ignore=pattern
Do not list implied entries matching shell PATTERN
This is similar to--hide, but this is not covered by-a and-a.

3, sort, on time or name, extension what sort of, and reverse set what
-F do not sort, enable-au, Disable-ls--color
-U do not sort; List entries in directory order
Do not sort by a parameter,-F does not understand,-u, said by the directory in the order, is to use the interface to open the display, or according to the directory structure of the order of storage, not quite sure.

-C With-lt:sort by, and show, CTime (time of last modification of file status information)
With-l: Show CTime and Sort by name
Otherwise:sort by CTime
-T indicates that the list of files is sorted by time and by default is sorted by the modified time of the file contents.
-C indicates that the change (file state changed time) time is displayed, not the content modification time. With-T can be sorted according to the changing time of the file state. If there is no-T, just simple and-l, the status change time is displayed, sorted by file name, if-L and-T are not paired, only the file is displayed in the order of changes, and the file details are not displayed.
In fact, it is simple to understand that the-C is to achieve the display file state change time and the file status change time to sort the basic.

-U with-lt:sort by, and show, Access time
With-l: Show access time and sort by name
Otherwise:sort by Access time
Similar to-C, but this is the access time, note that the modification time does not have such a representation, because the modification time is the default option, do not need to write.

--group-directories-first
Group directories before files.

Augment with a--sort option, but any use of--sort=none (-u)
Disables grouping

-R,--reverse
Reverse order while sorting
Reverse order, will be the original sorted reverse display.

-s sort by file size
by file size
-t Sort by modification time
By modified time
-V Natural sort of (version) numbers within text
by version number
-x sort alphabetically by entry extension
Alphabetical ORDER BY extension

--sort=word
Sort by WORD instead of Name:none-u, Extension-x, Size-s,time-t, version-v
Sort by various parameters

--time=word
With-l, show time as WORD instead of modification time:atime-u, access-u, Use-u, ctime-c, or status-c; Use specified time as sort key if--sort=time
The feeling is a comprehensive statement of-C and-U.
Note When multiple times are combined, the last one takes effect.

4, Format time display time how to display
--full-time
Like-l--time-style=full-iso
This parameter alone displays details, with the time displayed in the format: 2015-01-16 15:40:55.811159015 +0800
--time-style=style
With-l, show times using style Style:full-iso, Long-iso, Iso,locale, +format.  FORMAT is interpreted like ' date '; If FORMAT is Format1<newline>format2, FORMAT1 applies to non-recent files and FORMAT2 to recent files; If style is prefixed with ' posix-', STYLE takes effect only outside the POSIX locale
That is to set the format of the time display, focusing on format, 1th, do not forget +, and then newline is generally a variable form, like this
Newline= '

Ls-l--time-style= "+%y-%m-%d $newline%m-%d%h:%m"

The special symbol of TIME indicates:
'%H '
Hour (' 00 ' ... ' 23 ')
'%I '
Hour (' 01 ' ... ' 12 ')
'%k '
hour, Space padded (' 0 ' ... ' 23 '); Equivalent to '%_h '. This is a GNU extension.
'%l '
hour, Space padded (' 1 ' ... ' 12 '); Equivalent to '%_i '. This is a GNU extension.
'%M '
Minute (' 00 ' ... ' 59 ')
'%N '
nanoseconds (' 000000000 ' ... ' 999999999 '). This is a GNU extension.
'%p '
Locale ' s equivalent of either ' AM ' or ' PM '; Blank in many locales. Noon is treated as ' PM ' and Midnight as ' AM '.
'%P '
Like '%p ', except lower case. This is a GNU extension.
'%r '
Locale ' s 12-hour clock time (e.g., ' 11:11:04 PM ')
'%R '
24-hour hour and minute. Same as '%h:%m '.
'%s '
Seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC. Leap seconds is not counted unless leap second support is available. See%s-examples, for examples. This is a GNU extension.
'%s '
Second (' 00 ' ... ' 60 '). This May is ' if leap seconds is supported.
'%T '
24-hour hour, minute, and second. Same as '%h:%m:%s '.
'%x '
Locale ' s time representation (e.g., ' 23:13:48 ')
'%z '
RFC 2822/iso 8601 Style numeric time zone (e.g., ' -0600 ' or ' +0530 '), or nothing if the zone is determinable. This value reflects the numeric time zone appropriate for the current time, using the time zone rules specified by the TZ environment variable. The time (and optionally, the time zone rules) can be overridden by the--date option.
'%:z '
RFC 3339/iso 8601 Style numeric time zone with ': ' (e.g., ' -06:00 ' or ' +05:30 '), or nothing if no time zone is DETERMINABL E. This is a GNU extension.
'%::z '
Numeric time zone to the nearest second with ': ' (e.g., ' -06:00:00 ' or ' +05:30:00 '), or nothing if no time zone is Determi Nable. This is a GNU extension.
'%:::z '
Numeric time zone with ': ' Using the minimum necessary precision (e.g., ' -06 ', ' +05:30 ', or ' -04:56:02 '), or nothing if no Time zone is determinable. This is a GNU extension.
'%Z '
Alphabetic time zone abbreviation (e.g, ' EDT '), or nothing if the time zone is determinable. See '%z ' for what it is determined.

Special symbol format for dates:
'%a '
Locale ' s abbreviated weekday name (e.g., ' Sun ')
'%A '
Locale ' s full weekday name, variable length (e.g, ' Sunday ')
'%b '
Locale ' s abbreviated month name (e.g., ' Jan ')
'%B '
Locale ' s full month name, variable length (e.g., ' January ')
'%c '
Locale ' s date and time (e.g., ' Thu Mar 3 23:05:25 2005 ')
'%c '
Century. This was like '%Y ' and except the last of the last of the digits is omitted. For example, it's ' if '%Y ' is ' $ ', and is '-0 ' if '%Y ' is '-001 '. It's normally at least-characters, but it could be.
'%d '
Day of month (e.g, ' 01 ')
'%d '
Date Same as '%m/%d/%y '
'%e '
Day of month, space padded; Same as '%_d '
'%F '
Full date in ISO 8601 format; Same as '%y-%m-%d '. This was a good choice for a date format, as it was standard and was easy-to-sort in the usual case where years was in the RA Nge 0000...9999.
'%g '
Year corresponding to the ISO week number, but without the century (range ' xx ' through ' 99 '). This have the same format and value as '%y ', except if the ISO week number (see '%V ') belongs to the previous or next Year, which is used instead.
'%G '
Year corresponding to the ISO week number. This have the same format and value as '%Y ', except if the ISO week number (see '%V ') belongs to the previous or next Year, which is used instead. It is normally useful only if '%V ' is also used; For example, the format '%g-%m-%d ' was probably a mistake, since it combines the ISO week number year with the conventional Month and day.
'%h '
Same as '%b '
'%j '
Day of the Year (' 001 ' ... ' 366 ')
'%m '
Month (' 01 ' ... ' 12 ')
'%u '
Day of week (' 1 ' ... ' 7 ') with ' 1 ' corresponding to Monday
'%u '
Week number of year, with Sunday as the first day of the week (' 00 ' ... ' 53 '). Days in a new year preceding the first Sunday is in week zero.
'%V '
ISO week number, that's, the week number of year, with Monday as the first day of the week (' 01 ' ... ' 53 '). If the week containing January 1 had four or more days in the new year, then it was considered Week 1; Otherwise, it is week-the-previous year, and the next week is Week 1. (See the ISO 8601 standard.)
'%w '
Day of week (' 0 ' ... ' 6 ') with 0 corresponding to Sunday
'%W '
Week number of year, with Monday as First day of week (' 00 ' ... ' 53 '). Days in a new year preceding the first Monday is in week zero.
'%x '
Locale ' s date representation (e.g., ' 12/31/99 ')
'%y '
Last both digits of year (' 00 ' ... ' 99 ')
'%Y '
Year. This was normally at least four characters, but it could be more. Year ' 0000 ' precedes year ' 0001 ', and Year ' -001 ' precedes year ' 0000 '.

Reference URL:
Http://www.gnu.org/software/coreutils/manual/html_node/date-invocation.html#date-invocation
Http://www.gnu.org/software/coreutils/manual/html_node/Formatting-file-timestamps.html

5, display the file size format settings
--block-size=size
Use Size-byte blocks. See SIZE format below
SIZE May is (or may be a integer optionally followed by) one of FOLLOWING:KB, K 1024x768, MB 1000*1000, M 1024*1024, And so on for G, T,p, E, Z, Y.
Set the display format of the file size in the information list

-H,--human-readable
With-l, print sizes in human readable format (e.g., 1K 234M 2G)
Set up a readable format for displaying file sizes
--si Likewise, but use powers of 1024
Similar to-H, but into the system by 1000, is to directly check the number of decimal places.
-K like--block-size=1k
Press K (1024) to display file size

-S,--size
Print the allocated size of each file, in blocks
Show file size by blocks number

6. Color settings for file types
--color[=when]
Colorize the output. When the defaults to "always" or can be ' never ' or ' auto '. More info below.
Using color to distinguish the file types is disabled both by default and with--color=never.  With--color=auto, LS emits color codes if standard output is connected to a terminal.  The ls_colors environment variable can change the settings. Use the Dircolors command to set it.
No in-depth understanding, just simple to understand, display color and suppress display color.

7. Whether the file name is added with special symbols
-F,--classify
Append indicator (one of */=>@|) to entries
is to display the corresponding symbol after the file name, such as "/" after the folder name.

--file-type
Likewise, except do not append ' * '
Similar to-F, but does not append "*"
-P,--indicator-style=slash
Append/indicator to Directories
Simply append "/" to a folder

--indicator-style=word
Append indicator with style WORD to entry Names:none (default), slash (-P), File-type (--file-type), classify (-f)
A brief summary of the above is summarized.

-Q,--quote-name
Enclose entry names in double quotes
Use double quotes to extend the file name, such as "test"/
--quoting-style=word
Use quoting style WORD for entry names:literal, Locale, Shell,shell-always, C, escape
Format the file name, such as single quotes, double quotes, or not.

8. For Symbolic link files
-H,--dereference-command-line
Follow symbolic links listed on the command line

--dereference-command-line-symlink-to-dir
Follow command line symbolic link, points to a directory
The folder corresponding to the symbolic link immediately following the link, specifically do not know what meaning, no test.

-L,--dereference
When showing file information for a symbolic link, show information for the file the link references rather than for the Link itself
When displaying file information, the symbolic link file is not displayed, but the information for the corresponding file of the symbolic link is displayed.

9, the treatment of special characters display
-Q,--hide-control-chars
Print? Instead of non graphic characters
Replace non-display characters with?

--show-control-chars
Show non graphic characters as-is (default unless program was ' ls ' and output is a terminal)
Don't know.

10. Other
-D,--dired
Generate output designed for Emacs ' dired mode
Don't understand what it means.

-I.,--inode
Print the index number of each file
Displays the index value of the node.

-N,--literal
Print raw entry names (don ' t treat e.g. control characters specially)
Don't understand what it means.

-T,--tabsize=cols
Assume tab stops at each COLS instead of 8
-W,--width=cols
Assume screen width instead of the current value
These two parameters-T and-W are always error-prone and do not know what the special rules are.

Reference URL:

General Manual
http://www.gnu.org/software/coreutils/manual/
Symbolic representation of the time format
Http://blog.chinaunix.net/uid-25525723-id-356633.html
Http://www.gnu.org/software/coreutils/manual/html_node/Formatting-file-timestamps.html
Description of the LS display
Http://www.jb51.net/article/14709.htm
ll and L. commands

Http://www.zhuitaiyang.com/html/2013/linuxchapter1_1005/415.html

Access time, modification time and time of change introduction

Http://blog.sina.com.cn/s/blog_67178440010101gr.html

The difference between LS and Du

http://blog.csdn.net/ysdaniel/article/details/6922055


Understanding of the LS command

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.