Operations 7 min read

Mastering ls -lrt: List Files by Modification Time on Linux

This guide explains how the ls -lrt command works, breaks down its -l, -r, and -t options, shows example outputs, and demonstrates how to sort directory listings by time, making file management in Linux faster and more efficient.

Open Source Linux
Open Source Linux
Open Source Linux
Mastering ls -lrt: List Files by Modification Time on Linux

As software developers or testers we often use the ls -lrt command, especially when dealing with a large number of files.

In fact, it is just the ls command with the -lrt options.

If you are not familiar with this command, you are probably new to Linux or do not use Linux commands often.

We will introduce this command now.

Purpose of the ls -lrt command

The ls command lists directory contents, and lrt is a combination of three options:

l : displays a long listing with file permissions, owner, size, creation time, etc.

t : sorts the output by time.

r : reverses the order of the listing.

When combined, ls -lrt shows the current directory’s contents sorted by time, with the newest files appearing at the bottom.

The order of the options does not matter; ls -lrt and ls -ltr produce the same result.

Example outputs

Default ls (alphabetical order):

[email protected]:~/Apps$ ls
balenaEtcher-1.5.116-x64.AppImage  pcloud
cpufetch                           PenguinSubtitlePlayer-Linux
Obsidian-0.13.19.AppImage          ScreenCloud-v1.5.3-x86_64.AppImage

Long format ls -l (still alphabetical):

[email protected]:~/Apps$ ls -l
total 304804
-rwxr-xr-x 1 abhishek abhishek 89697412 Feb  3  2021 balenaEtcher-1.5.116-x64.AppImage
drwxr-xr-x 6 abhishek abhishek     4096 Jul 23  2021 cpufetch
-rwxr-xr-x 1 abhishek abhishek 90800704 Jan 24 11:05 Obsidian-0.13.19.AppImage
-rwxr-xr-x 1 abhishek abhishek 57430439 Mar 17 07:52 pcloud
drwxr-xr-x 2 abhishek abhishek     4096 Mar 20  2021 PenguinSubtitlePlayer-Linux
-rwxr-xr-x 1 abhishek abhishek 74170408 Feb 13 20:26 ScreenCloud-v1.5.3-x86_64.AppImage

Sorted by time ls -lt (newest at top):

[email protected]:~/Apps$ ls -lt
total 304804
-rwxr-xr-x 1 abhishek abhishek 57430439 Mar 17 07:52 pcloud
-rwxr-xr-x 1 abhishek abhishek 74170408 Feb 13 20:26 ScreenCloud-v1.5.3-x86_64.AppImage
-rwxr-xr-x 1 abhishek abhishek 90800704 Jan 24 11:05 Obsidian-0.13.19.AppImage
drwxr-xr-x 6 abhishek abhishek     4096 Jul 23  2021 cpufetch
drwxr-xr-x 2 abhishek abhishek     4096 Mar 20  2021 PenguinSubtitlePlayer-Linux
-rwxr-xr-x 1 abhishek abhishek 89697412 Feb  3  2021 balenaEtcher-1.5.116-x64.AppImage

Using the r option to reverse the order, ls -lrt shows the newest files at the bottom:

[email protected]:~/Apps$ ls -lrt
total 304804
-rwxr-xr-x 1 abhishek abhishek 89697412 Feb  3  2021 balenaEtcher-1.5.116-x64.AppImage
drwxr-xr-x 2 abhishek abhishek     4096 Mar 20  2021 PenguinSubtitlePlayer-Linux
drwxr-xr-x 6 abhishek abhishek     4096 Jul 23  2021 cpufetch
-rwxr-xr-x 1 abhishek abhishek 90800704 Jan 24 11:05 Obsidian-0.13.19.AppImage
-rwxr-xr-x 1 abhishek abhishek 74170408 Feb 13 20:26 ScreenCloud-v1.5.3-x86_64.AppImage
-rwxr-xr-x 1 abhishek abhishek 57430439 Mar 17 07:52 pcloud

When the directory contains many files, using -lt or -lrt helps you quickly locate the most recently modified files without scrolling.

Source: TIAP
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxfile-managementcommand-linels
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.