Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the ls command in linux to display the content and attribute information under the specified working directory

Shulou Source: shulou.com Published: 2022-06-02 18:40:34 09月21日 Update

This article mainly introduces the use of linux ls command to display the content and attribute information under the specified working directory, the article is very detailed, has a certain reference value, interested friends must read it!

The ls command is one of the most commonly used instructions under Linux. The ls command is an abbreviation for the English word list, just as the English word list means. Its function is to list the contents of the specified directory and their related attribute information.

By default, the ls command lists the contents of the current directory. With parameters, we can do more with ls. As the most basic and frequently used command, it is necessary for us to figure out the usage of the ls command, so let's take a look!

Syntax format: ls [options] [file]

Common parameters:

-a displays all files and directories (including "." Hidden files at the beginning)-l lists files and directory information in a long format-r displays files in reverse order (default in English alphabetical order)-t sorts according to the last modification time-An is the same as-a, but does not list "." (current directory) and ".." (parent directory)-S sorts by file size-R recursively lists all subdirectories

Reference example

List all files (including hidden files):

[root@linuxcool] # ls-a

List the details of the file:

[root@linuxcool ~] # ls-l

List all directories under the root directory (/):

[root@linuxcool ~] # ls /

List all files in the current working directory whose names begin with "s":

[root@linuxcool] # ls-ltr s*

List details of all directories and files under the / bin directory:

[root@linuxcool ~] # ls-lR / bin

List all files and directories under the current working directory and sort by file size:

[root@linuxcool ~] # ls-AS above is to use the ls command in linux to display the contents and attribute information under the specified working directory. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Directories files commands information content work attributes English sorting words parameters size common use beginning more format order reference necessary next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB vpn Shulou Technology Linux