15

Lately some really bad things have been happening with my computer, having to do with lack of icons and all kinds of bad things going with my graphical interface. All the bad things in the appeal are accompanied by a certain disability of my terminal. I'm using 12.04 with Gnome Classic view with no effects.

Let's have a sudo apt-get update.

I get sudo: apt-get: command not found message. And it is the way it goes with all my apt-get commands.

What can it mean? How to fix this, especially concerning all the other problems I'm experiencing?

muru
  • 197,895
  • 55
  • 485
  • 740
Barnaba X
  • 153
  • 1
  • 1
  • 4
  • locate apt-get should turn up /usr/bin/apt-get/. If not, see if the file is actually there. Then check the $PATH: echo $PATH. Tell us what you find. – Jos Jul 03 '14 at 18:37
  • @Jos Good shot, 'locate apt-get' turns back nothing. In '/usr/bin' there is no file; 'echo $PATH' throws back something like this: /home/bakuhatsu/.rvm/gems/ruby-2.0.0-p0/bin:/home/bakuhatsu/.rvm/gems/ruby-2.0.0-p0@global/bin:/home/bakuhatsu/.rvm/rubies/ruby-2.0.0-p0/bin:/home/bakuhatsu/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games – Barnaba X Jul 03 '14 at 18:47
  • 5
    Is /usr/bin/ completely empty? In that case, your only option is to reinstall Ubuntu. Or is there just no file apt-get? Then download and manually install the apt package, as follows: look at your /etc/apt/sources.list to find the correct mirror, then go to that mirror, to the pool/main/a/apt/ directory, download the correct .deb file for your architecture, and install it with sudo dpkg -i apt-xxx.deb. – Jos Jul 03 '14 at 18:59
  • No, the folder contains all kinds of files, yet the /usr/bin/apt-get is missing. Which one should I choose from source.list? They're mostly .gz files, but I guess it makes no difference – Barnaba X Jul 03 '14 at 20:44
  • @Jos I am also suffering exactly from the problem mentioned above , but in my case "locate apt-get" is giving desired result . What should I do now ??? Please help.... – Rahul Raj Jul 31 '16 at 18:32
  • Why don't you just use apt? Google apt-get vs apt. – Mohammad Kholghi Aug 22 '19 at 06:48

4 Answers4

8

I faced the same issue regarding apt-get: command not found here are the steps how I resolved it on Ubuntu Xenial

  • Search the appropriate version of apt from here (apt_1.4_amd64.deb for ubuntu xenial)

  • Download the apt.deb

    wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.4_amd64.deb
    
  • Install the apt.deb package

    sudo dpkg -i apt_1.4_amd64.deb
    

Now we can easily run

sudo apt-get install <Package_Name>
derHugo
  • 3,356
  • 5
  • 31
  • 51
cmthakur
  • 181
  • I was on the verge of putting my work system on a fresh installation. But this fortunately does the trick for me. Thank you. – fluffyBatman Jan 27 '19 at 05:37
  • This answer helped me. Sometimes re-installing everything as the selected answer proposes is not an option. You'll need to Google the correct place for the up todate packages. – joscas Sep 01 '20 at 15:01
  • 2
    And what if I get dpkg command not found? – Pathros Oct 26 '22 at 19:31
  • This worked for me withour reinstalling the whole OS. With the same approach I had to download and install the apt dependency. – dg3 Jul 06 '23 at 07:49
7

The short answer:

Re-install Ubuntu from a Live CD or USB.

The long version:

The long version would be a waste of your time: your system will never be clean, but if you insist you could try:

  • copying everything (missing) except for the /home folder from the Live CD/USB to your HDD.

OR

  • do a re-install/repair over the broken system again with the Live CD / USB stick.

OR

  • download the deb file for apt-get and install as explained on above posts.

I would definitely go for a fresh new install as there are so many things to do and so little time.

Fabby
  • 34,259
Goksu
  • 299
  • I'm afraid it might end this way. I am growing curious for the reason it turned broken in the first place, though. Any ideas? – Barnaba X Jul 03 '14 at 20:04
  • 5
    This could have happened because of an interrupted install (power outage, bad drive, no space on drive, cat walking on keyboard, jealous girl/boyfriend, quantum anomaly, aliens having a laugh). or a result of playing around with the file system changing permissions, removing files, broken APP/other resource dependency problem etc. I've done it, had it all. :) – Goksu Jul 03 '14 at 20:59
4

If you are on aws ec2 use yum instead.

Source: https://stackoverflow.com/questions/14045262/how-to-fix-apt-get-command-not-found-on-aws-ec2

0

I was facing the same issue. I ran echo $PATH but couldn't find /usr/bin in the PATH.

I ran export PATH=$PATH:/usr/bin/, and then everything works fine.

Benjamin R
  • 2,952
  • 1
  • 13
  • 20
  • Hi Fatima, welcome to Ask Ubuntu. Just fyi: export PATH=$PATH will use all the current value in $PATH, so to append /usr/bin/ and leave everything else alone, all you need to do is export PATH=$PATH:/usr/bin/. This is important for the answer as lots of people just copy and paste from Stack Exchange sites and they might not want $JAVA_HOME or anything else appended to their PATH by mistake. Thanks for your contribution. – Benjamin R Aug 22 '19 at 09:05
  • Anyone wanting to quickly check if /usr/bin is in their path can run echo $PATH | grep :/usr/bin:. If that returns nothing, double-check with echo $PATH | grep -P "^\Q/usr/bin\E". – Benjamin R Aug 22 '19 at 09:12