I am using Ubuntu via a virtual machine and every time I either exit saving the current estate or power it off, it always work when running the virtual machine again. After trying to install python3 via the terminal, I noticed the background of my desktop (in the VM) changed to black, most of my apps were gone, and I couldn't open anything.

Closed the VM, re-opened it and encounter this that has never been shown to me before. I type my username and password but then what? I am very inexperienced with any of this so I am unsure as to what is expected. Is there a way to move on from this screen? Did I lose all the stuff in the VM? Is there a way to recover what I had saved and installed in this machine and moved it to a new one? SCREENSHOT

@mchid This is the output: SCREENSHOT 2 I am afraid I have toasted that VM, I'll look into how to delete this one as to not lose space. Lesson learned the hard way.

  • 1
    How did you install python3? Python3 should be installed by default.
    – mchid
    Jan 23 at 6:40
  • @mchid I uninstalled it and reinstalled it with the terminal.(sudo apt install python3 python3-pip) I really don't know if that has anything to do with moving on from the tty login screen but is the last thing I did. Jan 23 at 6:47
  • 1
    Oof. It is possible to recover but it might be easier to reinstall. Lots of packages depend on Python so all of those packages were most likely removed when you uninstalled python. What does the following command return (please edit your question and post the output there): cat /var/log/apt/history.log | grep Remove | grep -Po "(?<=, )[[:alnum:]-:.]+(?= \()"
    – mchid
    Jan 23 at 7:01
  • Just copy and paste the command, it's one single line.
    – mchid
    Jan 23 at 7:01
  • 1
    @mchid same output. Is not that bad, luckily I had everything backed in my host machine. How can I thank you? I appreciate the time and the explanation of the commands. Jan 23 at 8:07

1 Answer 1


You can try to reinstall the packages that were uninstalled. First run the following command:

sed -n '/^Remove/ s/([^ ]*//g;s/Remove: //p' < /var/log/apt/history.log | tee uninstalled

This command lists uninstalled packages and prints this output to a file named uninstalled.

If the list is clean and only contains package names, run the following commands to reinstall those packages:

sudo apt update
sudo apt install $(cat uninstalled)

After installation, reboot to apply the changes.

If that doesn't work, I would recommend to reinstall Ubuntu. In the future, you should always review the list of packages to uninstall before you press y to accept the changes.

To explain further, the file /var/log/apt/history.log contains your apt history. Uninstalled packages will be listed after "Removed:" on the same line. The sed command finds this line and cleans up the list to only list package names.

The -n option suppresses output.

/^Remove/ says to look for lines that begin with "Remove".

s/([^ ]*//g removes the version number contained within parenthesis after each package name (substitute /this/ with nothing and g is for all instances).

s/Remove: //p substitutes "Remove:" with nothing and prints the result.

Finally, tee uninstalled writes the output to a file named "uninstalled".

  • @mchip just did it. I edited my question with the outcome. I don't know how to thank you for the time. I can't vote. Jan 23 at 7:42
  • This was pretty magical, helped me now, and will definitely help in the future when I mess up again, thank you.
    – Kyle
    Jul 15 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.