0

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.

omer
  • 188
  • 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 01 '20 at 12:14
  • 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 01 '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 01 '20 at 12:19
  • I had the old source list backed up so restored it using console. – omer Feb 01 '20 at 12:28
  • 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 01 '20 at 12:29
  • What I really want is to bring back the unity desktop. – omer Feb 01 '20 at 12:30
  • currently running sudo apt-get update and it is updating sources. I will try installing ubuntu-desktop after that. thanks for the help :) – omer Feb 01 '20 at 12:32
  • 1
    You haven't given release details so apt install it (ubuntu-desktop for 16.04,ubuntu-unity-desktopfor 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 01 '20 at 12:33
  • running apt install or apt cache return unable to locate package – omer Feb 01 '20 at 12:45
  • Does this answer your question? How do I restore the default repositories? deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse deb http://archive.canonical.com/ubuntu bionic partner – karel Feb 01 '20 at 13:33
  • I tried with new source.list but that went in vain as well. Somehow I was able to get UI back using apt install -f command. it installed some libs. But System was totally broken. no apps. no settings. So I will recover the system the normal way without apps. – omer Feb 01 '20 at 16:33