Linux Command Learning 1

Source: Internet
Author: User

ls command

Function description

The LS command displays the contents of the specified directory, listing the files and subdirectories contained in the working directory.

Grammar

ls [OPTION] ... [FILE] ...

Common options

Options Meaning
-A Show all files, including hidden files, to. Start with hidden files
-D Typically, if a directory is specified, the LS command lists the contents of the directory rather than the directory itself. Use this item in conjunction with the-l option to view the details of the directory, not the contents of the directory
-F The option adds a type indicator after each name listed (for example, if the name is a directory name, a slash is added)
-L Long format display, in addition to the file name, at the same time the files or subdirectories of the permissions, the user and the size of information, such as detailed list
-H Listed in long format, displaying the size of a file in a human-readable manner rather than as a number of bytes
-R Displays the results in reverse order. Normally, the LS command displays results in ascending alphabetical order
-S Output the size of the file after each file name
-S Sort results by File size
-K Displays the size of the file in the form of K bytes
-U Sort by the time the file was last accessed
-T Sort by modified time
-O Show details In addition to group information
-X Output by column, sorted horizontally
-Q With "?" Replace non-output characters
-M Output file name horizontally and with "," as delimiter
-R List files in all subdirectories
-pf The first file name is appended with a character to indicate the type of the file. "*" means executable normal file, "/" means directory, "@" means symbolic link, "|" Indicates FIFO, "=" means socket (socket)
-C
Output by column, sorted vertically
-Q Enclose the file name of the output in double quotation marks.

Understanding Long Format Display

The following example uses the CentOS 7 demo, ls-l equivalent to LL

[[email  Protected] app]# cat/etc/redhat-release 

CentOS Linux release 7.1.1503 (Core)

[[email  Protected] app]# ls-l

Total usage 2636

-rw-r--r--. 1 root root 1222783 October 12:09 glances-1.7.1.tar.gz

-rw-r- -R--. 1 root root  388499 November  7 13:20 htop-1.0.2.tar.gz

-rw-r--r--. 1 root root 1081874 November  7 13:21 pip-1 .5.4.tar.gz

Drwxr-xr-x. 2 root root       6 November  7 13:15 test

[[email protected] app] # ll

Total usage 2636

-rw-r--r--. 1 root root 1222783 October 12:09 glances-1.7.1.tar.gz

-rw-r--r--. 1 root root  388499 November  7 13:20 htop-1.0.2.tar.gz

-rw-r--r--. 1 root root 1081874 November  7 13:21 pip-1.5.4.tar.gz< /p>

Drwxr-xr-x. 2 root root       6 November  7 13:15 test

Meaning of long format fields

Column Field Meaning
1th column -rw-r--r-- The access rights to the file. The first character represents the type of file. Between different types, the "-" at the beginning indicates that the file is a normal file and D represents a directory. The next three characters represent the access rights of the file owner, and then the three characters represent access to the members of the group to which the file belongs, and the last three characters represent the access rights of the other person.
2nd Column 1 Number of File links
3rd Column Root User name of the file owner
4th Column Root Name of the user group to which the file belongs
5th column 1222893
The size of the file in bytes
6th column
October 28 12:09 Date and time when the file was last modified
7th column Glances ..... Filename


Example

Use-LH to view file sizes in a convenient way

[Email protected] app]# LS-LH #以方便查看的形式显示文件大小

Total dosage 2.6M

-rw-r--r--. 1 root root 1.2M October 12:09 glances-1.7.1.tar.gz

-rw-r--r--. 1 root root 380K November 7 13:20 htop-1.0.2.tar.gz

-rw-r--r--. 1 root root 1.1M November 7 13:21 pip-1.5.4.tar.gz

Drwxr-xr-x. 2 root root 6 November 7 13:15 test

Use the-A and-a parameters to display all files and display except. and. All files except the

[[email protected] app]# ls #不加选项, listing files

glances-1.7.1.tar.gz htop-1.0.2.tar.gz pip-1.5.4.tar.gz Test

[[email protected] app]# ls-a #使用-a option to show all files

.  .. glances-1.7.1.tar.gz htop-1.0.2.tar.gz pip-1.5.4.tar.gz Test

[[email protected] app]# ls-a #使用-A option to display except. and. All the files

glances-1.7.1.tar.gz htop-1.0.2.tar.gz pip-1.5.4.tar.gz Test


This article is from the "Zhao Dongwei blog" blog, make sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1870204

Linux Command Learning 1

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.