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 Manage Linux VPS (SSD and Traditional) From Client Area?

This article will assist you to manage your Linux VPS (SSD and Traditional) from client area...

How to Disable SELinux on CentOS?

SELinux called Security-Enhanced Linux is a security module of Linux kernel which provides...

How to check Inode usage from cPanel and Command line?

Inode is a data structure that stores the information about all files created on your hosting...

How to install Virtualmin/Webmin control panel in CentOS 7?

Please refer to the following steps to install Virtualmin/Webmin on Centos 7.x Let us update...

How to run ClamAV scan from SSH in cPanel server?

In this article, we'll discuss how to run ClamAV scan via SSH in cPanel/WHM server. ClamAV is one...