Skip to main content

Understanding the Long Format of the ls Command in Linux

The ls command is one of the most commonly used commands in the Linux terminal. It lists files and directories in a directory. By default, it shows a simple list, but you can view more information about each file or directory by using the long format. This article will explain how to generate a long-format output and what each section of this output means.

1. Command Structure for Long Format Output

To generate a long-format listing of files and directories in a terminal, you can use the following command:

ls -l

Here, the -l option specifies that the output should be in long format. You can also combine it with other options, like so:

ls -la # shows all files, including hidden files, in long format

2. Sample Long Format Output

When you run ls -l, you will see output similar to the following:

-rw-r--r-- 1 root root 27837 2017-04-03 11:05 oo-maxwell.odt
drwxr-xr-x 2 user user 4096 2021-09-12 18:24 Documents

3. Explaining Each Section of the Long Format

SectionExample ValueDescription
File Type and Permissions-rw-r--r--Indicates the type of file and its permissions.
Number of Links1Shows the number of hard links to the file or directory.
OwnerrootThe user who owns the file or directory.
GrouprootThe group associated with the file or directory.
File Size27837Size of the file in bytes.
Modification Date and Time2017-04-03 11:05When the file or directory was last modified.
File or Directory Nameoo-maxwell.odtThe name of the file or directory.

Detailed Explanation of Each Section:

  • -rw-r--r--:

    • The first character indicates the type of file (- for regular files, d for directories, l for symbolic links, etc.)
    • The next nine characters represent permissions for the owner, group, and others. In this example, rw- means the owner has read and write permissions but not execute. r-- means the group and others have only read permission.
  • 1: This is the number of hard links to the file or directory.

  • root: This is the username of the owner of the file or directory.

  • root: This indicates the group that the file or directory belongs to. In this case, it belongs to the root group.

  • 27837: This is the file size in bytes.

  • 2017-04-03 11:05: This is the last modification date and time of the file or directory.

  • oo-maxwell.odt: This is the name of the file or directory.

Understanding the long format of the ls command in Linux is important for both beginners and experienced users, as it provides comprehensive details about files and directories, helping in effective system management and file manipulation.

TypeScript Course Instructor Image
TypeScript Course Instructor Image

Time To Transition From JavaScript To TypeScript

Level Up Your TypeScript And Object Oriented Programming Skills. The only complete TypeScript course on the marketplace you building TypeScript apps like a PRO.

SEE COURSE DETAILS

What Can You Do Next 🙏😊

If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for ssoftware developers.

YouTube @cloudaffle