How to Install Git on Amazon Linux 2 Easily

0
Install Git on Amazon Linux 2

So before talking about how to install Git on Amazon Linux 2. Let’s get a brief introduction about the Amazon Linux 2 and what it does and why you should use it along with git on it. Amazon Linux 2 is also known as Amazon EC2.

So by its name you can totally guess that it’s Linux Operating System that is from Amazon Web Service. It is a stable, high-performance, and security-focused execution environment and it helps to develop and run cloud applications.  It is specially created and maintained by Amazon Web Service(AWS).

How to Install and Configure Git on Amazon Linux 2

Steps to Implement

  1. Launch Amazon Linux 2 Instance in Desired Region.
  2. Connect to Amazon Linux 2 Instance through Putty.
  3. Run commands to Install & Configure the git.

Launch Amazon Linux 2 Instance in Desired Region

So first you have to launch the Amazon Linux 2. So to do that just open AWS and search for instances on the left-hand side and under instances just click on the launch instance icon.

Connect to Amazon Linux 2 Instance through Putty or Terminal

Now after launching the instance will open putty and you have to write The following code to connect the Amazon Linux 2 instance through putty.

Install Git on Amazon Linux 2 [Configuration]

Info best app you have successfully connected to Amazon Linux 2 instance through putty and now you have to run two commands to install and configure the git.

Open Linux Terminal

So first you have to open a Linux terminal And this full show something like the below code.

Using username "ec2-user".
Authenticating with public key "imported-openssh-key"
 
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
 
https://aws.amazon.com/amazon-linux-2/
5 package(s) needed for security, out of 13 available
Run "sudo yum update" to apply all updates.
[[email protected] ~]$

Switch to root user

Now you have to switch to the root user to install git and to do that write the following code on the terminal.

[[email protected] ~]$ sudo su
[[email protected] ec2-user]#

Install server updates

Now after switching to a super user or root user you have to install the server updates for Amazon Linux 2.

To do that follow the below commands as shown here

[[email protected] ec2-user]# yum update -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 2.4 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package file.x86_64 0:5.11-33.amzn2.0.2 will be updated
---> Package file.x86_64 0:5.11-35.amzn2.0.1 will be an update
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
kernel x86_64 4.14.154-128.181.amzn2 amzn2-core 20 M
python2-rpm x86_64 4.11.3-40.amzn2.0.3 amzn2-core 84 k
replacing rpm-python.x86_64 4.11.3-25.amzn2.0.3
Updating:
file x86_64 5.11-35.amzn2.0.1 amzn2-core 57 k
file-libs x86_64 5.11-35.amzn2.0.1 amzn2-core 339 k
python x86_64 2.7.16-4.amzn2 amzn2-core 92 k
yum noarch 3.4.3-158.amzn2.0.3 amzn2-core 1.2 M
 
Cleanup : yum-3.4.3-158.amzn2.0.2.noarch 15/25
Erasing : rpm-python-4.11.3-25.amzn2.0.3.x86_64 16/25
Cleanup : python-libs-2.7.16-3.amzn2.0.1.x86_64 24/25
Cleanup : rsyslog-8.24.0-16.amzn2.6.1.x86_64 25/25
Verifying : python-libs-2.7.16-4.amzn2.x86_64 1/25
Verifying : file-5.11-35.amzn2.0.1.x86_64 2/25
Verifying : python-2.7.16-4.amzn2.x86_64 3/25
Verifying : file-libs-5.11-33.amzn2.0.2.x86_64 25/25
 
Installed:
kernel.x86_64 0:4.14.154-128.181.amzn2 python2-rpm.x86_64 0:4.11.3-40.amzn2.0.3
 
Updated:
file.x86_64 0:5.11-35.amzn2.0.1 file-libs.x86_64 0:5.11-35.amzn2.0.1
python.x86_64 0:2.7.16-4.amzn2 python-devel.x86_64 0:2.7.16-4.amzn2
python-libs.x86_64 0:2.7.16-4.amzn2 rpm.x86_64 0:4.11.3-40.amzn2.0.3
rpm-build-libs.x86_64 0:4.11.3-40.amzn2.0.3 rpm-libs.x86_64 0:4.11.3-40.amzn2.0.3
rpm-plugin-systemd-inhibit.x86_64 0:4.11.3-40.amzn2.0.3 rsyslog.x86_64 0:8.24.0-41.amzn2.2.1
yum.noarch 0:3.4.3-158.amzn2.0.3
 
