Linux Masterclass:
TASK#1 BASED ON BOTH LINUX SESSIONS
Q1. Create a file via touch and update that file and also verify the timestamp and output will be redirected to another file.
Procedure:
Step 1: First, create a new directory by “mkdir” command.
Step 2: Then, go to the directory using “cd” command.
Step 3: After this, use “touch <filename>” command to create a new file.
(Note: “touch” command is used to update the timestamp of file and if that file is not present in the directory then it will automatically create a new file by itself.)
Step 4: And next step is to check, whether file created or not by using “ls” command.
Step 5: For checking the timestamp of the file use “ls –l” command.
Step 6: After this, we use vim editor, type “vim <filename>”.
Step 7: Inside vim editor, type "i" to convert it into writing mode. Then type the text.
Press "esc" command, and type ":wq" after this hit the "enter" key to save and get out of file.
Step 8: Then we will use “ls –l” command to check the timestamps of the file.
(Note: You can use touch command again to update the timestamp of the file and observe it’s working)
Step 9: After that previous state, we will use “cat <filename>” command for displaying the content inside file.
Step 10: For checking update, we will again use “ls –l” command.
Q2. Add some of the data as per your choice and append that data via echo command in the same file.
Procedure:
Step 1: First we will use "cat" command to view the content of the file.
Step 2: After checking content, we use command “ echo ‘text’ >> <filename>”. This command will append the text inside the file created.
Step 3: For verifying the content inside file, using command "cat".
Q3. Install httpd and set up your own web server.
Procedure:
Step 1: To install httpd on Centos machine is use " yum install httpd -y > /dev/null" command.
Step 2: To check, if httpd is installed or not, type command "rpm -q httpd". It will give information of the installed version of httpd on your machine.
Step 3: For starting httpd, use command "systemctl start httpd".
Step 4: Type command "systemctl enable httpd" to enable httpd.
(Note: httpd is disabled by default)
Step 5: Check the status of httpd using command "systemctl status httpd".
Q4. Copy some files from one Linux host to another Linux host via SCP.
Procedure:
Step 1: Open both the machine and give name to the one machine as host1 and other as host2 using command "hostnamectl set-hostname host1".
Step 2: After setting up name to the host execute it, by "exec bash" command.
Step 3: After this, use "ifconfig enp0s3 | grep inet" command on both the machine to get their IP Addresses.
Step 4: Next is to create a file on host1 using vim command and enter some text.
Step 5: Use scp(Secure Copy Command) command on host1.
Type "scp <filename> root@(host2 IP address):/tmp" .
(Note: After this previous step, password will be ask
Here, root@(host2 IP address):/tmp is the IP Address of the receiving machine where, /tmp is the location where we want to save the received file on the host2 machine.)
Step 6: Check for the file on host2 using "cat /tmp/filename" command.
Q5. Create another VM and setup password less authentication.
Procedure:
Step 1: Here, we will create another VM by cloning current VM.
Step 2: Go to Oracle VM VirtualBox, clone the current CentOS in it.
Step 3: No need to change settings, keep it to default and click next.
Step 4: After that, choose Full Clone option.
Step 5: Click Clone. This will set another CentOS in your VirtualBox.
Procedure For Password less Authentication:
Step 1: First create the key using “ssh-keygen” command in host 1 and enter it’s authentication credentials.
Step 2: After this, copy the key in host2 using command “ssh-copy-id root@(host2 IP address)”.
Step 3: Then host2 will verify the key is matched or not, if it then we are able to login and we can use it as password-less authentication.
(After this, we not need to enter password while accessing host2 anymore. To login as host2 in host1 machine execute command "ssh (IP of host2)")
.
.
.
.
.
Name: Mousmi U. Das
College: Government College of Engineering, Nagpur
" I tried to complete the task with simple explanation and some images , whatever I understand about Linux Masterclass. If you like this it's my pleasure, again if it need some improvement guide me with this. "
-Thank You