Directory listings become easier to scan when the entries that usually fall at the bottom need attention first. In Linux, ls -r reverses the active sort order, so a name-sorted view can show descending names and a time-sorted view can show the oldest entries first without changing files or directories.
The default ls order is name sorting under the current locale. Adding -1 prints one entry per line, while -r flips the order that ls would otherwise produce. That makes a before-and-after check easy in terminals, scripts, and handoff notes.
Reverse sorting only works when sorting is enabled. -U or --sort=none prints directory entries in storage order and leaves -r with nothing to reverse; use the default name sort or a specific sort key such as -t when the order must be predictable.
Steps to reverse file and folder listings in Linux:
- List the target directory in default name order.
$ ls -1 /srv/reverse-demo alpha.txt archive logs zulu.txt
-1 prints one entry per line so the ordering is easy to compare.
- Reverse the default name sort.
$ ls -1r /srv/reverse-demo zulu.txt logs archive alpha.txt
-r reverses the active sort key; with the default name sort, the entries appear in reverse alphabetical order.
- List entries by modification time when timestamp order matters.
$ ls -lt --time-style=long-iso /srv/reverse-demo total 16 -rw-r--r-- 1 root root 40 2026-04-14 09:03 zulu.txt drwxr-xr-x 2 root root 4096 2026-04-14 09:02 logs drwxr-xr-x 2 root root 4096 2026-04-14 09:01 archive -rw-r--r-- 1 root root 6 2026-04-14 09:00 alpha.txt
-t sorts by modification time, newest first.
- Reverse the time sort to show the oldest entries first.
$ ls -ltr --time-style=long-iso /srv/reverse-demo total 16 -rw-r--r-- 1 root root 6 2026-04-14 09:00 alpha.txt drwxr-xr-x 2 root root 4096 2026-04-14 09:01 archive drwxr-xr-x 2 root root 4096 2026-04-14 09:02 logs -rw-r--r-- 1 root root 40 2026-04-14 09:03 zulu.txt
-r flips the -t result, so the oldest modified entry appears first.
- Force bytewise name ordering when a script or comparison must produce the same order across hosts.
$ LC_ALL=C ls -1r /srv/reverse-demo zulu.txt logs archive alpha.txt
LC_ALL=C avoids language-specific collation differences for this command only.
- Skip unsorted mode when the output must be reversed.
-U and --sort=none disable sorting, so -r has no effect. Keep sorting enabled with the default name order, -t, -S, -X, or another supported sort key before reversing the listing.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.