Day 3 | EC2-Instance Creation | MobaXterm Connect to EC2 | Simple Linux Commands

Gaurav DakshGaurav Daksh
6 min read

EC2-Instance Creation on AWS:

What is EC2:

Amazon EC2 (Elastic Compute Cloud) instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure. EC2 allows users to rent virtual computers on which to run their own computer applications. Here are some key features of an EC2 instance:

  1. Scalability: You can quickly scale up or down the number of instances based on demand.

  2. Instance Types: EC2 offers various instance types optimized for different use cases, including compute-optimized, memory-optimized, and storage-optimized instances.

  3. Regions and Availability Zones: Instances can be launched in different geographic regions and availability zones to enhance redundancy and reduce latency.

  4. AMI (Amazon Machine Image): An AMI is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance.

  5. Elastic Block Store (EBS): Provides persistent block storage volumes for use with EC2 instances. Each EBS volume is automatically replicated within its availability zone to protect you from component failure.

  6. Security Groups: Act as a virtual firewall to control inbound and outbound traffic to your instances.

  7. Key Pairs: Securely login to your instances using SSH for Linux instances and RDP for Windows instances.

  8. Elastic IP Addresses: Static IP addresses designed for dynamic cloud computing, allowing you to mask instance or availability zone failures by rapidly remapping your public IP addresses to any instance in your account.

EC2 is highly flexible and widely used for a variety of applications, from web hosting and batch processing to large-scale enterprise applications.

EC2-Instance Creation:

  1. Go to your aws.amazon.com and log into your account.

  2. Go to your dashboard -

  3. Click on EC2 or go to services > go to Compute \> Click on EC2.

  4. Click on Instance(running).

  5. No Instance is running here So click on Launch Instances.

  6. Here Give any name to your instance (Practice Ubuntu Instance).

    Select any image Linux, Ubuntu, Windows, RedHat, etc. Keep Ubuntu Free tier eligible.

  7. Create a new key pair and select the .pem key for the Ubuntu machine or use the .ppk key to connect with the Windows machine or Putty software.

  8. Don't make any other changes and directly click on Launch Instance.

  9. Now instance is created successfully. Click on the instance number and wait for the instance to be up and running, also status check should be 2/2 for an instance to run.

  10. Click on instance and we will get a Public IPv4 address to connect with any machine.

Connect EC2-Instance with MobaXterm:

  1. MobaXterm is a toolbox for remote computing.

  2. Go to https://mobaxterm.mobatek.net/download-home-edition.html and download MobaXterm Home Edition(Installer Edition).

  3. Install MobaXterm and Open it. Click on Session \> Click on SSH \> Put your public IP in the Remote host section > Specify username (Default username for Ubuntu is ubuntu) > Put Private Key and select OK.

  4. Now our Ubuntu machine is up and running. So Let's start with Linux Comments.

Linux Commands:

There are some simple Commands:

  1. ls : This command is used to list the content of a directory

  2. ls -l : it will show the owner, filesize, and permissions of the files and directories

  3. ls -la : it will show the hidden files as well

  4. sudo : this command is used for performing root privileges commands

  5. pwd : this command will print your current directory location

  6. cat : this command will be used to open the files
    cat -n : this adds line numbers to files

  7. vi or vim : this is a text editor used in Linux.

    normal mode: it's the default mode

    insert mode: in insert mode, you can type text into the file. To enter insert mode, you need to press the 'i' button

    command mode: to enter command mode, you need to press the ESC button and then ':' In command mode, if you want to save, you have to give wq!

  8. grep : this command searches for a particular string/word in a file

  9. sort : this command is used to sort the results of the search either alphabetically or numerically. it also sorts files and dir's

  10. tail : this command prints the last N number of data of the given input. By default, it prints 10 lines

  11. head : This command prints the first N number of data of a given input. By default, it prints 10 lines

  12. chmod : this command is used to change the permissions of the files and directories

  13. chown : this command is used to change the ownership of the files and directories

  14. ping : this command will ping a host or IP to check the connection

  15. lsof : it will display all the open files on a Linux OS

  16. ifconfig : it will print all the network information like IP, subnet, and MAC address

  17. id : will be used to get the ID info of the user and group

  18. sed : it stands for "stream editor". it will be used to edit text files in a Linux sed s/aws/azure/g

    file.txt : wherever aws is there in that file, it will be replaced with Azure

  19. diff : this command is used to find the difference between two files # diff file1 file2

  20. history : it will print all previous commands executed by the user.

  21. find : this command is used to find files and directories

    find . -name "*.txt" : it will print all files which end with .txt in that path

  22. free : this command is used to print memory details

  23. ssh user@host : to connect the server through ssh

  24. ssh-keygen : this is used to generate public/private keys for that user

  25. nslookup or dig : this stands for "Name server lookup". it will be used to check DNS server info

  26. yum : this command will be used to install packages with dependencies in Redhat, centos, and Amazon Linux

  27. rpm : it is used to install particular packages without dependencies in Redhat, centos, and Amazon Linux

  28. apt-get : it is used to install packages on Ubuntu Linux server sample commands: for installing:

    yum install package-name apt-get install pkg-name rpm -ivh pkg-name

    for deleting :

    yum remove package-name apt-get remove pkg-name rpm -e pkg-name

    for updating:

    yum update package-name apt-get update pkg-name rpm -Uvh pkg-name

  29. netstat : this command will used to print all opening ports

  30. df : it prints the complete used and available disk space in the system

  31. du : it is used to print disk utilization of files and directories

  32. top: it is used to monitor the system's resources and processes that are running in real-time.

  33. ps : we use the ps command to check the ID of the processes which are running on the server

    ps -a: show process for all users ps -u

    username : show process for a particular user

  34. kill : this command is used to kill the processes

  35. chage : command will be used to change the password fields.

  36. rm -rf : to delete files

  37. rmdir : to delete directories 38

    cp: to copy files from one location to another location

  38. mv : to rename files or directories

  39. ln : to create a hard link to the file

  40. ln -s : to create a soft link to the file

  41. uname -a : to see all the information about the system

  42. uname -r : to see only kernel info

  43. cat /etc/os-release : os information

  44. wc : it shows no of lines and words of file

    wc -l filename : shows lines

    wc -w filename : show words

  45. w : it prints user logged info

  46. uptime : server uptime information

0
Subscribe to my newsletter

Read articles from Gaurav Daksh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gaurav Daksh
Gaurav Daksh