Recover files deleted with command sudo apt autoremove

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

Help! I'm desperate and would appreciate any assistance. Firefox kept crashing and when nothing I tried worked, I decided to uninstall it and reinstall it. In the past when I used the Software Manager to uninstall a program, it didn't completely remove all the files that go with the deleted program and that caused problems. So, I found a website that described how to do it using the command terminal. It advised to command: sudo apt-get purge firefox and then sudo apt autoremove. Now ALL my documents and all my downloads are completely gone. Is there a way to recover all my files? Stupidly, I didn't back up before I did it. I thought it would be a simple process. Thanks so much.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Recover files deleted with command sudo apt autoremove

Post by xenopeek »

Chrwdy wrote: Fri Nov 26, 2021 7:57 amIt advised to command: sudo apt-get purge firefox and then sudo apt autoremove. Now ALL my documents and all my downloads are completely gone. Is there a way to recover all my files?
The apt-get purge and apt autoremove commands you ran only touch files in operating system directories, never files in your own home directory (where your documents and downloads are located). If your documents and downloads are gone, you must have done something else for that to happen. That can not be caused by the two commands you ran.

Are the files that are gone not in your trash folder?

If you really deleted your documents and downloads you may be able to recover them with TestDisk or PhotoRec, two data recovery tools. Because any further writes to your hard disk risk overwriting disk blocks where deleted files were located you should immediately stop using it. Boot from a Linux Mint installation ISO and use TestDisk or PhotoRec from there. You should also have a large external storage device to recover files to. Because, again, writing to your hard disk before recovering data from it risks overwriting not-yet recovered files. It won't just recover files you deleted recently but any recoverable files you have deleted in the past. It will be some puzzling.

The TestDisk and PhotoRec website https://www.cgsecurity.org/ has step by step and detailed tutorials for how to use it.

It will be easier if you have a recent backup to restore your files that way.
Image
vanadium
Level 4
Level 4
Posts: 324
Joined: Sun Dec 27, 2015 1:07 pm

Re: Recover files deleted with command sudo apt autoremove

Post by vanadium »

edit: xenopeek is seconds earlier, and his message is exactly the same...
Chrwdy wrote: Fri Nov 26, 2021 7:57 amNow ALL my documents and all my downloads are completely gone. Is there a way to recover all my files? Stupidly, I didn't back up before I did it. I thought it would be a simple process. Thanks so much.
That is *not* caused by `sudo apt autoremove`. All that command will do is remove any system libraries that are not anymore used by any installed program.

Something else happened. It is difficult to tell from a distance what. You will need to resort to an older out-of-data backup. Else, you have to revert to attempts for data recovery. Specialized firms can do that but it will come with a price. You can attempt yourself using recovery tools such as 'testdisk', but don't hold your breath. If you are tempted to try that, create an ISO of the disk and work off the issue, i.e., do not write any further on the partition where data have been lost. Any further use of that drive may further erase data that still will be hidden there.

There is really not much else than having good up to date backup copies of your personal data. We all learn this, and many of us (that includes me 8) the hard way.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Recover files deleted with command sudo apt autoremove

Post by Flemur »

As others mentioned, "purge" wouldn't delete your documents and downloads; try this to see if they're still around somewhere:

Code: Select all

sudo find / -iname "*part-of-one-of-your-filenames*" 
Replace part-of-one-of-your-filenames with a real value.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Re: Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

Thanks for your very kind responses, Flemur, Xenopeek and Vanadium! I so appreciate your help.

I tried installing Testdisk. It downloaded, but it wouldn't launch, nor did it appear in my applications. I tried deleting it and reinstalling to no avail.

Then I tried opening Timeshift, but it wouldn't open, even though it was already installed in my applications.

Do you think trying to install Testdisk would overwrite the partititon and make it more likely my files are unrecoverable?

I tried using the sudo find command, as Flemur suggested, and I've attached a screenshot of the response.
image1.png
It looks like I don't have permission to access my own files (yikes!) but I really can't decipher this. Any suggestions?

thanks so much.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Recover files deleted with command sudo apt autoremove

Post by Flemur »

Chrwdy wrote: Fri Nov 26, 2021 10:57 pm I tried using the sudo find command, as Flemur suggested, and I've attached a screenshot of the response.image1.png
Ignore those "errors"

Use this, leave the *'s in:

Code: Select all

sudo find / -iname "*oracle*" 
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Re: Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

Thanks. I tried that, but I got the same terminal response.

I have Timeshift in my Applications. I tried to launch it, and I got to the screen that needed my password, and then nothing happens. My understanding of Timeshift is that I could open it and restore my computer to all the settings, files, documents, etc. from a previous date. Am I understanding that correctly?

If I look through my file system, I can find a folder for Timeshift, which takes me to snapshots (daily, weekly, etc). I can open the "snapshots-daily" folder (all others are empty). There are three folders in snapshots-daily (Nov. 23, 24, and 26). When I open one of these, that takes me to a localhost folder, plus four files (exclude.list, infojson, rsync-log, rsync-log-changes). I really don't understand any of those files.

