One Linux command per day (2): ls command

Source: Internet
Author: User
Tags parent directory

Copyright notice

Updated: 2017-04-26
Bo Master: Luckyalan
Contact: [Email protected]
Statement: Draft not forget to dig well man, reproduced please indicate the source!

1 Article Introduction
This article describes the Linux under command LS.

2 Development Platform
Scanning development Platform

3 Pre-reading instructions
Tips, such as pre-known knowledge, which blogs need to be read first

4 Article body
LS (list segment, list split) is used to list files and is a command that is governed by the POSIX and single UNIX standards. We can use the LS command:

    • Print a list of files or folders in the current directory
    • List of files or folders in the specified directory
    • View permissions, directory information, and so on for files, folders, file directories, and more

4.1 Command format

1 LS [options] [directory name]

4.2 Command functions

View information such as file or file permissions.

4.3 Common parameters

LS If you omit the command arguments and manipulate the object and enter "LS" directly, the contents list of the current working directory is listed as follows:

4.3.1 Show All-a/-a/-all

-a,–all lists all files under the directory, including the. The implied file at the beginning. Where-all has detailed information containing the privileges in the inland. and parameter-A does not list "." (represents the current directory) and ".." (Represents the parent directory of the current directory). As shown in the following three pictures:

4.3.2 file sort Show-C

With-L, sorted by file name, display CTime (file status last changed time sorting and display):

With-lt, according to CTime sort, display CTime:

4.3.3 Verbose Display-l

In addition to file names, the file's permissions, owner, file size, and more are listed in detail:

4.3.4 Display File Size-human

Show size in a way that humans can see (corresponding to the size of the-SI display), note that the following may also be used with ls-h-human:

4.4.5 Other Commands

-T sorted by file modification time
-V Sort by version
-X list items line by row instead of columns by column
-x Sort by extension
-1 Only one file per line (note that there is no ls-2, only-1)
Help display this help message and leave
–version display version information and leave

4.5 Common examples

When using the LS command, pay attention to the format of the command: At the command prompt, the first is the command keyword, followed by the command parameters, before the command parameters to have a short line "-", all the command parameters have a specific role, you can choose one or more parameters according to the need, After the command argument is the action object of the command.

4.5.1 listing the details of all files and directories under the specified folder

Ls-l-r/home/parallels/

Keyword: ls
Parameter:-l-r
Action object:/home/parallels/

We can also write the following form:

Ls-l-r/home/parallels/

If the operation object of the command is in the current directory, the Operation object can be manipulated directly, if it is not in the current directory, the full path of the action object needs to be given. For this example, if the Parrallels folder is in the home folder, we can use it directly:

LS-LR parallels

4.5.2 lists the details of all directories in the current directory that begin with "T"

Ls-l t*

Note that the details of the files in the folder starting with T are listed here instead of the names of the folders that start with the header.

4.5.3 lists only subdirectories under folders

List the subdirectories under the/home/parallels Directory (folder):

Ls-f/home/parallels |grep/$

List the details of subdirectories under the/home/parralels directory:

" ^d "

5 References
1, the concept of this part of the reference to Wikipedia.

One Linux command per day (2): 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.