Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How CentOS uses the ls command to view files and directories

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you how to use ls command to view files and directories in CentOS. I think it's very practical, so I share it with you. The following is how to use the ls command.

In terminal mode, linux provides powerful command capabilities.

Command execution format: Command [Options] Parameter 1 Parameter 2 ……

Linux command formats are case-sensitive compared to Windows; when commands are too long, you can use a backslash (\) to escape the Enter key.

When options are added, they are usually preceded by a-sign, such as ls -h ; when options are fully named, they are preceded by a--character, such as ls --help (to show help for ls commands).

The ls command is used to display information about files or directories, equivalent to dir under Windows. Its command format is:

ls [options] directory or file name

Functions of options and parameters:

-a: All files, including hidden files (beginning with. List them together (usually)

-A: All files, including hidden files, but excluding. With... both directories

-d: List only the directory itself, not the file data within the directory (common)

-f: List results without sorting (ls sorts by filename by default!)

-F: Additional data structures are given based on information such as files, directories, etc., for example:

*: Represents cocoa execution file; /: Represents directory; =: Represents socket file;|: Represents FIFO file;

-h: List file sizes in a readable manner (e.g. GB, KB, etc.);

-i: List inode numbers, the meaning of inode will be described in the next chapter;

-l: long data serial output, containing file attributes and permissions and other data;(commonly used)

-n: List UID and GID instead of user and group names (UID and GID are mentioned in Account Management!)

-r: reverse the sorting results, for example: the original file name from small to large, reverse is from large to small;

-R: listed together with the contents of the subdirectory, which means that all files under the directory will be displayed;

-S: Sort by file size, not by file name;

-t: Sort by time, not by file name.

--color=never: Do not give color display based on file characteristics;

--color=always: show color

--color=auto: Let the system determine whether to give color according to its own settings

--full-time: output in full time mode (including year, month, day, hour and minute)

--time={atime,ctime}: Output access time or permission attribute change time (ctime) instead of content modification time

1. ls /Display the contents of the root directory

2, ls -a Display all contents of the current directory (including. .. Catalogues and with. hidden files at the beginning)

ls -A Displays all contents of the current directory (excluding. .. Contents, but containing the words. hidden files at the beginning)

4. ls -al Detailed output file or directory information

Each file or directory has one line, and each line is divided into seven parts.

The first part represents file types and permissions.- rw------: The first digit represents the file type (see CentOS Learning Notes III: Introduction to Files and Directories from the Heart for details); each of the following three digits is a group, each group represents the permission of the owner, the group to which it belongs, and others; the three digits of each group are rwx, which represents read, write (change content), and execute permissions, respectively. If-, it means that there is no corresponding permission.

The second part represents the number of files

The third part represents the owner.

The fourth part represents the group to which it belongs

The fifth part represents the file size, which defaults to bytes.

The sixth part is the content modification time

The seventh part is the file name

5. ls -alh (-h displays file size in KB, GB in legible fashion). - The h parameter is used in many commands, such as du and df.

6. ls -alhR (-R: stands for listed with the contents under the subdirectory)

7. ls -aln (-n: indicates to display user and group information with ID number, 0 indicates root user and root group)

8. ls -al --full-time (--full-time: represents output in full format)

ls -al --time=atime (atime represents the last time the contents of the file were read)

ls -al --time=ctime (ctime represents the last time the file permission attribute was modified)

Default: represents the last time the file content was modified

In the following figure: touch test: indicates the creation of a test file;

chmod 777: Indicates permission to modify files

echt "1111" >> test: means to add 1111 content to the end of the file.

Execute multiple commands on the same line in turn, with intervals between commands, linux executed in turn.

10, ls -alhS (-S: stands for file size sorting)

ls -alt --full-time (-t: stands for

The above is how to use the ls command, the detailed use of the situation also have to be used by everyone to know the specific essentials. If you want to read more articles related to content, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report