If I open the localhost folder, it takes me to numerous folders (bin, boot, cdrom, dev, and many others). There's a root folder that has an x over. That doesn't look good.

Do you think any of these Timeshift folders would help me to restore my laptop to how it was a few days ago?
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: Recover files deleted with command sudo apt autoremove

Post by Aztaroth »

Chrwdy wrote: Fri Nov 26, 2021 7:57 am Now ALL my documents and all my downloads are completely gone. Is there a way to recover all my files? Stupidly, I didn't back up before I did it. I thought it would be a simple process. Thanks so much.
Am I writing nonsense guessing Timeshift won't be of any help because the OP is after personal data and not system files ?
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Recover files deleted with command sudo apt autoremove

Post by xenopeek »

Aztaroth wrote: Sat Nov 27, 2021 3:23 am Am I writing nonsense guessing Timeshift won't be of any help because the OP is after personal data and not system files ?
No, by default Timeshift only backs up operating system files. It does not back up personal files like documents and downloads.

Timeshift isn't of use here.
Image
User avatar
JerryF
Level 16
Level 16
Posts: 6570
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: Recover files deleted with command sudo apt autoremove

Post by JerryF »

Aztaroth wrote: Sat Nov 27, 2021 3:23 am
Chrwdy wrote: Fri Nov 26, 2021 7:57 am Now ALL my documents and all my downloads are completely gone. Is there a way to recover all my files? Stupidly, I didn't back up before I did it. I thought it would be a simple process. Thanks so much.
Am I writing nonsense guessing Timeshift won't be of any help because the OP is after personal data and not system files ?
Timeshift could help with personal files, but only if the OP had changed the settings to include user files, which isn't the best "backup" solution.
motoryzen
Level 10
Level 10
Posts: 3474
Joined: Sun Dec 08, 2019 12:25 am

Re: Recover files deleted with command sudo apt autoremove

Post by motoryzen »

No, by default Timeshift only backs up operating system files. It does not back up personal files like documents and downloads.

Timeshift isn't of use here.
Timeshift could help with personal files, but only if the OP had changed the settings to include user files, which isn't the best "backup" solution
xenopeek and jerryf both have valid points here.

I wouldn't rely on Timeshift as the ONE end all backup solution either just incase that thought was ever in curiosity or question. Even the dev(s) of Timeshift will tell you that as well as the other very experienced LM users here and Clem and rest of the Linux Mint Team.

A supplementary backup solution like Foxclone is a VERY applicable deal here. It's never failed to save my bacon when all else did.
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
Petermint
Level 9
Level 9
Posts: 2981
Joined: Tue Feb 16, 2016 3:12 am

Re: Recover files deleted with command sudo apt autoremove

Post by Petermint »

Start File Manager. In Cinnamon, the file manager is Nemo which hides hidden files by default. Select View then Show hidden files.

Look for directory .mozilla. Open. If the directory is not there, you somehow selected the option to remove configuration files when removing a package. I have seen that only in the Synaptic Package Manager.

Inside .mozilla, there should be a directory for firefox. One of the subdirectories has your profile. When you reinstall Firefox, it may create a new profile and you may need to swap profiles or copy the content of the old to the new.

Backintime is an equivalent to Timeshift for your home directory. There is also a Backup tool in LM but I prefer Backintime as I can configure it for multiple backups. Whatever you do, backup before reinstalling Firefox.
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Re: Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

Thanks for your response. I did look in the .mozilla file, and the directory was there. I had already re-installed Firefox before I discovered that all my personal documents and downloads were missing. Several people have said that my documents may still be somewhere, as long as I haven't rewritten over top. Would re-installing Firefox rewrite everything so that now my documents and downloads are completely gone?
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Re: Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

xenopeek wrote: Sat Nov 27, 2021 1:03 pm
Aztaroth wrote: Sat Nov 27, 2021 3:23 am Am I writing nonsense guessing Timeshift won't be of any help because the OP is after personal data and not system files ?
No, by default Timeshift only backs up operating system files. It does not back up personal files like documents and downloads.

Timeshift isn't of use here.
Thanks. Some suggested TestDisk, which will install, but it won't launch. And now I wonder if trying to install it over-wrote all my personal documents such that now I won't be able to retrieve them. Does installing a program over-write the hard drive like that? I'm trying to hold out hope that my documents are hiding somewhere....
Chrwdy
Level 1
Level 1
Posts: 17
Joined: Fri Nov 26, 2021 7:46 am

Re: Recover files deleted with command sudo apt autoremove

Post by Chrwdy »

motoryzen wrote: Sat Nov 27, 2021 3:54 pm
No, by default Timeshift only backs up operating system files. It does not back up personal files like documents and downloads.

