n0obcoder
n0obcoder

Reputation: 727

How to install apt-get on AWS EC2 instance?

I am using an instance of AWS EC2. I want to use apt-get command, but it throws an error: 'apt-get not found'

How do i get to use apt-get command?

Upvotes: 4

Views: 12689

Answers (1)

Marcin
Marcin

Reputation: 238051

For exact details of your Linux distro you can use command

cat /etc/os-release

Its example output for Ubuntu (default user is ubuntu) is:

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

while for Amazon Linux 2 (default user is ec2-user):

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

Since it seems you are using Amazon Linux 2, you should use yum to install and updated your packaged, not apt nor apt-get,e.g.:

sudo yum update

Alternatively, when you create your instance, choose Ubuntu image for your it, rather then default Amazon Linux 2.

Upvotes: 8

Related Questions