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

CentOS learning notes from the heart part IV: view files and directories command ls

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

View files and directories command ls

In terminal mode, linux provides a powerful command function.

Command execution format: command [options] Parameter 1, Parameter 2.

It is case-sensitive compared to Windows,linux 's command format; when the command is too long, you can use a backslash (\) to escape the carriage return key.

When adding an option, the option is usually preceded by a-sign, such as ls-h; when the option uses the full name, the option is preceded by-- characters such as ls-- help (displays the help of the ls command)

The action of the ls command is to display the information of a file or directory, which is equivalent to dir under Windows. The command format is:

Ls [options] directory or file name

Functions of options and parameters:

-a: all files, along with hidden files (beginning with. Listed together (commonly used)

-A: all files, along with hidden files, but not included. With; with. These two directories

-d: list only the directory itself, not the file data in the directory (commonly used)

-f: list the results directly without sorting (ls sorts by file name by default! )

-F: give additional data structures based on files, directories, etc., such as:

*: represents cocoa executable file; /: represents directory; =: represents socket file; |: represents FIFO file

-h: list the file size in an easy-to-read way (such as GB, KB, etc.)

-I: list the inode number. The meaning of inode will be described in the next chapter.

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

-n: list UID and GID instead of user and group names (UID and GID will be mentioned in account management! )

-r: output the sort result in reverse, for example, the original file name is from small to large, and the reverse is from large to small.

-R: if it is listed together with the contents of the subdirectory, all the files in that 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 properties

-- color=always: display color

-- color=auto: let the system decide whether or not to give colors according to the settings

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

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

1. Ls / display the contents of the root directory

2. Ls-a displays all the contents of the current directory (including. .. Catalogue and. Hidden file at the beginning)

3. Ls-A displays all the contents of the current directory (excluding. .. Table of contents, but contains. Hidden file at the beginning)

4. Ls-al detailed output file or directory information

One line for each file or directory, and each line is divided into seven parts.

The first part represents the file type and permissions.-the first bit of rw-: represents the file type (for details, see CentOS Learning Notes III from the heart: file and directory introduction); the latter three are a group, each group represents the permissions of the owner, the group to which it belongs, and others; the three permissions of each group are rwx, representing read, write (change content) and execution permissions respectively.

The second part represents the number of documents

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 shows the file size by kb and gb in an easy-to-read way). The-h parameter is used in many commands, such as du, df

6. Ls-alhR (- R: it is listed together with the contents in the subdirectory)

7. Ls-aln (- n: displays the information of users and groups with ID numbers, and 0 represents root users and root groups)

8. Ls-al-- full-time (--full-time: represents output in full format, year, month, day and time)

9. 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 time when the contents of the file were last modified

In the following figure: touch test: indicates the establishment of a test file

Chmod 777: means to modify file permissions

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

Execute multiple commands in turn on the same line, between commands; interval, linux execution in turn.

10. Ls-alhS (- S: sort on behalf of file size)

11. Ls-alt-- full-time (- t: representative

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