Fri, Dec 30, 2022
Read in 2 minutes
When you want to quickly configure a Linux-based Amazon EC2 instance.
Linux comes in so many flavors that beginners and intermediate users alike are constantly learning new things. No wonder there are thousands of blogs and articles, and even full websites dedicated to tracking this vast landscape and ever-evolving variants.
What would help is a set of universal Linux commands that you can make part of your standard repertoire to help you quickly home in on the vitals of the specific instance at hand.
Here are a few that always come in handy.
cat /etc/os-release
$ 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/"
This will help you quickly determine which package manager you can use to install or upgrade packages.
Linux Distribution | Linux Package Manager |
---|---|
REHL | Yum |
Ubuntu / Debian | Apt |
Arch | Pacman |
Gentoo | Portage |
Zyper | Open Suse |
uname -a
uname -m
$ uname -a
Linux ip-172-31-119-209.ap-south-1.compute.internal 5.10.157-139.675.amzn2.x86_64 #1 SMP Thu Dec 8 01:29:11 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ uname -m
x86_64
This example above confirms that we are running on x86 64-bit architecture.
Another command that gives us information about the machine including the kernel and architecture is
hostnamectl
$ hostnamectl
Static hostname: ip-172-31-119-209.ap-south-1.compute.internal
Icon name: computer-vm
Chassis: vm
Machine ID: ec27d6ed5bca7925c09eebd91d3d3675
Boot ID: 06d31d10f8c54e9ab5f8d927408dbcbf
Virtualization: amazon
Operating System: Amazon Linux 2
CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2
Kernel: Linux 5.10.157-139.675.amzn2.x86_64
Architecture: x86-64