Detailed Explanation of the Output from ‘ls -l’ in Linux

In the Jiangsu Province Computer Major Transfer Examination, the scope of Linux command assessment is clear, and the difficulty and depth of the professional course assessments are increasing year by year. It is essential to master important concepts in Linux.

The output of the <span>ls -l</span> command is a key focus, and below, Uncle Aries provides a detailed analysis of a sample output line, explaining its meaning column by column.

-rw-r--r--.   1 root root      163 2月  27 2022 .updated

1. File Type and Permissions (First Column)

-rw-r–r–.

First Character: Indicates the file type

    • <span><span>-</span></span> → Regular file

    • <span><span>d</span></span> → Directory

    • <span><span>l</span></span> → Symbolic link

The next 9 characters: Permissions, divided into 3 groups, each with three characters

    • File Owner (u):<span>rw-</span> → Read + Write

    • Group (g):<span>r--</span> → Read only

    • Other Users (o):<span>r--</span> → Read only

The final <span>.</span> indicates the presence of SELinux security context (common in CentOS systems)

2. Number of Hard Links (Second Column)

1
  • The number of hard links to the file, which is usually <span>1</span>

  • The number of hard links for a directory is ≥ 2 (itself + reference to subdirectory <span>..</span>)

3. File Owner and Group (Third and Fourth Columns)

root root
  • Third Column: File Owner → <span>root</span>

  • Fourth Column: File Group → <span>root</span>

4. File Size (Fifth Column)

163
  • The unit is bytes

  • Indicates that the size of the <span>.updated</span> file is 163 bytes

5. Modification Time (Sixth to Eighth Columns)

2月 27 2022
  • The last modification time of the file

  • Month + Day + Year (or Hour:Minute, if it is the current year)

6. File Name (Ninth Column)

.updated
  • File name

  • Starts with a dot → Hidden file

  • Hidden files do not show under a regular <span>ls</span> command; you need to use <span>ls -a</span> to see them

Summary

Column Meaning
-rw-r–r–. File type + permissions + SELinux
1 Number of hard links
root File owner
root File group
163 File size (bytes)
2月 27 2022 Last modification time
.updated File name (hidden file)

Detailed Explanation of the Output from 'ls -l' in Linux

Leave a Comment