Replaced:
rpm-python.x86_64 0:4.11.3-25.amzn2.0.3
 
Complete!

Install Git packages

Now after successfully installing the server updates on Amazon Linux 2 you have to install Git packages to install Git on your system.

To do that follow the below commands as shown here.

[[email protected] ec2-user]# yum install git -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:2.17.2-2.amzn2 will be installed
Dependencies Resolved
 
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
git x86_64 2.17.2-2.amzn2 amzn2-core 217 k
Installing for dependencies:
emacs-filesystem noarch 1:25.3-3.amzn2.0.1 amzn2-core 64 k
git-core x86_64 2.17.2-2.amzn2 amzn2-core 4.0 M
perl-TermReadKey x86_64 2.30-20.amzn2.0.2 amzn2-core 31 k
 
Transaction Summary
================================================================================================
Install 1 Package (+7 Dependent packages)
 
Total download size: 6.8 M
Installed size: 36 M
Downloading packages:
(1/8): emacs-filesystem-25.3-3.amzn2.0.1.noarch.rpm | 64 kB 00:00:00
(2/8): git-2.17.2-2.amzn2.x86_64.rpm | 217 kB 00:00:00
(8/8): perl-TermReadKey-2.30-20.amzn2.0.2.x86_64.rpm | 31 kB 00:00:00
------------------------------------------------------------------------------------------------
Total 26 MB/s | 6.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : git-core-2.17.2-2.amzn2.x86_64 1/8
Verifying : git-2.17.2-2.amzn2.x86_64 6/8
Installed:
git.x86_64 0:2.17.2-2.amzn2
 
Dependency Installed:
emacs-filesystem.noarch 1:25.3-3.amzn2.0.1 git-core.x86_64 0:2.17.2-2.amzn2
git-core-doc.noarch 0:2.17.2-2.amzn2 libsecret.x86_64 0:0.18.5-2.amzn2.0.2
perl-Error.noarch 1:0.17020-2.amzn2 perl-Git.noarch 0:2.17.2-2.amzn2
perl-TermReadKey.x86_64 0:2.30-20.amzn2.0.2
 
Complete!

Verify Git Package

After installing git on Amazon Linux 2 you have to verify if it is installed successfully.

So to do that just run the following code

[[email protected] ec2-user]# which git
/bin/git

Check version of Git package

So after installing successfully the git on your system and if you might need to check the version of your git package then just run the following command

[[email protected] ec2-user]# git --version
git version 2.17.2

Set Username Configuration

So after checking the Git version you have to set a username for configuration so that you can use it in the future while working with it.

So to do that run the following command on your terminal

[[email protected] ec2-user]# git config --global user.name "XYZ"

Set Email Configuration

After setting up the username for your git you have to set the email that you will use while merging code using Amazon Linux 2 in the Amazon web server

[[email protected] ec2-user]# git config --global user.eamil "[email protected]"

Verify Username and Email Configurations

So just setting up the email and username is not the final step cause now you have to verify it through your git that you entered the right email and username for your git on Amazon Linux 2

[[email protected] ec2-user]# git config --list
user.name=XYZ
[email protected]

Set the Date

Now while merging the code there would be a specific date so that the other will know when your code is merged and to do that you have to set the date on your own.

So to set up the date just run the below command on your terminal

[[email protected] ec2-user]# date +%T -s"21:43:00"
21:43:00

Verify Date

And at the last day you just have to verify the date what have entered and to do that this one the following command on the terminal and you’re done with installing Git on Amazon Linux 2

[[email protected] ec2-user]# date
Sat Nov 30 21:43:15 UTC 2019

Read More: How to Install Git on Ubuntu 22.04

Conclusion

So if you are a developer who is interested in web services or cloud services like AWS and might want to use Amazon Linux 2 to manage the web server then you need to install Git. So that you can change the codes or merge them using git and in this article, we have learned how to install Git on Amazon Linux 2.

LEAVE A REPLY

Please enter your comment!
Please enter your name here