Linux Common shell command ls

Source: Internet
Author: User

ls: View file name and directory, usage: $ ls [option]

1. $ ls

Enter the LS command directly, listing all files and directories in the current directory, without displaying details such as type, size, date permissions, and so on.

2. $ ls-l

The-l option displays a record for each row, displaying file and directory information in a long list, including file type, size, date and time of modification, permissions, users and groups to which they belong.

As shown below:

D Rwxr-xr-x 2 userName groupName 4096 Sep 10:51 Desktop
Drwxr-xr-x 2 userName groupName 4096 Jul 2 07:47 Documents
Drwxr-xr-x 2 userName groupName 4096 Jul 2 07:47 Downloads

-rw-rw-r--1 userName groupName 0 Sep 11:43 hello.txt

The above output has 7 fields per line and each field has a different meaning:

Field 1: File types and permissions. The first character indicates the type of file, in particular: D: directory;-: normal file; s: Socket file; L: Link file

Rwxr-xr-x represents the permissions for the file.

Field 2: Number of links. 1 indicates that only one file is linked to this file

Field 3: Owner

Field 4: User groups

Field 5: File size, Unit bytes

Field 6: Date The file was last modified

Field 7: File name

3. $ ls-lh

The-LH option displays the file size as a form that conforms to the usual reading habits, such as:

Drwxr-xr-x 2 Lipan lipan 4.0K Sep 10:51 Desktop

4. $ ls-f

-F option to categorize different file types with different special characters

init/linux-sound-base/ufw/
klibc-p2s_k-gf23vtrggo2_4pgkqgwmy.so* lsb/x86_64-linux-gnu/
[Email protected] Modprobe.d/xtables/hello.txt

/: Indicates directory

@: Indicates a linked file

*: Represents an executable file

None: Indicates normal file

5. $ ls-r

-r option to recursively list the contents of a directory

6. $ ls-ls

-ls option to list files and directories in file size order in long list format (descending order)

7. $ ls-a

-A option to list all files and directories including hidden files or directories, including "." (current directory) and ".." (Parent directory)

8. $ ls-a

-A option to list all files and directories, including hidden files or directories, excluding "." (current directory) and ".." (Parent directory)

9. $ ls-n

-n option, output similar to-l option, but use UID and GID instead of owner and user group

Linux Common shell command ls

Related Article

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.