Amazon Linux 2

Amazon Linux 2

Amazon Linux 2 is the next generation of Amazon Linux, a Linux server operating system from Amazon Web Services (AWS). It provides a secure, stable, and high performance execution environment to develop and run cloud and enterprise applications. With Amazon Linux 2, you get an application environment that offers long term support with access to the latest innovations in the Linux ecosystem. Amazon Linux 2 is provided at no additional charge.

Package update

  sudo yum update

Get system info

  cat /etc/image-id
  cat /etc/system-release

Mount a volume (EBS)

# Get drives info 
suod lsblk
# Get volumen info
sudo file -s /dev/xvdf
# Format volumne
sudo mkfs -t xfs /dev/xvdf
# Mount volume to folder data
sudo mkdir /data
sudo mount /dev/xvdf /data 

Extend the EBS

sudo xfs_growfs -d /data

Auto attached volume

sudo cp /etc/fstab /etc/fstab.orig

sudo lsblk -o +UUID
# You will see similar output below
# xvda    202:0    0  20G  0 disk
# └─xvda1 202:1    0  20G  0 part /          e75a1891-3463-448b-8f59-5e3353af90ba
# xvdb    202:16   0  60G  0 disk /data      897b5130-c5c1-4ac9-aae3-699d1eaa9fd5

# Use vim to edit /etc/fstab
sudo vim /etc/fstab

# Add following line 
# UUID=897b5130-c5c1-4ac9-aae3-699d1eaa9fd5  /data  xfs defaults,nofail  0  2

# Verify the mounting
sudo umount /data
sudo mount -a


Add new user

  • Add new user without password

    sudo adduser new_user 
    ## Add user without password 
    sudo adduser new_user  --disabled-password
  • Switch to new user

    sudo su - new_user
  • Set password for new user

    sudo passwd new_user
  • Allow the new user to use sudo

    sudo usermod -aG wheel new_user

Install MySql

  • Install MySql 5.7

    # Add repo
    sudo wget
    sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm 
    # Install mysql
    sudo yum install mysql-community-server
  • MySql configuration file sits in /etc/my.cnf

  • Update data directory

    # backup original one
    sudo cp /etc/my.cnf /etc/my.cnf.orig
  • Use vim to update the data directory


Start MySql as service

  • Install polkit before start the service, otherwise you will get error

    sudo yum install polkit
  • Enable & Start mysql

    sudo systemctl enable mysqld.service
    sudo systemctl start mysqld.service
  • Find the temporay password created for root in /var/log/mysql.log

    sudo cat /var/log/mysql.log | grep "temporary password"
    # output
    # [Note] A temporary password is generated for root@localhost: l<C-eX&GW8?m

Reset root password

  sudo mysql_secure_installation

Create remote login credentials

CREATE USER 'user_id'@'localhost' IDENTIFIED BY 'your_secret';
CREATE USER 'user_id'@'%' IDENTIFIED BY 'your_secret';

GRANT ALL ON *.* TO 'user_id'@'localhost';
GRANT ALL ON *.* TO 'user_id'@'%';

Install AWS CLI

# Install aws cli without sudo 
curl "" -o ""
./awscli-bundle/install -b ~/bin/aws

# Configure cli 
aws configure
AWS Secret Access Key [None]: wJ37hsfSFJSDfhsfihakhfakhfu9763Fhshfsuff
Default region name [None]: region-code
Default output format [None]: json

Install EKS

curl --silent --location "$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
ekstool --version

Install kubectl

curl -o kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin

Install EPEL repository

## Amazon Linux 1 / 2
sudo yum install -y
sudo yum update

## Amazon Linux 2
sudo amazon-linux-extras install epel