How to List All Files Ordered by Size in Linux

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

In one of our several articles about listing files using the popular ls command, we covered how to list and sort files by last modification time (date and time) in Linux. In this short handy article, we will present a number of useful ls command options to list all of the files in a certain directory and sort them by file size in Linux.

Recommended Read: How to Find Out Top Directories and Files (Disk Space) in Linux

To list all files in a directory, open a terminal window and run the following command. Note that when ls invoked without any arguments, it will list the files in the current working directory.

In the following command the -l flag means long listing and -a tells ls to list all files including (.) or hidden files. To avoid showing the . and .. files, use the -A option instead of -a.

$ ls -la
OR
$ ls -la /var/www/html/admin_portal/
List All Files in Linux
List All Files in Linux

To list all files and sort them by size, use the -S option. By default, it displays output in descending order (biggest to smallest in size).

$ ls -laS /var/www/html/admin_portal/
List All Files Sort By Sizes
List All Files Sort By Sizes

You can output the file sizes in human-readable format by adding the -h option as shown.

$ ls -laSh /var/www/html/admin_portal/
List Files Sort By Sizes in Linux
List Files Sort By Sizes in Linux

And to sort in reverse order, add the -r flag as follows.

$ ls -laShr /var/www/html/admin_portal/
List All Files Sort By Sizes in Reverse Order
List All Files Sort By Sizes in Reverse Order

Besides, you can list subdirectories recursively using the -R option.

$ ls -laShR /var/www/html/admin_portal/
List Sub-directories Recursively
List Sub-directories Recursively

You will also find the following related articles useful:

  1. How to Find Recent or Today’s Modified Files in Linux
  2. Linux ‘tree Command’ Usage Examples for Beginners
  3. 10 Practical Examples Using Wildcards to Match Filenames in Linux
  4. Ways to Use ‘find’ Command to Search Directories More Efficiently

If you any other way to list the files ordered by sizes in Linux, do share with us or do you have questions or thoughts to share about this guide? If yes, reach us via the feedback form below.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply
  1. For those of us who are stuck in a UNIX environment, are the options any different? Thanks and I realize that it just means opening up a terminal and trying what you have outlined.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Root Plan Premium Linux Education for Serious Learners

Before You Go - Upgrade Your Linux Skills

Root members get everything in one place, with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Linux certifications: RHCSA, RHCE, LFCS and LFCA
Access new courses on release
Weekly newsletter, priority support & Telegram community
Join Root Today and Start Learning Linux the Right Way
Structured courses, certification prep, and a community of Linux professionals - all in one membership.
Join Root Plan →
$8/mo · or $59/yr billed annually