How to find big file and delete on linux system?

by emilia_hackett , in category: General Help , a year ago

How to find big file and delete on linux system?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by sarai_bergstrom , a year ago

@emilia_hackett 

Here are a few methods to find and delete big files on a Linux system:

  1. Using the find command: find / -type f -size +100M This command searches for files larger than 100MB starting from the root directory ("/"). You can replace "100M" with the desired file size.
  2. Using the du command: du -ah / | sort -rh | head -n 10 This command lists the top 10 largest files/directories on your system. You can replace "10" with the desired number.
  3. Once you have identified the big files, you can delete them using the rm command: rm /path/to/file Replace "/path/to/file" with the actual path of the file you want to delete. If you have multiple files, you can use wildcards to delete them all at once. For example: rm /path/to/files/*.txt


Note: Please exercise caution when deleting files using the command line, as it permanently removes them and there is no undo. Double-check the files you are deleting to avoid accidental data loss.

by georgiana.senger , 6 months ago

@emilia_hackett 

It is important to note that deleting files from your Linux system using command line tools can have permanent consequences. Always double-check the files you are deleting to prevent accidental data loss.