I was having problem with "broken packages" error. I tried few solution but they went in vain. Then I tried one:

removing source.list from /etc/apt/

I thought rebuilding source.list will fix the issue.

and then did an

sudo apt-get autoremove

which I reckon, removed major components as well.

Now, After reboot I login using a terminal and cannot install any program for example: ubuntu-desktop using apt.

Please advise how to recover the system or install desktop environment in this state.

  • If you removed your /etc/apt/sources.list, then you removed all major (non-3rd party) software repositories from your system so normal Ubuntu software can't be installed until sources.list file is re-created (assuming your software lists were updated by sudo apt update). You mention rebuilding 'sources.list'; how did you 'rebuild' it?
    – guiverc
    Feb 1 '20 at 12:14
  • 1. actually i didn't rebuil it before autoremove command 2. I did restore the list (move back the backup to e/etc/apt as i can login in via a terminal but there is no desktop. ( as in case of a server install)
    – omer
    Feb 1 '20 at 12:19
  • 1
    sudo apt autoremove only removes packages that were installed to satisfy certain other packages you installed. They'll only get removed if you removed the reason they were installed (eg. by removing the packages that caused their install). apt autoremove only cleans up some space from commands you'd executed earlier, so any errors of removal were actually apt remove commands performed before the autoremove
    – guiverc
    Feb 1 '20 at 12:19
  • 1
    :) run sudo apt update to update your software lists & apt install should find ubuntu software again. For the broken packages, try sudo apt -f install and read any error messages there (they're the answer to fixing any problems it can't auto fix)
    – guiverc
    Feb 1 '20 at 12:29
  • 1
    You haven't given release details so apt install it (ubuntu-desktop for 16.04, ubuntu-unity-desktop` for 18.04 or later). If you have errors, add them to your question or package isn't found, apt-cache policy ubuntu-desktop (if sources.lists is correct you'll see results)
    – guiverc
    Feb 1 '20 at 12:33

You can always reinstall the same Ubuntu version without reformatting the system directory. In that case, all you user files and settings will stay in place. At most, you may need to reinstall some applications you installed yourself.

To recover your system this way, boot up an installation medium of the same Ubuntu version. In the Installer, on the "Installation type" dialog, select "Something else". Indicate your current system partition as the partition to be used as root ("/") and uncheck the "format" checkbox. If you had a home folder or any other part of the system on another partition, reassign the same partitions, making sure "format" is unchecked.

This will repair your system while leaving your setup largely in place, except from some applications you may need to reinstall. After reinstall, also these applications will continue to be configured as before, because your user preferences are still in place.

Needless to say, even if this preserves all your date, make sure that the back up of all your personal user data is updated before proceeding.

  • thank you for the suggestion. I will make it the last resort. first I am testing the possibilities to recover from thia state. If not, will do the normal recovery as you suggested.
    – omer
    Feb 1 '20 at 12:48

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.