Forum

Maximizing Disk Spa...
 
Notifications
Clear all

Maximizing Disk Space: How to Find and Remove Large Files and Directories Using Command Line?

 
(@administrator)
Member Admin

On Unix-based systems, you can use the "du" command to display the disk usage of files and directories, and the "sort" command to sort the results by file size. To find large files or directories, you can combine these two commands with a pipe symbol like this:

To find large files:

 

find / -type f -size +100M -exec du -h {} \; | sort -hr | head -n 10

 

This will find all files larger than 100MB starting from the root directory ("/"), display their sizes in a human-readable format, sort them in descending order by size, and display the 10 largest files.

To find large directories:

 

du -h / | sort -hr | head -n 10

 

This will display the disk usage of all directories in the root directory ("/"), sort them in descending order by size, and display the 10 largest directories.

 

In my case, I try this... to find Large files and folders using this cmd.

 

find / -size +10M -ls

 

(10M = 10 MB) file size.

 

Then you can run this cmd to remove files,

 
rm -r /filepath/yourfolder/

 

Thanks.

Quote
Topic starter Posted : 13/02/2023 10:32 am
Share:
×