Module-2 Linux Fundamentals
Submitted by – Arun Kumar
Date of Submission – 01/06/2024
Submitted to – Vikul
L1 - In EC2 Ubuntu Instance Create a new user
and SSH Key pair with an authorized key.
Step 1(L1): First I am creating two Ubuntu instances, so I am
going to AWS console and creating instances.
i. Clicked on launch instance.
ii. I am selecting OS as Ubuntu and server name.
iii. Select existed key pair.
iv. I am going to network settings allow SSH traffic and given
number of instance 2 and clicked on launch instance.
v. Two Ubuntu instances created and I am also set name as
ubutnu-1 and Ubuntu-2 .
Step 2(L1): Now I am going to connect both instance using web
browser select both instance and clicked on connect.
Now I am in Ubuntu-1 instance just clicking connect.
Now Ubuntu-1 instance connected.
Now I am in Ubuntu-2 instance just clicking on connect.
Ubuntu-2 EC2 instance connected.
Step 3(L1): Now I am going to generate authentication key in
Ubuntu-1 instance typed command “ssh-keygen -t rsa”.
Its asking file location where I want to save key file but I want
to save it in default location so I am just clicked enter button.
Now asking for passphrases just I clicked enter button, again
pressing enter button to skipping passphrases and
authentication key successfully created in .ssh folder.
Step 4(L1): Now I am going inside .ssh folder just typed
command “cd .ssh/” and then see content of this folder typed
command “ls” three files presented inside .ssh folder.
Step 5(L1): Now I am open public key using command “ cat
id_rsa.pub” .
Step 6(L1): Now I am going to Ubuntu-2 instance and see what
user is existed type command “ls /home/” here only Ubuntu
user is presented.
Step 7(L1): I am going as root user for this I typed command
“sudo su” then I am creating user with name “Arun” just typing
command " useradd Arun”.
Step 8(L1): Now I am verifying user is created or not I am typing
command “ cat /etc/passwd” and user created successfully .
Step 9(L1): Now I am creating a directory inside home directory
just typed command “mkdir /home/Arun” and verifying
directory is created or not typed command “ls /home/”.
Step 10(L1): I am creating one more directory “.ssh” inside
demo I have typed command “mkdir /home/Arun/.ssh”.
Step 11(L1): Now I am opening a file inside .ssh directory just
typing command “ vi /home/Arun/.ssh/authorized_keys”.
Step 12(L1): Now I am pressing “i” to enter into insert mode
now I able to edit content inside it, I am copying “id_rsa.pub”
key from Ubuntu-1 and paste inside it.
Step 13(L1): Now I am pressing “Escape” button then enter
“:wq” to save this file and pressing enter button.
Step 14(L1): Now change ownership of .ssh directory just typed
command “chown –R Arun: /home/Arun/.ssh”.
Step 15(L1): Now I am giving to all permission to .ssh directory
using command “chmod 700 /home/Arun/.ssh”.
Step 16(L1): I am giving read and write permission to the
owner of autherised_keys file just typing command” chmod
600 /home/Arun/.ssh/authorized_keys”.
Step 17(L1): Now I am going to connect user from Ubuntu-1.
i. First I am going to Ubuntu-1 instance and type command
“cd ..” for going back to directory.
ii. Now I am going to Ubuntu-2 instance and from there I
am copying PUBLIC IP of it.
iii. Now going back to Ubuntu-1 and type command using
copied public IP “ ssh Arun@15.206.194.99” and enter
Yes .
iv. Now it is asking permission to connect I am typed “yes”.
v. Now Ubuntu-1 instance connected successfully with
Ubuntu-2 instance using “SSH AUTH_KEY”.
Thank You L1 Completed
L2 - As a Linux root user Create Files/Directory
in the same Instance and change the ownership
to a new user.
Step 1(L2): I am connected with Linux server
Step 2(L2): Now I am login as root user just typed command
“sudo su”.
Step 3(L2): Now I am creating a directory “Arun_Dir” in same
instance using command “ mkdir /home/Arun_Dir”.
Step 4(L2): Now I am checking ownership of “Arun_Dir” directory
using command “ls –ll /home”.
Step 5(L2): Now I am creating a new user named as “Arun” using
command “useradd Arun”.
Step 6(L2): Now I am verifying user is created or not using
command “cat /etc/passwd”.
Step 7(L2): Now I am changing ownership of directory
“Arun_Dir” from “root” user to “Arun” user using command
“chown Arun: /home/Arun_Dir”.
Step 8(L2): Now I am verifying user ownership is changed or not
using command “ll /home” now ownership is changed
successfully.
Thank You L2 Completed
L3 - In EC2 Ubuntu Instance Create Files and
Directories and Grant R/W/X Access only to the
Owner and User Group.
Step 1(L3): First I am created a Ubuntu instance then I am
connected using web browser.
Step 2(L3): Now I am going to create a Directory inside home
directory using command “ sudo mkdir /home/Arun_D”.
Step 3(L3): I have verify that directory “Arun_D” is created inside
home directory or not using command “ ls /home”.
Step 4(L3): I am going to check which R/W/X permission is
assigned to “Arun_D” directory using command “ll /home”.
Step 5(L3): Now I am going to delete all R/W/X permission those
are assigned to “Arun_D” directory using command “ sudo
chmod 000 /home/Arun_D”.
Step 6(L3): I am verifying that R/W/X permission of “Arun_D”
directory is deleted or not using command “ll /home”.
Step 7(L3): Now I am going to set R/W/X permission to owner of
“Arun_D” directory sung command “sudo chmod u+rwx
/home/Arun_D”.
Step 8(L3): Adding R/W/X permission to group of “Arun_D”
directory using command “sudo chmod g+rwx /home/Arun_D”.
Step 9(L3): Let’s verify R/W/X permission is added to the only
owner and group of “Arun_D” directory or not using command
“ll /home”.
Step 10(L3): Now i am login as root user because only root user
have permission of R/W/X using command “sudo su”.
Step 11(L3): I am going inside “Arun_D” directory and created a
file using command “cd /home/Arun_D” “touch Arun_File.txt”.
Step 12(L3): Now I have to check which R/W/X permissions are
assigned to “Arun_File.txt” file using command “ll”.
Step 13(L3): First I am deleting all R/W/X permission those are
assigned to file using command “chmod 000 Arun_File.txt”.
Step 14(L3): Now I am verifying that all permissions of file are
deleted are not using command “ll”.
Step 15(L3): I am going to set R/W/X permissions to the owner
and user of file using command “chmod u+rwx Arun_File.txt”
“chmod g+rwx Arun_File.txt”.
Step 16(L3): Now I am verifying that R/W/X permissions are
added to the owner and group only using command “ll”.
Thank You L3 Completed
L4 - In EC2 Ubuntu Instance install JDK and
setup JAVA_HOME path environment variable.
Step 1(L4): First I am going to connect Ubuntu server to my local
terminal using ssh-key for this I am copying ssh client url from
Ubuntu instance paste in local terminal.
Step 2(L4): Now I am going to update package repository using
command “ sudo apt update”.
Step 3(L4): Now I am installing JDK in Ubuntu server using
command “sudo apt install default-jdk”.
Step 4(L4): I am verifying jdk is installed or not using command
“java –version”.
Step 5(L4): Now I am setting JAVA_HOME Environment Variable
using command “sudo update-alternatives --config java”.
Step 6(L4): I am opened “.bashrc” file using command “nano
~/.bashrc”. and add path “ /usr/lib/jvm/java-8-openjdk-amd64
” at the end of file .
Step 7(L4): Now I am applying changes using command “source
~/.bashrc”.
Step 8(L4): Now I am going to verify Java_Home environment set
or not using command “echo $JAVA_HOME” here I am seeing
java home path that means it is successfully set.
Thank You L4 Completed
L5 - Create two AWS EC2 Ubuntu Instances to
establish SSH Connection and SCP the files from
one Instance to another instance.
Step 1(L5): I am creating two Ubuntu instances.
i. I have logged in to EC2 dashboard and clicked on launch
instance.
ii. I am not given server name right now and selecting
Ubuntu OS.
iii. Select existed key pair as Ubuntu-Key and network
settings keeping as default, given number of instances as
2 and licked on launch instance.
iv. Two Ubuntu instances successfully created and named
as Ubuntu-1 and Ubuntu-2.
Step 2(L5): Now I am going to connect both instances using web
browser just clicking on connect button.
Step 3(L5): Both instances successfully connected .
Step 4(L5): Now I am going to stablished SSH connections to
connect Ubuntu-1 to Ubuntu-2.
i. I have to go in Ubunut-1 instance and typed command
“sudo su” becoming a root user.
ii. Now I am creating a file in Ubuntu-1 with same name of
“Ubuntu-Key.pem” which is stored in Ubuntu-2 Server
using command “ vi Ubuntu-Key.pem”.
iii. File is created and I am pressing I button to enter in write
mode.
iv. Now I am copying private key from my local computer
paste in Ubuntu-Key.pem file.
v. Now I have pressed escape button and enter “:wq” then
press enter button.
vi. Now I am verifying file is created or not using command
“ls”.
vii. Now I am going to Ubuntu-2 instance and select SSH
Client and copied command ( chmod 400 "Ubuntu-
Key.pem") change permission of private key file only read
mode.
viii. Now I am pasting that command in Ubunut-1 instance.
ix. Now I am copying SSH connection command from
Ubuntu-2 and paste in Ubuntu-1 instance.
x. Now I am giving permission to connect type “yes” and
Ubuntu-1 instance is successfully connected to Ubuntu-2
instance.
Step 5(L5): Now I am going to SCP file from Ubuntu-1 instance to
Ubuntu-2 instance.
i. First I am exit from Ubuntu-2 instance to Ubuntu-1
instance using command “exit”.
ii. Now I am creating a file as “Arun.txt” using command
“touch Arun.txt”.
iii. I am verifying file is created in Ubuntu-1 instance or not
using command “ls”.
iv. I am copying public IP of Ubuntu-2 instance.
v. I am transfer file “Arun.txt” from Ubuntu-1 instance to
Ubuntu-2 using command “scp -i Ubuntu-Key.pem
Arun.txt ubuntu@13.234.21.161:/home/ubuntu”.
vi. Now I am given permission to transfer type “yes” and file
successfully transferred.
vii. I am verifying the file is transferred or not for that I am
going to connect Ubuntu-2 instance using SSH
connection command and then type “ls”.
Thank You L5 Completed
L6 - Write a Linux Shell Script to Install Git, JDK,
Maven in EC2 Ubuntu Instance.
Step 1(L6): I am creating a Shell Script file using command “vi
Arun.sh”.
Step 2(L6): Now I am pressed “I” to enter insert mode.
Step 3(L6): Now I am writing script file and pressing escape
button and enter “:wq” to save end exit from file.
Step 4(L6): I have checked which permission is accessed by file
“Arun.sh” using command “ll” .
Step 5(L6): Now I am given file execution permission to
“Arun.sh” file using command “chmod 755 Arun.sh”.
Step 6(L6): Now I am checking permission is set or not.
Step 7(L6): Now I am executed “Arun.sh” file using command
“./Arun.sh”.
Step 8(L6): Now I am seeing that Git,JDK and Maven are
successfully installed.
Thank You
Linux Assignment Completed