How to recover deleted files in Ubuntu

If you accidentally delete a file in the Ubuntu operating system, you can try the following methods to recover the file:

  1. Check the trash bin: Ubuntu automatically moves deleted files to the trash bin by default. You can right-click on the trash bin icon on the desktop and select “Open” to see if the file you want to recover is in there. If you find it, right-click on the file and select “Restore”.
  2. Restore using command line: Open the terminal and try recovering files from the trash using the following command.
cd ~/.local/share/Trash/files
ls -a

This will list all files in the trash can. Then use the following command to restore the files to their original location:

mv 文件名 目标目录

The file name is the name of the file you want to recover, and the target directory is the original directory where the file was located.

  1. Utilize data recovery tools: If the methods mentioned above do not help you retrieve your files, you can try using some third-party data recovery tools such as TestDisk, PhotoRec, etc. These tools can scan your hard drive and recover deleted files.

Regardless of the method you use, it is recommended that you stop using the hard drive as soon as possible to prevent overwritten files from becoming irretrievable. Additionally, regular backups are the best practice to prevent data loss.

bannerAds