Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Running any sudo apt-get command gives the error:

/usr/bin/apt-get: 1: /usr/bin/apt-get: Syntax error: end of file unexpected

(see Related question)

Is there a way to reinstall the apt-get program or replace the file /usr/bin/apt-get ?

share|improve this question
    
possible duplicate of apt-get Syntax error: end of file unexpected –  Rat2000 Sep 13 '13 at 11:20
    
Admittedly that is a duplicate but considering it did not receive a working solution I am inclined to leave this question open. –  Mokubai Sep 13 '13 at 16:59

1 Answer 1

up vote 1 down vote accepted

Disclaimer: The output shown is taken from a debian system, as I don't have access to a ubuntu machine. Ubuntu should be sufficient similar.

apt-get is an Advanced front-end for dpkg (according to its description), so you should still be able to you dpkg. First, determine your apt version:

$ dpkg -l | grep apt | head -n 1
ii  apt                                         0.8.10.3                       Advanced front-end for dpkg

Grab the appropriate deb package from [http://ie.archive.ubuntu.com/ubuntu/pool/main/a/apt/][1] (I took the link from the linked question -- I'm absolutely not sure, if this is the right repository for your ubuntu version!).

Then you can try to remove apt from your system

$ dpkg -r apt

and reinstall it:

$ dpkg -i apt_[...].deb

dpkg -r does not touch the conffiles, so if that does not work, you can try to use dpkg -P apt, which does a purge and removes also the conffiles (from man dpkg: Conffiles are configuration files that are listed in the DEBIAN/conffiles control file)

share|improve this answer
    
Thanks. I get dpkg: dependency problems prevent removal of apt: ubuntu-minimal depends on apt. unattended-upgrades depends on apt. ubuntu-extras-keyring depends on apt. –  user224461 Sep 15 '13 at 18:31
    
@user224461: You can force the removal with dpkg --force-all -r apt. But please double-check that you have the correct deb package of apt at hand! –  mpy Sep 15 '13 at 18:36
    
Ok thanks. How do I know which of the apt packages I need? (32-bit ubuntu 13.04) I have apt 0.9.7.7 apt_0.9.7.7ubuntu5_i386.deb? apt_0.9.7.7ubuntu4_i386.deb? or apt_0.9.7.5ubuntu5_i386.deb? apt_0.9.7.5ubuntu5.5_i386.deb.. –  user224461 Sep 16 '13 at 9:03
    
Since you have apt 0.9.7.7 it is one of the apt_0.9.7.7 packages. But I don't know what's the difference between the ubuntu4 and ubuntu5 suffix, as I don't use Ubuntu myself, sorry. –  mpy Sep 16 '13 at 9:27
    
Many thanks, it worked by "sudo dpkg --force-all -r apt" then i tried "dpkg -i apt_[...].deb" with the ubuntu5 version of the .deb file but got an error removed again and reran with the ubuntu4 –  user224461 Sep 16 '13 at 20:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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