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 Hide Your NGINX Server Version.

Sometimes hackers target your server with a technic called banner grabbing. Usually, banner...

HOW TO INSTALL NEXTCLOUD ON UBUNTU?

Nextcloud is an open-source and secure PHP-based content collaboration platform. It is used for...

How to setup Database Map tool from WHM Panel?

cPanel provide a feature called Database Map tool. You can provide ownership of databases and...

How to install the Zabbix agent version 4.0 on Debian 9 (strech)?

Zabbix is an Open-source monitoring tool use to monitor the health of servers, networks and other...

Do You Provide GUI With VPS or Just a Command Line?

Yes, we do provide GUI environment with all our Windows VPS plans. However, in Linux VPS, you...