Linux ls command

Source: Internet
Author: User

Ls

Displays a list of directory contents, and the output information can be highlighted in color highlighting to partition different types of files.

Grammar:

Touch [ options ] [ parameters ]

options

explanation

example

-a--all

Displays all files, including ".

Ls–a/ show All files under the root

-l

long format display

Ls–l Show file properties

-h

with 1024


-d

show current directory

ls–d/tmp

-t

sorted by modified time, default from near to far

Ls–t/

-R

reverse, often with -t use

Ls–tr/

-C

fit -lt according to CTime (File access time Access)


-G

does not list any information about the group


-F

directory plus identity

(different files and different identities)

-P

directory plus identity

add to directory only /




Instance:

[[email protected] test]# ls–a # Show all, including hidden files

.  .. Dir1 dir2 dir3 file1 file2 file3

[[email protected] test]# ls-l/ll # long format display

Total 12

Drwxr-xr-x 2 root root 4096 Mar 14:23 Dir1

Drwxr-xr-x 2 root root 4096 Mar 14:23 Dir2

[[email protected] test]# ll–h # Show file size in K,M,G

Total 12K

Drwxr-xr-x 2 root root 4.0K Mar 14:23 dir1

Drwxr-xr-x 2 root root 4.0K Mar 14:23 Dir2

[[email protected] test]# touch-m file1-d "20180311" # Modify Change Time

[[email protected] test]# touch-m file2-d "20180312" # Modify Change Time

[[email protected] test]# ll–t # According to the modified time to sort, from near to far, by default is modified by the time

Total 0

-rw-r--r--1 root root 0 Mar 00:00 file2

-rw-r--r--1 root root 0 Mar 00:00 file1

[[email protected] test]# ll–tr #-r reverse, usually with a- t use

Total 0

-rw-r--r--1 root root 0 Mar 00:00 file1

-rw-r--r--1 root root 0 Mar 00:00 file2

[[email protected] test]# ll-d/test/ # Show only the properties of the current file or directory

Drwxr-xr-x 6 root root 4096 Mar 14:42/test/

[[email protected] test]# touch-a file2-d "20180313" # Modify Access Time

[[email protected] test]# touch-a file1-d "20180314" # Modify Access Time

[[email protected] test]# LL-TC # sorted by file access time

Total 0

-rw-r--r--1 root root 0 Mar 14:47 file1

-rw-r--r--1 root root 0 Mar 14:47 file2

[email protected] test]# stat file2 View Status

File: ' File2 '

size:0 blocks:0 IO block:4096 Regular empty file

device:fd00h/64768d inode:521236 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

ACCESS:2018-03-13 00:00:00.000000000-0400

Modify:2018-03-12 00:00:00.000000000-0400

Change:2018-03-19 14:47:13.681005838-0400

[Email protected] test]# stat file1

File: ' File1 '

size:0 blocks:0 IO block:4096 Regular empty file

device:fd00h/64768d inode:521234 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

Access:2018-03-14 00:00:00.000000000-0400

Modify:2018-03-11 00:00:00.000000000-0500

Change:2018-03-19 14:47:19.547994463-0400

[[email protected] test]# ll-d/test/ # Show only the properties of the current directory

Drwxr-xr-x 6 root root 4096 Mar 14:42/test/

[[email protected] test]# ll-gd/test/ # does not display the information of the genus Group

Drwxr-xr-x 6 root 4096 Mar 14:42/test/

Long format Display Description:

-rw-r-r--. 1 root root 0 Mar 16:18 1.sh

First: Represents the type of the file,- represents the file, D represents the directory,l represents the linked file,

back 9 bits: Each 3 bits represent, belong to the master, belong to the group, other people's rights,R Read,w Write,x Execute, respectively represent 421

1: The delegates were linked several times

Root: Owner

Root: belong to group

0 : Represent size, unit bits

Mar 16:18 represents the last modified time

[[email protected] test] #ls--color=auto # with color display

[[email protected] test]# ls-f # Add a logo to the directory (different files may be added differently)

Dir1/dir2/dir3/file file1 file2 file3 test/

[[email protected] test]# ls–p # Add "/" to the directory only

Dir1/dir2/dir3/file file1 file2 file3 test/


Linux 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.