How do I sort disk usage in Linux?

April 21, 2020 Off By idswater

How do I sort disk usage in Linux?

Let us break down the command and see what says each parameter.

  1. du command: Estimate file space usage.
  2. a : Displays all files and folders.
  3. sort command : Sort lines of text files.
  4. -n : Compare according to string numerical value.
  5. -r : Reverse the result of comparisons.
  6. head : Output the first part of files.

How do you sort du in Unix?

The following command sorts du output by size in descending order. The -n flag is a shorthand of –numeric-sort , which tells sort to sort lines in numerical order. The -r flag means -reverse , which reverse the default ascending order of sort . By default, du scans all subdirectories and includes them in the output.

How do I sort du output?

One of the easiest ways to sort with out the -h option of sort is to first use the du command with out the -h option, sort that output and then run du again on the sorted list of folders.

How do I list the top 10 large files in Linux?

Linux find largest file in directory recursively using find

  1. Open the terminal application.
  2. Login as root user using the sudo -i command.
  3. Type du -a /dir/ | sort -n -r | head -n 20.
  4. du will estimate file space usage.
  5. sort will sort out the output of du command.
  6. head will only show top 20 largest file in /dir/

What is the difference between DF and du in Linux?

df vs. du. The (very complicated) answer can be best summarized like this: The df command provides a sweeping ballpark figure for how much space is being utilized on your filesystem as a whole. The du command is a much more accurate snapshot of a given directory or subdirectory.

How do I free up space in Unix?

How to free disk space on Linux systems

  1. Checking free space. More about open source.
  2. df. This is the most basic command of all; df can display free disk space.
  3. df -h. [[email protected] ~]# df -h.
  4. df -Th.
  5. du -sh *
  6. du -a /var | sort -nr | head -n 10.
  7. du -xh / |grep ‘^\S*[0-9\.
  8. find / -printf ‘%s %p\n’| sort -nr | head -10.

How do I get more RAM on Linux?


  1. Open the command line.
  2. Type the following command: grep MemTotal /proc/meminfo.
  3. You should see something similar to the following as output: MemTotal: 4194304 kB.
  4. This is your total available memory.

How do I find the top 10 large files in UNIX?

How do I find the top 5 files in UNIX?

How to find out top Directories and files in Linux

  1. du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
  2. du command -s option : show only a total for each argument (summary).
  3. du command -x option : skip directories on different file systems.