6

I have accidentally removed apt-get, how do I reinstall it?

$ sudo apt-get update
sudo: apt-get: command not found

$ sudo dpkg-reconfigure apt
/usr/sbin/dpkg-reconfigure: apt is broken or not fully installed 

I would like to mention I do not want to reinstall Linux!

  • Can you check exactly which packages you uninstalled? And provide a list of them in your question. –  May 21 '15 at 11:33
  • I do not know how to do that...and I upgraded some lib(something) after, as I read on here a little about it and I tried to fixed it. – privateoneuser May 21 '15 at 11:36
  • 1
    Please [edit] your question to add the list of packages you uninstalled. You'll find that in cat /var/log/apt/history.log | grep remove, if you removed it using apt-get remove. If you used the purge command, replace the grep string accordingly. If you did it differently, just output the log file. – s3lph May 21 '15 at 11:38
  • I cannot put the output as it exceeds alot the number of charachters. Is there a way I can attached the file? – privateoneuser May 21 '15 at 11:45
  • First part is :

    Start-Date: 2015-05-18 22:05:40 Commandline: /usr/sbin/synaptic Purge: account-plugin-aim:i386 (3.8.6-0ubuntu9.1) End-Date: 2015-05-18 22:05:42

    – privateoneuser May 21 '15 at 11:52
  • And second part with a lot of packages , i will just write here just a few of them...Start-Date: 2015-05-18 22:06:42 Commandline: /usr/sbin/synaptic Remove: python3-commandnotfound:i386 (0.3ubuntu12), plasma-nm:i386 (0.9.3.3-0ubuntu1), python-aptdaemon.gtk3widgets:i386 (1.1.1-1ubuntu5.1), nautilus-share:i386 (0.7.3-1ubuntu5), kubuntu-debug-installer:i386 (13.10ubuntu1), update-notifier:i386 (0.154.1ubuntu1), xdiagnose:i386 (3.6.3build2), software-properties-gtk:i386 (0.92.37.3), ubuntu-standard:i386 (1.325), kde-runtime:i386 (4.13.3-0ubuntu0.2), kwalletmanager:i386 (4.13.3-0ubuntu0.1),...... – privateoneuser May 21 '15 at 11:54

3 Answers3

5

I'm not sure what happened with your apt-get, but if you're unable to use it, you might want to use apt from Ubuntu repositories (simply downloading and installing via sudo dpkg -i package_name)

the functionality of apt is pretty much similar to what you get with apt-get.

psukys
  • 3,590
  • user3@comp3:~/Downloads$ sudo dpkg -i apt_1.0.1ubuntu2.5_i386.deb (Reading database ... 350313 files and directories currently installed.) Preparing to unpack apt_1.0.1ubuntu2.5_i386.deb ... Unpacking apt (1.0.1ubuntu2.5) over (0.5.15-2) ... dpkg: dependency problems prevent configuration of apt: apt depends on libapt-pkg4.12 (>= 0.9.16); however: Package libapt-pkg4.12:i386 is not configured yet. apt depends on libstdc++6 (>= 4.6); however: Package libstdc++6:i386 is not configured yet. – privateoneuser May 21 '15 at 12:32
  • dpkg: error processing package apt (--install): dependency problems - leaving unconfigured Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Errors were encountered while processing: apt – privateoneuser May 21 '15 at 12:33
  • 1
    Have you tried installing the packages that were mentioned as not configured? – psukys May 21 '15 at 12:34
  • I tried to install some of them, yes but it always kept saying that this package is not yet configured because another package that depends on is not configured yet and so on, until I gave up. Unfortunally I removed too many packages and now I am stuck. – privateoneuser May 21 '15 at 12:39
  • The depends list is not so big, do the same for all of these, repeat in cycle if needed, you should get apt-get back again: libapt-pkg4.12 (>= 0.9.16), libc6 (>= 2.15), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.6), ubuntu-keyring, gnupg. – Stéphane Gourichon May 21 '15 at 13:40
  • I will do my best and coming back with the results :) ... and how can I configure a package?dpkg: dependency problems prevent configuration of apt: apt depends on libapt-pkg4.12 (>= 0.9.16); however: Package libapt-pkg4.12:i386 is not configured yet. apt depends on libstdc++6 (>= 4.6); however: Package libstdc++6:i386 is not configured yet. – privateoneuser May 21 '15 at 13:49
  • Ironically enough, apt-get would resolve this problem, although the problem itself must be handled by manual dependency resolving :)

    During the installation, packages usually configure themselves.

    – psukys May 21 '15 at 13:51
  • libapt-pkg4.12 (>= 0.9.16) means a higher version than 0.9.16? – privateoneuser May 21 '15 at 13:55
  • Thank you a lot for your effort and attention. It helped me a lot!!! – privateoneuser May 21 '15 at 14:35
