Understanding ls -ltr command in Linux

Master ls -ltr Sorting: terminal listing files oldest to newest

You run ls, scan a crowded directory, and still cannot tell which file changed most recently. The ls -ltr command solves that in four characters of flags: it prints full details for every entry and sorts them so the oldest file sits at the top and the newest sits at the bottom, right above your next command.

The sections below cover what each flag contributes, how to read every column of the output, and the combinations that answer the questions you actually have: which file moved last, which entries are directories, and which file grew large. Every command shown here was executed on a current Linux system, and the screenshots come from those exact runs. If you need the broader option set first, start with how to use the ls command in Linux.

What Each Flag Does

The command stacks three independent options, and ls applies all of them in one pass.

FlagLong formJob
-l–format=longPrints one entry per line with permissions, owner, size, and timestamps
-t–timeSorts entries by modification time, newest first
-r–reverseReverses whatever sort is active

Order inside the flag cluster makes no difference, so ls -ltr and ls -lrt produce identical output. The default ls sort is alphabetical, and the manual states that any time-based or size-based sort replaces it only when you pass a flag like t, S, or u. That is why -t matters here: without it, -r would simply reverse alphabetical order.

Reading One Line of Output

Each row packs eight fields into a fixed layout. Here is one line from the test directory after running ls -ltr.

drwxrwxr-x 2 ubuntu ubuntu 4096 Aug 26 03:42 src
FieldValueMeaning
Type and permissionsdrwxrwxr-xd marks a directory, then owner, group, and other permissions
Hard links2Count of names pointing at this inode
OwnerubuntuUser who owns the entry
GroupubuntuGroup owner
Size4096Bytes on disk, 4 KB for a directory entry
Modification dateAug 26Month and day, or a year for older files
Time03:42Hour and minute for recent files
NamesrcFile or directory name

One detail trips people who read listings months later: ls switches from showing the time to showing the year once a file has not been touched for over half a year. If a listing shows Aug 25 instead of Aug 25 03:42, the file is old, not broken. The chmod and chown guide explains how to change the permission bits in the first field when you need to.

Running It on a Test Directory

Create a few files a minute apart, then list them.

echo "log line A" > app.log
echo "config v2" > app.conf
touch data.csv archive.tar.gz
mkdir src
sleep 61
echo "recent fix" > patch.log
ls -ltr
Terminal output of the ls -ltr command showing files sorted oldest to newest by modification time
ls -ltr lists every entry in long format, oldest first

patch.log lands last even though it was created last in the sequence, because the sleep pushed its modification time one minute past everything else. That bottom position is the whole point of the r flag: the file you most likely care about never requires scrolling.

See only the newest entries

Pipe the listing into tail when a directory holds hundreds of files and you only want the recent end.

ls -ltr | tail -5

tail -1 gives you exactly the single most recently modified entry. This pairing works well right after a build or deploy, when you want to confirm which artifacts actually changed.

Make sizes readable

Raw byte counts are precise but slow to compare. Adding h, for human-readable, scales them into K, M, and G units.

ls -ltrh
Output of ls -ltrh where file sizes appear in human readable units like K
Adding h turns raw byte counts into readable sizes

The 4096-byte directory entry becomes 4.0K. Nothing about the ordering changes, since h affects display only. When you need to trace where disk space actually goes rather than reading one directory, follow up with the tools in the CPU, disk, and memory usage guide.

List regular files only

Directories share the same listing as files, which clutters the view when you are hunting documents. The first character of every line encodes the type: a dash means a regular file and d means a directory. Filtering on that character removes the noise.

ls -ltr | grep ^-
Output of ls -ltr piped to grep so only regular files are listed
grep ^- filters directory entries out of the listing

The src directory disappears from the output while every file keeps its time order. The anchor ^ pins the match to the start of the line so filenames containing dashes cannot fool it. More filters like this live in the grep command tutorial.

Variations Worth Knowing

The same three flags combine with a few others to answer related questions.

CommandWhat changes
ls -ltNewest first instead of oldest first
ls -lrtaIncludes hidden dotfiles such as .bashrc
ls -ltrSSorts by size, largest last, ignoring time
ls -ltruSorts by access time instead of modification time
ls -ltr –full-timeShows seconds and the timezone for each timestamp

The u flag matters when a process reads many logs and you want evidence of activity rather than edits. Modification time changes only when file contents change, which is why it is the default choice for this sort.

Find Files Modified Today Without Parsing ls

Scripts that consume ls output break on spaces in filenames, because the listing was designed for people, not programs. When the goal is to act on recent files, use find, which emits raw paths one per line.

find . -maxdepth 1 -type f -mmin -60 -printf '%T@ %p\n' | sort -n

This lists regular files modified in the last hour, sorted oldest to newest by numeric epoch time. Keep ls -ltr for interactive work and reach for find the moment a script needs the same information. To count or batch-process matches, the guide on counting files in a directory covers those workflows.

What does ls -ltr stand for?

It combines three flags: l for the long listing format, t for sorting by modification time, and r for reversing the sort so the oldest entry appears first and the newest appears last.

When should I use ls -ltr instead of ls -l?

Use ls -l when alphabetical order helps you find a known filename. Use ls -ltr when you want to see which files changed most recently, because the newest entries land at the bottom near your prompt.

How do I show only the most recently modified file?

Run ls -ltr | tail -1. The tail command prints the last line, which is always the newest entry under this sort order.

What is the difference between ls -ltr and ls -lrt?

Nothing. Flag order does not matter to ls, so both commands produce identical output.

Run ls -ltrh in the directory you were just working in. The newest line tells you whether the command you ran a minute ago did what you expected, and from there the rest of the listing answers itself.