• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Find And Sort Files By Size In Linux Ubuntu

How To Find And Sort Files By Size In Linux Ubuntu

By Sourabh / June 3, 2022 Category: How To, Ubuntu

How to find and sort files by size in Linux Ubuntu. Here is the command to order files by size in Linux and sort files in directory by size Linux.

How To Find And Sort Files By Size In Linux

You can use one of the following commands to find and sort files by size in Linux Ubuntu:

$ ls -lhS
$ ls -l
$ ls -lS
$ ls -lhS

Note that the command option ‘-h’ or ‘–human-readable’ is used to get the result in human readable format. It is used to append a size letter to each size, such as ‘M’ for mebibytes. Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes. This option is equivalent to ‘–block-size=human-readable’. You can also use the ‘–si’ option if you prefer powers of 1000.

List files by their size in reverse order

If you want to display the result in ascending order and show bigger files at the bottom and smaller files at the top, you can use the command option -r with the ls -lhSr command.

$ ls -lhSr

If you want to get the list of 10 biggest files in a directory, you can use the following command:

$ ls -lhS | head -11

Using the ls and sort Commands

$ ls -lhR | grep '^-' | sort -k 5 -h

The following command options are used for ls and sort command:

  • -l: uses a long listing format. The file size is shown in the fifth column
  • -h: reports size in a human-readable format like Kilobytes (K), Megabytes (M), Gigabytes (G), and so on
  • -R: recurs through the sub-directories
  • -k: performs the sort using a key. In this example, the fifth column is used as the sort key

Using the du and sort Commands

$ du -ah --max-depth=1 | sort -h

The following command options are used for the du command:

  • -a: reports size of all files and not just of directories
  • -h: reports size in human-readable formats like Kilobytes (K), Megabytes (M), Gigabytes (G), and so on
  • –max-depth: reports total size for the first-level directories

If you want to list the result in descending order, use the -r option with the sort command.

Using the find and sort Commands

$ find . -type f -ls | sort -n -k7

The following command options are used for the find and sort command:

  • -type f -ls: uses a long listing format of ls command for each file. The size of a file is shown in the seventh column.
  • -n -k7: sorts files in ascending order according to their size. In this example, we use the seventh column as a sort key

Hope you learned how to find and sort files by size in Linux Ubuntu.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap