Linux Base command (1) LS command

Source: Internet
Author: User
Tags file size file system parent directory file permissions

The LS command is the most commonly used command under Linux. ls command is the abbreviation of List  save LS used to print out the list of the current directory  if LS specifies a different directory  then the list of files and folders in the specified directory is displayed. The LS command allows you to view not only the files contained in the Linux folder  but also the file permissions (including directories, folders, file permissions)  view directory information, and so on. The LS command is used a lot in everyday Linux operations!

1. Command format:

ls [options] [directory name]

2. Command function:

Lists all subdirectories and files in the destination directory.

3. Common parameters:

-a,–all lists all the files in the directory, including the. Implied file at the beginning

-A with-a, but does not list "." (represents the current directory) and ".." (Represents the parent directory of the current directory).

-C with-lt: According to CTime sorting and display CTime (file state last changed time) with-L: Show CTime but sort by name otherwise: Sort by ctime

-c Each column lists items from top to bottom

–color[=when] Controls whether color-resolved files are used. When it can be ' never ', ' always ' or ' auto ' one of them

-d,–directory Displays the directory as a file, rather than displaying the file under it.

-d,–dired produces results that are used in dired mode for Emacs

-F does not sort the output file, the-au option is in effect, and the-LST option is invalid

-G is similar to-l but does not list owners

-g,–no-group does not list any information about the group

-h,–human-readable the file size in an Easy-to-understand format (for example, 1K 234M 2G)

–si is similar to-H, but the file size takes 1000 of the second party instead of 1024

-h,–dereference-command-line Use the symbolic link in the command column to indicate the true destination

–indicator-style= Specifies the indicator < mode after each project name: None (Default), classify (-f), File-type (-P)

-i,–inode Prints the inode number of each file

-i,–ignore= style does not print any items that conform to Shell Universal characters < style >

-K is –block-size=1k, representing the size of the file in K-byte form.

-l details the permissions, owner, file size, and so on for the file, in addition to the filename.

-l,–dereference displays the object indicated by the symbolic link rather than the symbolic link itself when displaying the file information for the symbolic link

-m all items are separated by commas and fill the entire line of line width

-O, similar to-l, displays details of the file except for group information.

-r,–reverse in reverse order

-r,–recursive Lists all subdirectory layers at the same time

-s,–size lists the size of all files in block size

-s sort by file size

–sort=word The following are the optional WORD and the appropriate options they represent:

Extension-x status-c

None-u time-t

Size-s Atime-u

Time-t Access-u

Version-v Use-u

-T to sort by file modification time

-U match-LT: Show access time and sort by access time

With-L: Show access time but sort by name

Otherwise: Sort by access time

-U does not sort; Lists items according to the original order of the file system

-V sorting based on version

-w,–width=cols to specify screen width without using current values

-X list items line by row instead of column

-x Sort by extension

-1 lists only one file per line

–HELP Display this help information and leave

–version display version information and leave

4. Common examples:

Example one: List details of all files and directories under the/home/peidachang folder

Command: Ls-l-r/home/peidachang

Pay attention to the format of the command when using the LS command: At the command prompt, the first is the command keyword, followed by the command arguments, preceded by a dash "-", all the command arguments have a specific effect, and you can select one or more parameters, depending on your needs, After the command parameter is the action object for the command. In the above command "Ls-l-r/home/peidachang", "LS" is the command keyword, "-l-r" is the parameter, "/home/peidachang" is the action object of the command. In this command, two parameters are used, "L" and "R", and of course, you can put them together as follows:

Command: Ls-lr/home/peidachang

This form is exactly the same as the result of the command form above. In addition, if the command's action object is in the current directory, you can manipulate the action object directly, if you do not need to give the full path to the action object in the current directory, for example, in the example above, my current folder is the Peidachang folder, and I want to Peidachang File to operate, I can directly input LS-LR Peidachang, also can use Ls-lr/home/peidachang.

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.