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".