Sudo apt autoremove made a mess

Hello,
I decided to uninstall Opera browser and run command 'sudo apt purge opera-stable'. That was successful and then I run 'sudo apt autoremove' command. The result badly surprised me. All files in Home directory (in Documents, Pictures etc.) were gone, as well as all Wine software, and all the settings (primarily those connected with Zorin Appearance) I've been doing for last month or so. Needless to say that I'm a Linux newbee.
Have I done something wrong?

The Autoremove is something best used With Caution.
When software is installed that automatically installs needed dependencies, it gets called "automatically installed."
Automatically installed packages are subject to removal with Autoremove.

When you specify a package to install; this is "Manually installed." Manually installed packages are exempt from Autoremove.

I often will mark sensitive packages as Manually Installed to prevent autoremove from getting its mitts on them.

As to how removing Opera removed your Home Directory, WIne etc., I am unable to guess without seeing the dpkg log.
That is tragic. I never use Opera, either.
I can only suggest you search extensively to see if any of those personal files were moved somewhere...

2 Likes

It seems very unlikely that apt autoremove did anything with your home directory. How did you install Opera? Also, did you run any other commands such as rm?

Thanks for quick reply.
Well, I don't use Opera either, I prefer Firefox. I just wanted to try some Opera features (downloaded deb package directly from the Opera site and installed using Software tool), but in no time got fed up with it. I reached for Terminal in order to uninstall Opera only because Opera hasn't been listed in Software/Installed so I could have removed it by clicking Remove button. What can I say: the old Windows habits die hard.
Forgot to mention, the Autoremove also remove all fine settings and tunings I made in WPS Office (shortcuts, measurement units...), fonts that I manually installed and so on.
Anyway, it is not so tragic, rather unexpected. I managed to restore all files from external HDD and set up desktop environment again. Luckily, important settings, like HPLIP or Ubuntu restricted extras, stayed untouched by this turmoil.
And...I don't know how to find dpkg log, but now it seems unnecessary to do it 'cause everything back to normal.

No, I didn't. Only those commands which I mentioned in my first post.
As to how did I install Opera, I wrote it in a reply to Aravisian post.

Usually after an update I also preform this action. It cleans up and mostly removes (the oldest drivers) and leftovers. So there is no harm done ...in my case.

But if you haven't restarted I would try testdisk to see if you can recover those lost folders/files which are important to you. If a recovery is not possible then I would recommend a fresh installation (unless you have a backup) to avoid headaches and all kinds tryouts.

I suspect it was the purge that may have removed all of the configuration files but it shouldn’t have. I’d have to look at the Opera package to see what their config looks like. Sorry you had to deal with that mishap.

Same. I cannot stand Opera.

I do not see how purge or autoremove could remove the Home Directory. I cannot help but think something else happened there...

I don't think there is a need for a fresh installation or restoring a backup (which I have). As I wrote to Aravisian, I recovered all files from external HDD.
As far as I can see, no system files or settings suffered any harm from this "unexpected cleaning". The system runs smooth and I cannot notice unusual behaviour. Hope there won't be any more unpleasant surprises.

Might be a good time to install Timeshift:

When running removal or autoremove commands... always and without exception, Read what the terminal says will be removed. Always.

Autoremove can be problematic if there are PPAs or 3rd party repositories enabled as well. When 3rd party apps have shared dependencies with native ones removing one can affect the other. Having installed and removed the Opera .deb many times I suspect the cause lies elsewhere.

1 Like

Have it, but I think no need to use it now.

Yes, you are quite right. Though, I'm not sure I wouldn't be able to understand what it said.

Forgot to write :roll_eyes:. Between purge and autoremove commands I type this one, I found in some tutorial on YT: "rm -rf /home/djurica/ .cache/opera". But system refused to execute it, I cannot remember now what was the explanation. Is this the missing point that might explain mess I made? But, I repeat, that command hasn't been executed.

Yes, that was it.
You entered a command to remove the Home Directory.

Even if it hasn't been executed.

It was executed - you know this because your Home Directory was removed.

It may be that the rm -rf command was executed, then the system put up a warning in regards to the tail: ".cache/opera"
As that message is unknown, I cannot verify it.
But auto remove should not remove the Home Directory. "rm-rf 'Home Directory'" WILL remove it - and you input that command - and it was removed. It's an open and shut case.

That being said... there is a TYPO in your command. You have a space that should not be there.
The instructions wanted you to run:

rm -rf /home/$USER/.cache/opera

But you ran:

rm -rf /home/$USER/ .cache/opera

Please see This Thread:

I wish tutorials did not blithely throw the rm -rf command around without giving a crash course on how to use it and how to avoid problems with it.
That YouTube guide belongs in the Wall of Shame.

Okay, I understand. Thank you very much. No more playing with "rm -rf".
This is the tut in question (How to Completely Remove or Uninstall Opera Browser in Ubuntu 18.04 LTS? - YouTube), and as far as I can see, there was a space between / and .cache, both in txt doc and in Terminal. I just want to say that I was very careful in following the instruction.

1 Like

Yes, it looks like a space between to me, too.
But looking in the "read More" of the description, there is no space visible, there. I think it has to do with how it appears on the video screen.
You clearly followed that very carefully, based on what you could say. And very good that you have backups.

But in future, remember that any command that follows any direct path must have a Full path in order to complete its run of that path.
In the case of a 'rm -rf', this can get dangerous; As white space left behind can halt the path too soon.
In this case, the path halted at your Home Directory instead of at the ~/.cache/opera directory.