Vim Commands Cheat Sheet

:wq {file}

:e[dit] {file}

i  insert
dd  delete [count] lines



echo $varname

Don't forget chmod +x filename

Amazon Linux

Amazon Linux Basics

Adding Packages

sudo yum update -y                  # all packages
sudo yum install -y package_name
sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd

Start a Service

sudo service docker start
sudo service jenkins start
sudo service nginx start

Autostarting a service on Amazon Linux

# check a service is configured for startup
sudo chkconfig sshd
echo $?  # 0 = configured for startup
# or
sudo chkconfig --list mysqld
sudo chkconfig --list         # all services

# add a service
sudo chkconfig --add vsftpd
sudo chkconfig mysqld on
sudo chkconfig --level 3 httpd on  # specific runlevel

Linux Boot Process

You can also use a /etc/rc.d/rc.local script.

Running Commands on your Linux Instance at Launch

  • Paste a user data script into the User data field
yum update -y
yum install -y httpd24 php56 mysql55-server php56-mysqlnd
service httpd start
chkconfig httpd on
groupadd www
usermod -a -G www ec2-user
chown -R root:www /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} +
find /var/www -type f -exec chmod 0664 {} +
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

File location: /etc/sysconfig/cloudinit

Cloud-init output log file: /var/log/cloud-init-output.log

Install the SSM Agent on EC2 Instances at Start-Up

cd /tmp
curl https://amazon-ssm-region.s3.amazonaws.com/latest/linux_amd64/amazon-ssm-agent.rpm -o amazon-ssm-agent.rpm
yum install -y amazon-ssm-agent.rpm

Linux desktop

How can I connect to an Amazon EC2 Linux instance with desktop functionality from Windows?