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 determine what is using the most disk space on a Linux server?

There are times when you receive following error while accessing the cPanel WebMail or WHM. You...

How to install NodeJS on Centos with cPanel?

NodeJS is an open-source and cross-platform server environment. It is a JavaScript runtime built...

How to run ClamAV and Maldet together on cPanel server?

You may be familiar with ClamAV and Maldet scanner (aka Linux Malware Detect). They're widely...

Difference Between su and sudo and How to Configure sudo in Linux VPS.

As we know Linux provides much better security. You can set user management policy and user...

How to Stop and Disable ClamAV Service from CentOS?

We all know that ClamAV scanner is a pretty heavy on CPU-Memory resources, and it should be...