Timeshift isn't of use here.
Timeshift could help with personal files, but only if the OP had changed the settings to include user files, which isn't the best "backup" solution
xenopeek and jerryf both have valid points here.

I wouldn't rely on Timeshift as the ONE end all backup solution either just incase that thought was ever in curiosity or question. Even the dev(s) of Timeshift will tell you that as well as the other very experienced LM users here and Clem and rest of the Linux Mint Team.

A supplementary backup solution like Foxclone is a VERY applicable deal here. It's never failed to save my bacon when all else did.
Flemur wrote: Fri Nov 26, 2021 11:34 am As others mentioned, "purge" wouldn't delete your documents and downloads; try this to see if they're still around somewhere:

Code: Select all

sudo find / -iname "*part-of-one-of-your-filenames*" 
Thanks. I had set up Timeshift to do daily backups, but I was thinking it was equivalent to Time Machine on a Mac, which backs up everything. I'm disappointed to now understand its limitations.
Last edited by SMG on Sat Nov 27, 2021 7:47 pm, edited 1 time in total.
Reason: Added close quote so response was outside of the quoted sections.
User avatar
JerryF
Level 16
Level 16
Posts: 6570
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: Recover files deleted with command sudo apt autoremove

Post by JerryF »

Chrwdy wrote: Sat Nov 27, 2021 7:11 pm Thanks. Some suggested TestDisk, which will install, but it won't launch. And now I wonder if trying to install it over-wrote all my personal documents such that now I won't be able to retrieve them. Does installing a program over-write the hard drive like that? I'm trying to hold out hope that my documents are hiding somewhere....
I think your best bet would be to use a Live USB/DVD drive and temporarily install TestDisk using it live. Then check your hard disk with TestDisk.
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Recover files deleted with command sudo apt autoremove

Post by Flemur »

Chrwdy wrote: Sat Nov 27, 2021 7:15 pm Thanks. I had set up Timeshift to do daily backups, but I was thinking it was equivalent to Time Machine on a Mac, which backs up everything. I'm disappointed to now understand its limitations.
I don't use timeshift, but you can set it up to backup your important files, namely your personal, non-OS stuff.

I backup OS and data with grsync. Don't see any reason to use anything else.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
mikeflan
Level 17
Level 17
Posts: 7106
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Recover files deleted with command sudo apt autoremove

Post by mikeflan »

It advised to command: sudo apt-get purge firefox and then sudo apt autoremove. Now ALL my documents and all my downloads are completely gone.
I believe these forum members who say these commands would not remove the files in your home directory. So if your files are gone, they have probably been gone for a long time. Can you think of any files other than 'oracle girl' to search for? When is the last time you accessed a personal file and which one was it? Where was it located?

Please look in your Trash (on your desktop) for your files.

Please type each of these commands in a terminal and report the results (if you want to):

Code: Select all

ls -la ~/Downloads
ls -la ~/Documents
ls -la ~/Music
ls -la ~/Desktop
ls -la ~/Pictures
ls -la ~/.mozilla/firefox
ls -la ~/.local/share/Trash/files
Then follow JerryF advice about TestDisk if you can't find the files.
Petermint
Level 9
Level 9
Posts: 2981
Joined: Tue Feb 16, 2016 3:12 am

Re: Recover files deleted with command sudo apt autoremove

Post by Petermint »

Does .mozilla/firefox contain two directories with names like 7yt7vnc2.default? One could be your new profile from the recent install and the other, the previous profile. Mozilla documents how to switch profiles. You can backup, stop Firefox, reboot, copy the contents of a profile, then start Firefox. The subdirectory with the most files will be the used profile and the subdirectory with less files will be the fresh install. Look in .mozilla/firefox/profiles.ini to see which one is in use from the fresh install.
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: Recover files deleted with command sudo apt autoremove

Post by Aztaroth »

Chrwdy wrote: Sat Nov 27, 2021 7:15 pm Thanks. I had set up Timeshift to do daily backups, but I was thinking it was equivalent to Time Machine on a Mac, which backs up everything. I'm disappointed to now understand its limitations.
It is not a limitation, but the sensible thing to do.
Of course, in your special case, you would have something better than nothing, but imagine you upgrade to a new kernel for example, test it one week or two, and then decide the previous was better. If you'd use Timeshift to restore your system as it was one or two weeks ago with that previous kernel, you'd also restore all your personal files as they were at that time and loose all the work you've done during that period.
That's why the Timeshift developer, Tony George, discourages backing personal files with his tool. Here, https://teejeetech.com/timeshift/, read the section User Data is Excluded by Default for more.
Also, as someone already said, Mint provides the Mint Backup Tool dedicated to personal data backup. It's not the top backup tool as it only piles the docs you selected in a tar.gz file. You have also dedicated tools like FreeFileSync, not mentionning command lines like cp or rsync.
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
Locked

Return to “Beginner Questions”