[Command tips] ls

Source: Internet
Author: User

Address: http://www.dutor.net/index.php/2010/06/cmd-ls/

[Command tips] ls

Ls = List: lists information about a specified directory or file based on different options. It is one of the most common commands in Unix/Linux, CD to a directory and then run the first command.

Ls

Ls without parameters lists the files and directories in the current directory, ls folder lists the files and subdirectories in the folder, and LS file displays the file information (the default is the file name ).

123456789
Dutor @ Dutor-desktop :~ $ CD Wdir/  / Home / Dutor / Wdirdutor @ Dutor-desktop :~ / Wdir $ Ls Apue asm cpp latex PHP Python QT shelldutor @ Dutor-desktop :~ / Wdir $ Ls CPP/ ACM main. cpp makefile pthread symtab tags test. scurses main. C main. s playaround STL systemprogram test. c tutmanualdutor @ Dutor-desktop :~ / Wdir $ Ls CPP / Makefilecpp / Makefile
Ls-

-Option A is the same as LS, But it lists all the files in the current directory or specified directory, including the files starting with dot (.),. directory, and. directory.

 12 
Dutor@Dutor-desktop :~/Wdir $Ls -... Apue asm cpp. I2C. C. SWP latex PHP Python QT Shell
Ls-

-Option A is the same as LS, but lists all files in the current directory or specified directory, including files starting with dot (.), but not the. Directory and. directory.

 12 
Dutor@Dutor-desktop :~/Wdir $Ls -Apue asm cpp. I2C. C. SWP latex PHP Python QT Shell
Ls-l

The-L option LS command lists the detailed analysis information of files or subdirectories in the current directory or specified directory.

12345678910
Dutor @ Dutor-desktop :~ / Wdir / CPP / STL $ Ls   -L Total 32 Drwxr-XR-x 2 Dutor 4096   2010 -04- 19   19 : 25 Bind2nd -RW-r --   1 Dutor 1296   2010 -03- 27   18 : 39 Heap. cpp-RW-r --   1 Dutor 980   2010 -03- 27   18 : 03 Kth-Max.cpp -RW-r --   1 Dutor 1168   2010 -04- 29   20 : 24 Main. cpp -RW-r --   1 Dutor 709   2010 -04- 20   17 : 58 Operator. cpp -RW-r --   1 Dutor 654   2010 -03- 27   17 : 40 Priority_queue.cpp -RW-r --   1 Dutor461   2010 -04- 10   22 : 41 Sort_list.cpp -RW-r --   1 Dutor 655   2010 -04- 29   21 : 18 Test. cpp

The LS-l information contains seven tabs:

  • First field: the first character specifies the file type

    • -: Common File;
    • D: directory file;
    • L: Symbolic Link;
    • S: Socket file;
    • B: Block devices;
    • C: character device;
    • P: MPS queue file.

    The following nine characters indicate the object access permissions. Each three characters indicate the permissions of a class of users, including the file owner, users in the same group, and other users. The permissions are divided into read (R), write (W), execute (X ).

  • Second domain: number of links. The normal file must be at least 1, and the directory must be at least 2 (... and ..);
  • Third domain: file owner;
  • Domain 4: User Group;
  • Field 5: file size. The directory size is usually an integer multiple of the block size;
  • Sixth domain: the last modification date and time of the file. Modifying the file means adding and modifying the files or subdirectories in the file;
  • Domain 7: File Name
Ls-T

List objects based on the file modification time. The last modification is before.

1234
Dutor@Dutor-desktop :~/Wdir $LsApue asm cpp latex PHP Python QT shelldutor@Dutor-desktop :~/Wdir $Ls -TCpp qt shell php asm latex apue Python
Ls-R

List objects in reverse order.

 123456 
Dutor@Dutor-desktop :~/Wdir $LsApue asm cpp latex PHP Python QT shelldutor@Dutor-desktop :~/Wdir $Ls -TCpp qt shell php asm latex apue pythondutor@Dutor-desktop :~/Wdir $Ls -TrPython apue latex asm php shell QT CPP
Ls-1

List objects in a single row.

Ls-F

Visual display file type.

 12 
$  ls  -F  desktop / events / Ubuntu-app @ firstfile music / Public / templates / 
    • /: Directory
    • Nothing: common file.
    • @: Symbolic Link file
    • *: Executable File
Ls-latr

That is to say, each option can be used in combination, except for mutually exclusive options, such as-a and-.

Use alias

It is more convenient to use alias. the alias defined by me include:

123
Alias Ll='LS-lH'Alias La='LS-'Alias L='LS-CF'

End

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.