How to List All Files Ordered by Size in Linux?

In Linux, we can list all the files using the ls command. Here, we will share some commands which will help you to sort the files in order by size.

In the following command, we will list all the files in a directory. This will also list the hidden files on that directory.

# ls -la

Here, we will use the -s option. It will list all the files in descending order (largest to smallest in size).

# ls -laS /var/log

Now, if you want to see the file size in a human-readable format, you can add -h option in the command.

# ls -laSh /var/log

If you want to sort the file with reverse order, please add r as mentioned below.

# ls -laShr /var/log

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Run Multiple PHP versions with Nginx on Ubuntu?

You can run multiple php versions on Ubuntu without any issue. You require Multiple php versions...

How to Move Accounts From One cPanel Server To Another cPanel server?

cPanel facilitates you with the built-in Transfer Tools which allow you to migrate your existing...

How to configure Exim outgoing IP address from WHM?

By Default, All the outgoing emails from the Exim will be sent from the server’s primary IPv4...

How to use gzip in Linux?

Linux has many commands line tools to compress/decompress files and gzip is one of them. In this...

How to Install FTP on Ubuntu 18.04?

FTP stands for File Transfer Protocol used to share files/folders from one server to another...