Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Basics of Working with EC2 Instance | EC2 Overview
course content

Contenido del Curso

Cloud Technologies Introduction

Basics of Working with EC2 InstanceBasics of Working with EC2 Instance

Let's start working with the instance. As you may have understood from the previous chapter, all the work with the instance will happen in the Linux system, and we will manage it through the console. We'll manage the instance using the bash language, which you can also use to control your computer.

Let's take a look at the list of basic navigation commands in bash to understand what we'll be doing next:

Command Usage Description
pwd - Prints the full path to the current working directory.
cd cd /path/to/directory Changes the current directory to the specified path. Use 'cd ..' to move to the parent directory.
ls ls -l, ls -a Lists files and directories in the current directory. Use '-l' for a detailed list and '-a' to include hidden files.
mkdir mkdir new_directory Creates a new directory.
rmdir rmdir directory Removes an empty directory.
rm rm file, rm -r directory Removes files or directories. Use '-r' to remove directories and their contents recursively.
cp cp source destination Copies files or directories from the source to the destination. Use '-r' to copy directories.
mv mv old_name new_name Moves or renames files and directories.
touch touch filename Changes file timestamps or creates an empty file if it does not exist.
cat cat file Displays the contents of a file on the screen.
less, more less file, more file Displays the contents of a file page by page. 'less' allows backward navigation, whereas 'more' does not.

Installation of Updates and Programs

First, we need to make sure that all the necessary updates are installed on the system. We'll do this using the following command:

Code Description

sudo: This part of the command runs the following command as the superuser (root). It grants the command administrative privileges, which are necessary for making system-wide changes such as updating software.

yum: This is the package manager used by certain Linux distributions. Yum stands for "Yellowdog Updater, Modified" and is used to manage RPM (Redhat Package Manager) packages.

update: This option tells yum to update all packages to the latest versions that are available in the repository databases.

-y: This flag automatically answers "yes" to any prompts that might come up during the execution of the command. It allows the update process to run to completion without user interaction, which is useful for automated scripts or when you don’t want to manually confirm each update.

After executing this command, the system will start automatically updating and installing the necessary components:

As you can see, in my case, there was nothing to download, and everything was already installed. However, it is highly recommended that this command be used during the initial instance setup to avoid future errors.

Since we own this instance and have the right to do whatever we want with it, we can confidently switch to the root user.

The root user is a superuser who has access to all commands and system configurations. Such a superuser even outranks a network administrator in the hierarchy.

To switch to superuser mode, use the command sudo su. Now, we can try out some commands on our instance.

For example, let's create a folder named test_folder. Inside this folder, we'll create a file named README.txt and write "This is an EC2 instance!" in it.

Our commands will look like this:

  1. mkdir test_folder - Create a folder with the desired name;
  2. cd test_folder/ - Navigate to the folder we just created;
  3. touch README.txt - Create a file with the desired name and extension;
  4. echo "This is an EC2 instance!" > README.txt - Write the desired text to the corresponding file;
  5. cat README.txt - Display the contents of the text file we created.

As a result, the following will be printed to the console:

Thus, we can manage our instance through the console.

You're probably interested in something completely different, and you want to host a website on your EC2 instance, right?

Don't worry; in the next chapter, we'll host our portfolio website on the instance and access it via a link. This will be your first fully-fledged website hosted in the cloud on an Amazon server!

1. What command do you use to change the current directory to a specified path?
2. How would you update your system and install necessary components using the command line?

What command do you use to change the current directory to a specified path?

Selecciona la respuesta correcta

How would you update your system and install necessary components using the command line?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 3. Capítulo 5
course content

Contenido del Curso

Cloud Technologies Introduction

Basics of Working with EC2 InstanceBasics of Working with EC2 Instance

Let's start working with the instance. As you may have understood from the previous chapter, all the work with the instance will happen in the Linux system, and we will manage it through the console. We'll manage the instance using the bash language, which you can also use to control your computer.

Let's take a look at the list of basic navigation commands in bash to understand what we'll be doing next:

Command Usage Description
pwd - Prints the full path to the current working directory.
cd cd /path/to/directory Changes the current directory to the specified path. Use 'cd ..' to move to the parent directory.
ls ls -l, ls -a Lists files and directories in the current directory. Use '-l' for a detailed list and '-a' to include hidden files.
mkdir mkdir new_directory Creates a new directory.
rmdir rmdir directory Removes an empty directory.
rm rm file, rm -r directory Removes files or directories. Use '-r' to remove directories and their contents recursively.
cp cp source destination Copies files or directories from the source to the destination. Use '-r' to copy directories.
mv mv old_name new_name Moves or renames files and directories.
touch touch filename Changes file timestamps or creates an empty file if it does not exist.
cat cat file Displays the contents of a file on the screen.
less, more less file, more file Displays the contents of a file page by page. 'less' allows backward navigation, whereas 'more' does not.

Installation of Updates and Programs

First, we need to make sure that all the necessary updates are installed on the system. We'll do this using the following command:

Code Description

sudo: This part of the command runs the following command as the superuser (root). It grants the command administrative privileges, which are necessary for making system-wide changes such as updating software.

yum: This is the package manager used by certain Linux distributions. Yum stands for "Yellowdog Updater, Modified" and is used to manage RPM (Redhat Package Manager) packages.

update: This option tells yum to update all packages to the latest versions that are available in the repository databases.

-y: This flag automatically answers "yes" to any prompts that might come up during the execution of the command. It allows the update process to run to completion without user interaction, which is useful for automated scripts or when you don’t want to manually confirm each update.

After executing this command, the system will start automatically updating and installing the necessary components:

As you can see, in my case, there was nothing to download, and everything was already installed. However, it is highly recommended that this command be used during the initial instance setup to avoid future errors.

Since we own this instance and have the right to do whatever we want with it, we can confidently switch to the root user.

The root user is a superuser who has access to all commands and system configurations. Such a superuser even outranks a network administrator in the hierarchy.

To switch to superuser mode, use the command sudo su. Now, we can try out some commands on our instance.

For example, let's create a folder named test_folder. Inside this folder, we'll create a file named README.txt and write "This is an EC2 instance!" in it.

Our commands will look like this:

  1. mkdir test_folder - Create a folder with the desired name;
  2. cd test_folder/ - Navigate to the folder we just created;
  3. touch README.txt - Create a file with the desired name and extension;
  4. echo "This is an EC2 instance!" > README.txt - Write the desired text to the corresponding file;
  5. cat README.txt - Display the contents of the text file we created.

As a result, the following will be printed to the console:

Thus, we can manage our instance through the console.

You're probably interested in something completely different, and you want to host a website on your EC2 instance, right?

Don't worry; in the next chapter, we'll host our portfolio website on the instance and access it via a link. This will be your first fully-fledged website hosted in the cloud on an Amazon server!

1. What command do you use to change the current directory to a specified path?
2. How would you update your system and install necessary components using the command line?

What command do you use to change the current directory to a specified path?

Selecciona la respuesta correcta

How would you update your system and install necessary components using the command line?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 3. Capítulo 5
some-alt