MASTERCLASS #TASK ON LINUX
Q.1 Create a file via touch and update that file and also verify the timestamp and output will be redirected to another file.
Here I am adding screenshot to visualize and for easy understand.
Step 1: Create a new directory using “mkdir”.
Step 2: Go to that directory using “cd” command.
Step 3: Use touch command to create a file. Check whether the file created or not using “ls” command.
Step 4: Check the timestamp using “ls -l” command.
Step 5: To open the file and write something use “vim” command.
Step 6: Go to insert mode to write something.
Step 7: After writing something press “ESC” key on keyboard and type “wq” and hit “enter” key for quitting the file and save the written lines.
Step 7: To check the file content use “cat” command.
Q.2 Add some of the data as per your choice and append that data via echo command in the same file
To write something without opening the file and append use “echo” command.
Q.3 Install httpd and set up your own web server.
Step 1: To install httpd use command “yum install httpd -y > /dev/null”.
Step 2: To start httpd use command “systemctl start httpd”
Step 3: To enable httpd (By default disabled) use command “systemctl enable httpd”
Step 4: To check the status of httpd use command “systemctl status httpd”
Q.4 Copy some files from one Linux host to another Linux host via SCP.
Step 1: Open both host and rename as “host1” and “host2” using command “hostnamectl set-hostname host1” and “hostnamectl set-hostname host2”. After that use command “exec bash” to execute name change operation.
Step 2: Check the ip address of both host using command “ifconfig enp0s3 | grep inet”.
Step 3: Create a file in host1 using “vim” command and write something.
Step 4: Transfer the file from host1 to host2 using SCP, use command “scp filename root@(ip address of host2):/tmp”. Password of host2 will be asked at that time.
Q.5 Create another VM and setup password less authentication.
- Another VM can be setup by cloning the current VM.
Step 1: Go to Oracle VM VirtualBox and right click on the current CentOS and select Clone.
Step 2: Don’t change the default settings and just click Next.
Step 3: Then choose Full Clone option from the current window.
Step 4: Click Clone. This will set another CentOS in your VirtualBox.
- Setup PASSWORD — LESS AUTHENTICATION.
Step 1: Generate the key using “ssh-keygen” in host 1 and enter authentication credentials.
Step 2: Then copy this key in host2 using command “ssh-copy-id root@(ip address of host2)”. host2 will verify if it’s coming from the right source or not and if the key is matched, it means you are able to login. After that you need not to enter password while accessing host2 anymore.
This is less authentication Password setup to access different host.