Search Our Database

How to clear unused files and folder

Last updated on |
by

Introduction

This guide provides a solution for system administrators and developers who need to efficiently remove directories containing millions of files in Linux environments. Managing such large directories can be challenging due to file system limitations and performance issues.

Prerequisites

  • Root access of the server
  • Necessary backups as removing folder is irreversible
Important Note: Please take note once the files have been removed, it is irreversible and the deleted files cannot be retrieved back. Kindly backup any necessary folders

 

1. Navigate to where the unused files is located

cd /path/to/unused_files

 

2. Before deleting the files, you can see double confirm first to see what types of files being deleted, you can use command below first:

find . -type f -print

After confirming all the files that being deleted, can run:

find . -type f -print -delete

Running the command above removes all files in the selected directory. Once that has been done, run the following command to remove the folder:

rm -rf /path/to/unused_files

 

Article posted on April 20, 2020 by Louis