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.
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.AppImageLong 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.AppImageSorted 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.AppImageUsing 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 pcloudWhen the directory contains many files, using -lt or -lrt helps you quickly locate the most recently modified files without scrolling.
Source: TIAP
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
