Home

Software Management

Overview

I worked on the following objectives:

Task 2: Updating My Linux Machine

In this task, I used the yum package manager to update and upgrade the machine, including relevant security packages.

I had to use sudo to complete this task since I was not root.

First, I validated that I was in the companyA home folder by entering:

pwd

Since I wasn't in the correct folder, I entered:

cd companyA

To query repositories for available updates, I entered:

sudo yum -y check-update

To apply security-related updates, I entered:

sudo yum update --security

To update packages, I entered:

sudo yum -y upgrade

Figure: Once the sudo yum -y upgrade command is ran, the packages are updated and the system will let you know that you are running the current updated version.

My instance was already up to date. But I still ran through the commands for practice.

To view the install of httpd and view the history of updates, I entered:

sudo yum install httpd -y

This command installed httpd and also showed a list of all previous updates and current packages on the instance.

Task 3: Rolling Back a Package

In this task, I downgraded a package that had been updated through the yum package manager by doing the following:

I had to use sudo to complete this task since I was not root.

First, I validated that I was in the companyA home folder by entering:

pwd

To view the history of updates, I entered:

sudo yum history list

In the output, under the ID column, I made a note of the number for EC2 ... to use in the following steps in this task.

Figure: Once the sudo yum history-list command is finished running, two users will appear (ec2-user and System) with the date, time, and actions that they did. It also shows how many files that were altered.

[ec2-user@ companyA]$ sudo yum history list Loaded plugins: extras_suggestions, langpacks, priorities, update-motd ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------ 2 | EC2 ... <ec2-user> | <date and time> | Install | 9 1 | System <unset> | <date and time> | I, O, U | 18 history list

To view the most recent set of updates, I entered:

sudo yum history info <#>

I replaced <#> with the history list number from the previous step.

The number is found at the top of the history list from step 2.

Figure: Information from the sudo yum history info <#> command shows the following information: begin time, begin rpmdb, end time, end rpmdb, user, return-code, and command line.

[ec2-user@ companyA]$ sudo yum history info <#> Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Transaction ID : <#> Begin time : <date and time> Begin rpmdb : End time : <time> End rpmdb : User : EC2 Default User <ec2-user> Return-Code : Success Command Line : install httpd -y

Then I entered:

sudo yum -y history undo <#>

I replaced <#> with the history list number from the previous steps.

Once the sudo yum -y history undo 2 command is ran, it now shows many packages as dep-install.

[ec2-user@ companyA]$ sudo yum -y history undo <#> Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Undoing transaction <#>, from <date> <list of actions now shown as Dep-Install>

Task 4: Installing the AWS CLI on Red Hat Linux

In this task, I installed the AWS CLI on Amazon Elastic Compute Cloud (Amazon EC2) Linux by:

I had to use sudo to complete this task since I was not root.

To verify that Python was installed, I entered the following command:

python3 --version

The output indicated the version of Python that was installed.

To install the AWS CLI, you must have Python 2 version 2.6.5 or later, or Python 3 version 3.3. If one of these versions is not already installed, go to the Python website and install.

To see if the pip package manager was already installed, I entered:

pip3 --version

"bash: pip: command not found" indicated this Red Hat instance did not have pip installed.

The primary distribution method for the AWS CLI on Linux, Windows, and macOS is pip. pip is a package manager for Python that provides you with an easy way to install, upgrade, and remove Python packages and their dependencies.

In order to install the AWS CLI, I downloaded the installation file using the curl command.

The -o option specifies the file name that the downloaded package is written to. The options on the following example command write the downloaded file to the current directory with the local name awscliv2.zip.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

I unzipped the installer.

The following example command unzips the package and creates a directory named aws under the current directory.

unzip awscliv2.zip

Then I ran the install program.

The installation command uses a file named install in the newly unzipped aws directory. By default, the files are all installed to /usr/local/aws-cli, and a symbolic link is created in /usr/local/bin. The command includes sudo to grant write permissions to those directories.

sudo ./aws/install

To verify that the AWS CLI was now working, I entered:

aws help

The help command displayed the help information for the AWS CLI.

At the : prompt, I entered q to exit.

At the top of the page above these instructions, I chose the Details dropdown menu, and then chose Show. A Credentials window opened.

In the Credentials window next to AWS CLI, I chose Show. This option displayed AWS CLI credentials, including the aws_access_key_id and aws_secret_access_key. I copied and pasted these two keys into a text editor to use in the next task.

There is no way for you to retrieve the secret access key that must be used when configuring the AWS CLI unless it was captured at the time that the keys were created. Fortunately, the secret access key was captured when it was created.

Task 5: Configuring the AWS CLI to Connect to My AWS Account

I returned to my terminal window and entered the following configuration command for the AWS CLI:

aws configure

At the prompts, I entered the following information:

After the information was entered, the appropriate credential files were created automatically.

To open the credential file, I entered the command:

sudo nano ~/.aws/credentials

Then I pasted the entire section copied from the Details window from task 4 into the file.

For example:

[default] aws_access_key_id=<your access key ID> aws_secret_access_key=<your access key> aws_session_token=<your session token>

I pressed ctrl + O to save and pressed enter to save the file as the original file name.

I pressed ctrl + X to exit the file.

Next, I needed to find my instance ID. At the top of my screen above these instructions, I chose AWS to open the AWS Management Console in a new tab.

At the top of the console page in the Search for service search box, I entered EC2 and chose EC2.

In the Resources section, I chose Instances (running).

There was one instance called Command Host. I copied and pasted the Instance ID for the Command Host into a text editor to use in the following step.

I returned to my terminal, and entered the following command, replacing <i-1234567890abcdefg> with the instance ID that I copied from the previous step. This command describes the instance attributes.

aws ec2 describe-instance-attribute --instance-id i-1234567890abcdefg --attribute instanceType

The output looked like the following (with my instance ID instead of <i-1234567890abcdefg>):

{ "InstanceId": "i-1234567890abcdefg" "InstanceType": { "Value": "t3.micro" } }

Related Topics