Listing Files by Size Using the ls Command on Linux
Linux operating systems provide various commands to display files in an organized way. Listing files by size can help you quickly find large files in a specific directory. In this article, you’ll learn how to list files by size using the ls
command in Linux.
The ls Command and Its Parameters
The ls
command is used to list files in a directory. To sort by size, we use the -S
parameter. This sorts the files from largest to smallest.
Command Usage
You can list files by size using the following command:
ls -lhS
This command displays file sizes in a human-readable format (KB, MB, etc.) and sorts them accordingly.
Example Usage
For example, if you want to list the files in the /home/user/directory
folder by size, open the terminal and enter: