I have new created EC2 instance in aws, and able to login as EC2-user using private key but want to login as root to install packages. Not able to switch as root tried sudo - but it asking for password, I didn't creat any password for root yet. I am stuck here
Asked
Active
Viewed 2.2k times
2 Answers
12
For Amazon Linux 2 you can use sudo su
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ cat /etc/os-release
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/"
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo su
[root@ip-xxx-xxx-xxx-xxx ec2-user]# whoami
root
Everett Toews
- 221
0
It's working now, need to create password for root by typing "passwd" command and set password for root. To switch user "su root" command.