0

Assuming that your apt-get seriously needs a reinstall, you can try following:

  1. Check your current apt-get version by apt-get --version.
  2. Search for the same version's .deb file on launchpad.net
  3. install it by dpkg -i filename.deb
  4. Of course, this unfortunately cannot work if you also removed the packeges on which apt depends, like libgcc1
GunjanPB
  • 1
  • 1
  • 1
    user3@comp3:~$ apt-get --version bash: apt-get: command not found – privateoneuser May 21 '15 at 12:08
  • @privateoneuser, which ubuntu version are you using? For 15.04, it is apt 1.0.9.7ubuntu4 try installing this version, I don’t think ubuntu version will matter. Download deb file corresponding to your architecture – GunjanPB May 21 '15 at 12:16
  • user3@comp3:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS Release: 14.04 Codename: trusty – privateoneuser May 21 '15 at 12:21
  • Go to (https://launchpad.net/ubuntu/+source/apt/1.0.1ubuntu2.7) and select your architecture (amd64/i386 etc.) and download apt_.deb – GunjanPB May 21 '15 at 12:35
  • I downloaded apt_1.0.1ubuntu2.7.tar.xz and apt_1.0.1ubuntu2.7.dsc. Should I install these 2 packages? – privateoneuser May 21 '15 at 12:42
  • Installing from source tar.gz is rather complicated, you should have downloaded this for 32-bit or this for 64-bit – GunjanPB May 21 '15 at 12:51
  • user3@comp3:~/Downloads$ sudo dpkg -i apt_1.0.1ubuntu2.7_i386.deb (Reading database ... 350022 files and directories currently installed.) Preparing to unpack apt_1.0.1ubuntu2.7_i386.deb ... Unpacking apt (1.0.1ubuntu2.7) over (1.0.1ubuntu2.5) ... dpkg: dependency problems prevent configuration of apt: apt depends on libapt-pkg4.12 (>= 0.9.16); however: Package libapt-pkg4.12:i386 is not configured yet. apt depends on libstdc++6 (>= 4.6); however: Package libstdc++6:i386 is not configured yet. – privateoneuser May 21 '15 at 12:56
  • dpkg: error processing package apt (--install): dependency problems - leaving unconfigured Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Errors were encountered while processing: apt – privateoneuser May 21 '15 at 12:57
  • Unfortunately you are stuck in dependency hell. Would you consider reinstalling Linux? – GunjanPB May 21 '15 at 13:01
  • No, and that is the problem. Isn't there any solutions to these dependencies? – privateoneuser May 21 '15 at 13:04
  • Manually searching for deb files of each dependency and installing them by dpkg -i is the only option – GunjanPB May 21 '15 at 13:10
  • I was thinking to the same thing yesterday, still I was hoping there might be better ways and looking forward for them. That's why I opened an account here. If you hear/find/know any other better ways to solve it please let me know. Thank you a lot anyway :) – privateoneuser May 21 '15 at 13:13
0

Try installing synaptic from the command line, and see if you can't reinstall apt that way.

From a terminal window, type in the following:

wget http://mirrors.kernel.org/ubuntu/pool/universe/s/synaptic/synaptic_0.84.2_amd64.deb

then install the downloaded package:

sudo dpkg -i synaptic_0.84.2_amd64.deb

then run the installed app:

sudo synaptic

In the quick search, type in apt and select it for install.

Terrance
  • 41,612
  • 7
  • 124
  • 183