HomeLinuxHow you can Discover Prime Directories and Information (Disk Area) in Linux

How you can Discover Prime Directories and Information (Disk Area) in Linux


As a Linux administrator, you should periodically test which recordsdata and folders are consuming extra disk house. It is extremely essential to search out pointless junk and free it up out of your onerous disk.

This temporary tutorial describes how you can discover the most important recordsdata and folders within the Linux file system utilizing the du (disk utilization) and discover instructions. If you wish to study extra about these two instructions, then head over to the next articles.

How you can Discover Greatest Information and Directories in Linux

Run the next command to search out out the high greatest directories below /dwelling partition.

# du -a /dwelling | type -n -r | head -n 5
Find Largest Directories in Linux
Discover Largest Directories in Linux

The above command shows the largest 5 directories of my /dwelling partition.

Discover Largest Directories in Linux

If you wish to show the largest directories within the present working listing, run:

# du -a | type -n -r | head -n 5
Find Biggest Directories Only
Discover the Greatest Directories Solely

Allow us to break down the command and see what says every parameter.

  • du command: Estimate file house utilization.
  • a : Shows all recordsdata and folders.
  • type command : Kind traces of textual content recordsdata.
  • -n : Examine in response to string numerical worth.
  • -r : Reverse the results of comparisons.
  • head : Output the primary a part of the recordsdata.
  • -n : Print the primary ‘n’ traces. (In our case, We displayed the primary 5 traces).

A few of you wish to show the above lead to a human-readable format. i.e. you may need to show the most important recordsdata in KB, MB, or GB.

# du -hs * | type -rh | head -5
Find Top Directories Sizes in Linux
Discover Prime Directories Sizes in Linux

The above command will present the highest directories, that are consuming up extra disk house. In the event you really feel that some directories are usually not necessary, you’ll be able to merely delete a number of sub-directories or delete your entire folder to release some house.

To show the most important folders/recordsdata together with the sub-directories, run:

# du -Sh | type -rh | head -5
Find Largest Folder and Sub directories
Discover the Largest Folder and Subdirectories

Discover out the that means of every possibility utilizing in above command:

  • du command: Estimate file house utilization.
  • -h : Print sizes in human-readable format (e.g., 10MB).
  • -S : Don’t embody the scale of subdirectories.
  • -s : Show solely a complete for every argument.
  • type command : type traces of textual content recordsdata.
  • -r : Reverse the results of comparisons.
  • -h : Examine human readable numbers (e.g., 2K, 1G).
  • head : Output the primary a part of the recordsdata.

Discover Out Prime File Sizes Solely

If you wish to show the largest file sizes solely, then run the next command:

# discover -type f -exec du -Sh {} + | type -rh | head -n 5
Find Top File Sizes in Linux
Discover Prime File Sizes in Linux

To seek out the most important recordsdata in a specific location, simply embody the trail beside the discover command:

# discover /dwelling/tecmint/Downloads/ -type f -exec du -Sh {} + | type -rh | head -n 5
OR
# discover /dwelling/tecmint/Downloads/ -type f -printf "%s %pn" | type -rn | head -n 5
Find Top File Size in Specific Location
Discover the Prime File Measurement in a Particular Location

The above command will show the most important file from /dwelling/tecmint/Downloads listing.

That’s all for now. Discovering the largest recordsdata and folders is not any massive deal. Even a novice administrator can simply discover them. In the event you discover this tutorial helpful, please share it in your social networks and help TecMint.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments