Amazon Linux: "apt-get: command not found"
Asked Answered
I

12

182

I'm trying to install an Apache server on my AWS instance. However, it seems that it doesn't have the apt package installed.

I googled and all I found was some broken links to this package. I am using PuTTY on a Windows machine if that information helps.

I currently have low to none experience in Linux environments.

I am running the following version of Linux:

Linux ip-172-31-37-96 3.14.48-33.39.amzn1.x86_64 #1 SMP Tue Jul 14 23:43:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

How can I fix this problem?

Infestation answered 15/9, 2015 at 18:17 Comment(1)
When creating the server in the EC2 dashboard, choose "ubuntu linux" as the server type.Shanks
B
373

If you're using Amazon Linux it's CentOS-based, which is RedHat-based. RH-based installs use yum not apt-get. Something like yum search httpd should show you the available Apache packages - you likely want yum install httpd24.

Note: Amazon Linux 2 has diverged from CentOS since the writing of this answer, but still uses yum.

Bemire answered 15/9, 2015 at 18:26 Comment(3)
Add -y to yum to avoid yum prompting question to your script.Santiagosantillan
Adding to Steven's comment -> yum -y install <package name>Douai
@Asif Why would you ask that here, in the comments of a six year old thread about something else entirely?Bemire
R
29

Try to install your application by using a YUM command:

yum install application_name

Rhpositive answered 22/7, 2016 at 10:50 Comment(0)
C
7

Check the Linux distribution. apt-get works in a Debian-based distribution whereas yum works in a Fedora-based distribution.

Ref: How to know the distribution name. Execute command cat /etc/*-release

It is also possible your system administrator does not permit you (or did not put you in the group of users who have sudo permissions) to execute apt-get, but if you have sudo access, try to execute with sudo apt-get <package_name> if Debian or yum install <package_name> if you are using Fedora.

Cartan answered 21/8, 2017 at 20:52 Comment(0)
D
5

I faced the same issue regarding apt-get: command not found. Here are the steps how I resolved it on Ubuntu 16.04 (Xenial Xerus):

  • Search the appropriate version of apt from here (apt_1.6.13_amd64.deb for Ubuntu 16.04)

  • Download the apt.deb

wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.13_amd64.deb

  • Install the apt.deb package

sudo dpkg -i apt_1.6.13_amd64.deb

Now we can easily run

sudo apt-get install htop

Darcie answered 8/12, 2017 at 6:13 Comment(5)
This URL is broken?Linguistician
use security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.8.1_i386.debBaptist
instead just go here and search for the version and distro, avoiding waiting for URL to brokeGaidano
wget security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.9.4_amd64.debWheelbase
Latest is security.ubuntu.com/ubuntu/pool/main/a/apt/apt_2.3.9_amd64.debCroteau
T
2

This answer is for complete AWS beginners:

I had this issue, but it was because I was trying to run a command from a tutorial inside my Mac computer. I actually needed to SSH into my AWS machine, and then run the same command there. Ta Da, it worked:

Enter image description here

Click this button in your EC2 instance, to be able to copy the SSH command. Set up your SSH keys ("Amazon EC2 key pairs and Linux instances") and then you can SSH into your machine.

Once here, you can run your sudo apt-get command.

Truman answered 16/6, 2020 at 3:34 Comment(0)
B
2

There can be two issues:

  1. Your are trying the command on a machine that does not support the apt-get command because apt-get is only suitable for Linux-based Ubuntu machines; for Mac, try the apt-get equivalent such as Homebrew (executable brew)

  2. The other issue can be that your installation was not completed properly, so:

The short answer

Reinstall Ubuntu from a live CD or USB stick.

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 or USB to your hard disk drive.

Or

Do a reinstall or repair over the broken system again with the live CD or USB stick.

Or

Download the .deb file for apt-get and install as explained in the previous posts.

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

Bartz answered 4/7, 2020 at 7:39 Comment(0)
D
1

apt–get: command not found

For Debian based Linux distributions:

Try to use sudo apt install <package> instead of the usual sudo apt-get install <package>

From man apt

apt provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options better suited for interactive usage by default compared to more specialized APT tools like apt-get(8) and apt-cache(8).

Dufresne answered 23/9, 2019 at 14:51 Comment(0)
S
1

Use YUM with sudo for Amazon Linux 2 AMI (HVM), SSD Volume Type.

Example: Try to install WSGI with Apache at an AWS instance:

sudo yum install python3-pip apache2 libapache2-mod-wsgi-py3
Swiercz answered 2/2, 2021 at 9:1 Comment(1)
How to install Font 'Arial'?Phosphide
S
0

You need to manually download the APT .deb package. Then run dpkg and it should install.

Sikora answered 15/9, 2015 at 18:21 Comment(3)
I went to packages.debian.org/search?keywords=apt and there are a list of options: squeeze (oldoldstable), squeeze-lts, wheezy (oldstable), jessie (stable) and experimental (rc-buggy) that are not listed as unstable or testing. Which one should I get?Infestation
None of them. There's no reason to install apt on an Amazon Linux server.Bemire
Yeah. I totally skipped over the word AWS. That's not a Debian server. Go with ceejayoz's answer.Sikora
P
0

This is one of the commands which you can run to install apt-get:

wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.4_amd64.deb
Phillip answered 28/6, 2018 at 13:57 Comment(1)
the link is broken.Lx
H
0

For an openSUSE Linux distribution:

sudo zypper install <package>

For example:

sudo zypper install git
Harville answered 21/4, 2020 at 12:0 Comment(0)
C
0

Try running

sudo amazon-linux-extras install nginx1

Nginx is also available on Amazon Linux Extras.

Cortico answered 30/6, 2021 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.