Linux commands (2) LS

Source: Internet
Author: User
Tags sorts

1. command format

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

2. Command function

List all subdirectories and files in the destination directory

3. Command Parameters

- A lists all files under the directory, including the. the implied file at the beginning.

-B lists the characters that are not output in the file name in the form of a backslash and a character number (as in the C language ) .

-C The modified time of the I node of the output file and sorted by this.

-D Displays the directory as if it were a file, rather than displaying the file below it.

-e Outputs the full information of the time, not the output of the brief information.

-f-u the output file is not sorted.

-G useless.

-I index information for the I node of the output file .

- k represents the size of a file in the form of a byte.

-L lists the file details.

-m output file name horizontally and "," as a separator.

-N replaces the name with the uid,gid of the number .

-O displays detailed information about the file in addition to the group information.

-p-f a character after each file name to indicate the type of the file,"*" means an executable plain file;"/" means a directory;"@" denotes a symbolic link;"|" represents FIFOs;"=" means socket (sockets).

Q- use ? instead of characters that cannot be exported.

-R sorts the directory backwards.

-S prints the size of the file after each file name.

-T is sorted by time.

-U Sorts the time the file was last accessed.

-X output by column, sorted horizontally.

-a displays except for "." and ".." all files outside the file.

-B does not output backup files ending with "~".

-C output by column, sorted vertically.

-G output file for the group information.

-L lists the link file name instead of the file that is linked to.

-n does not limit file length.

-Q Enclose the file name of the output in double quotation marks.

-R Lists all the files under subdirectories.

-S is sorted by file size.

-X to the file's extension (the last one .) after the character ) sort.

-1 rows only output one file.

--color=no do not display color file names

The--HELP displays help information on the standard output.

the--version outputs the version information on the standard output and exits.

4. Command Instances

Example 1: no parameter query

[[email protected] ~]# ls

Anaconda-ks.cfg Install.log Install.log.syslog

Example 2: Show whether it is a file or a directory, its size, date and time of modification, the name of the file or directory, and the owner of the file and its permissions

[Email protected]/]# ls-l

Total 90

Dr-xr-xr-x. 2 root root 4096 Jul 19:24 bin

Dr-xr-xr-x. 5 root root 8 19:19 boot

Drwxr-xr-x. Root root 3700 Jul 03:46 Dev

Drwxr-xr-x. 03:46 root root 4096 Jul etc

Drwxr-xr-x. 2 root root 4096 Sep Home

Dr-xr-xr-x. Root root 4096 Jul 19:24 Lib

Dr-xr-xr-x. 9 root root 12288 Jul 19:24 lib64

DRWX------. 2 root root 16384 Jul 8 19:10lost+found

Drwxr-xr-x. 2 root root 4096 Sep media

Drwxr-xr-x. 2 root root 4096 Sep mnt

Drwxr-xr-x. 3 root root 4096 Jul 8 19:16 opt

Dr-xr-xr-x. 03:46 root root 0 Jul proc

Dr-xr-x---. 2 root root 4096 Jul 04:51root

Dr-xr-xr-x. 2 root root 12288 Jul 19:24 sbin

Drwxr-xr-x. 7 root root 0 Jul 03:46selinux

Drwxr-xr-x. 2 root root 4096 Sep (SRV)

Drwxr-xr-x. Root root 0Jul 03:46 sys

DRWXRWXRWT. 3 root root 4096 Jul 04:24 tmp

Drwxr-xr-x. Root root 4096 Jul 8 19:12 usr

Drwxr-xr-x. Root root 4096 Jul 8 19:16 var

Example 3: List all files including the '. ' the hidden file at the beginning.

[Email protected]/]# ls-a

. . autofsck Boot etc lib lost+found mnt proc sbin SRV tmp var

.. Bin Dev Home lib64 media opt root selinux sys usr

Example 4 : The file is serialized out.

[Email protected]/]# Ls-r

var tmp srv sbin proc mnt lost+found lib etc boot

USR sys selinux Root opt media lib64 home Dev Bin

[[email protected]/]# ls

Bin Dev Home lib64 media opt root selinux sys usr

Boot etc lib Lost+found mnt proc sbin SRV tmp var

Example 5: Display them in the order of the most recent modification time of the file or directory.

[Email protected]/]# ls-ltr

Total 90

Drwxr-xr-x. 2 root root 4096 Sep (SRV)

Drwxr-xr-x. 2 root root 4096 Sep mnt

Drwxr-xr-x. 2 root root 4096 Sep media

Drwxr-xr-x. 2 root root 4096 Sep Home

DRWX------. 2 root root 16384 Jul 8 19:10lost+found

Drwxr-xr-x. Root root 4096 Jul 8 19:12 usr

Drwxr-xr-x. Root root 4096 Jul 8 19:16 var

Drwxr-xr-x. 3 root root 4096 Jul 8 19:16 opt

Dr-xr-xr-x. 5 root root 8 19:19 boot

Dr-xr-xr-x. Root root 4096 Jul 19:24 Lib

Dr-xr-xr-x. 9 root root 12288 Jul 19:24 lib64

Dr-xr-xr-x. 2 root root 4096 Jul 19:24 bin

Dr-xr-xr-x. 2 root root 12288 Jul 19:24 sbin

Dr-xr-xr-x. 03:46 root root 0 Jul proc

Drwxr-xr-x. Root root 0 Jul 03:46 sys

Drwxr-xr-x. 7 root root 0 Jul 03:46selinux

Drwxr-xr-x. 03:46 root root 4096 Jul etc

Drwxr-xr-x. Root root 3700 Jul 03:46 Dev

DRWXRWXRWT. 3 root root 4096 Jul 04:24 tmp

Dr-xr-x---. 2 root root 4096 Jul 04:51root

Reference:http://os.51cto.com/art/201503/469602.htm


Linux commands (2) 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.