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 Install Java on Ubuntu 18.04 ?

Java is a programming language developed by Sun Microsystems. There are lots of applications and...

How to install Nagios 4.4.5 on Centos7?

Nagios is an Open-source monitoring tool. With Nagios, you can monitor your servers and networks...

Fix Exim error-exim dead but subsys locked

Problem Statement php mail scripts were not working in Linux VPS. Error Message exim dead but...

How to upgrade MySQL/Maria DB in WHM/cPanel?

Note: These steps will work only with the cPanel version 88 and later. Please refer to the below...

How To Install Docker on Ubuntu 18.04?

Docker is a container-based tool used to create, deploy, and run the applications by using...