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 Visual Studio Code on CentOS 7?

Visual Studio Code is a Microsoft Product and an open-source cross-platform code editor. It...

Will internal traffic between two VPS viz. a Database Server and a Web Server be counted in my bandwidth usage?

Yes it will. The traffic will be counted in the bandwidth usage of your VPS. Even if you use...

How to install Magento 2.x.x in cPanel?

System Requirement :   Operating System: Centos, Debian, Ubuntu, RHCE RAM: 2 GB (Require for...

How to set up Apache password Authentication on Ubuntu 18.08?

On the internet, almost all the applications have some parts which should be protected with a...

How to install Mongodb in CentOS?

MongoDB is a Free and open-source cross-platform document-oriented database program. Classified...