Linux is a Unix-like operating system that is popular in many countries. It has a number of features that make it an attractive choice for servers and data centers. One of the most popular features of Linux is its ability to manage files and directories on a local or remote computer. To help you understand how Linux manages files and directories, here are some tips:

  1. List Files and Directories by Size on Linux To list all the files and directories in a directory, use the ls command. The following example lists all the files in the /tmp directory: /tmp ls -l total 16 -rw-r–r– 1 root root 4096 Jul 2 03:12 tmp -rw-r–r– 1 root root 4096 Jul 2 03:12 .bash_logout

Command

To get a list with the size of each item in a folder, you’ll want to use the du command like this:

The -m argument will return the listing in megabytes (note that you can use -h for human readable, but it won’t sort correctly)

Now we will want to run this through the sort command, sorting in reverse order -r and numeric -n:

The only problem here is that we’ll get way too much output if there are a lot of files and folders, so we can either pipe it through the more command:

Or we can just return the top 15 largest items:

This will return a listing something like this: