Answer for KodeKloud Question - Linux Run Levels

 New tools have been installed on the app server in Stratos Datacenter. Some of these tools can only be managed from the graphical user interface. Therefore, there are requirements for these app servers.

On all App servers in Stratos Datacenter change the default run level so that they can boot in GUI (graphical user interface) by default.

Answer:

# Check the defaut run level     

      systemctl get-default

#Check the graphical.target status 

    systemctl status graphical.target

#Now let set the run level to graphical.target 

    systemctl set-default graphical.target

#start and enable  the graphical.target

    systemctl start graphical.target

    systemctl enable graphical.target

#Now lets check the status again 

    systemctl status graphical.target

    systemctl get-default

* Do the above steps for all other App servers 

Note: ** The question copied for learning purposes.**Commands are correct but based on your question the server and user name, other details might differ so please do check.

Answer for KodeKloud Question - Create a user with a specific ID

 For security reasons the xFusionCorp Industries security team has decided to use custom Apache users for each web application hosted, rather than its default user. This will be theApache user, so it shouldn't use the default home directory. Create the user as per requirements given below:

a. Create a user named yousuf on the App server 2 in Stratos Datacenter.
b. Set UID to 1701 and its home directory to /var/www/yousuf.


Answer:

ssh <user>@<server>

#swithc to root user
    sudo su 

#create a new user named username with UID of 1701 you would type:
    useradd -u 1701 yousuf

#after above user creation when we checked in /etc/passwd the default user home as 
/home/yousuf but as per the question we need to change its home directory to/var/www/yousuf
    
cat /etc/passwd | grep yousuf 


# Set home directory to /var/www/yousuf.
        usermod -d /var/www/yousuf -m yousuf

# To check 

    cat /etc/passwd | grep yousuf 


Note: Commands are correct but based on your question the server and user name, other details might differ so please do check.

Answer for KodeKloud Question - NFS Troubleshooting


The Nautilus production support team was trying to fix issues with their storage server. The storage server has a shared directory /data, which is mounted on all app servers at location /var/www/html so that whatever data they store on the storage server under /data can be shared among all app servers. Somehow NFS server is broken and having some issues.

Identify the root cause of the issue and fix it to make sure sharing works fine among all app servers and storage server

Sample ANSWER:

--------------------

ON Storage Server 

--------------------

#check the /etc/eports file should be as below 

    vi /etc/export

/data 172.16.238.10(rw,sync,no_subtree_check,no_root_squash,fsid=0)

/data 172.16.238.11(rw,sync,no_subtree_check,no_root_squash,fsid=0)

/data 172.16.238.12(rw,sync,no_subtree_check,no_root_squash,fsid=0)


check above details in export file( in my case mount directory  is "/data" your might different )

#run below command 

exportfs -a 

#check nfs-server and rpcbind status (if not, start both )

        systemctl status nfs-server

systemctl status rpcbind

# Start commands

systemctl start nfs-server

systemctl start rpcbind

# these commands for start the service autumatically when server boot 

systemctl enable nfs-server

systemctl enable rpcbind

#run below to check 

    showmount

-----------------------------

Now on all the APP servers 

------------------------------

#check nfs-server and rpcbind status (if not, start both )

# now do the mount part 

mount -t nfs ststor01:/data /var/www/html

# verify our mount by using any of below commands

        mount | grep nfs

df -h 

( do the above steps for all the app servers ) 

----------------

TESTING 

---------------

go to the storage server ( navigate your shared directory on the storage server)

cd /data 

#create a text file 

touch text.txt 

#Now go to each APP server and check inside the /var/www/html

text.txt should be presented if the NFS mount is worked correctly 


Note: ** The question copied for learning purposes.**
Commands are correct but based on your question the server and user name, mount directory might differ so please do check.

Answer for KodeKloud Question - Apache Troubleshooting

 xFusionCorp Industries utilizes monitoring tools to check the status of every service, application, etc. running on the systems. The monitoring system identified that Apache service is not running on some of the Nautilus Application Servers in Stratos Datacenter.


1. Identify the faulty Nautilus Application Servers and fix the issue. Also, make sure Apache service is up and running on all Nautilus Application Servers. Do not try to stop any kind of firewall that is already running.
2. Apache is running on 3002 port on all Nautilus Application Servers and its document root must be /var/www/html on all app servers.
3. Finally you can test from jump host using curl command to access Apache on all app servers and it should work fine. E.g. curl http://172.16.238.10:3002/


Answer:

#First read each question section carefully 

#login to server 
    ssh <user>@<server>
# swithc to root user
    sudo su 

# check apache service running  in all 3 app servers 
    systemctl status httpd

#check the httpd.conf in (/etc/httpd/conf/httpd.conf)
    as you can see below #ServerName www.example.com:80 need to be edited as per the details 

#Edit httpd.conf file 

    ServerName 172.16.238.10:3002





# Save the file and restart the httpd service
 
    systemctl restart httpd 

# here is the important point, once you started the httpd service sometimes it got failed you need to check the reason for its failure by issuing the status command 

    systemctl status httpd

#There can be many errors/reasons but below 3 errors can be possible as per this question 
    Invalid server root directory httpd.conf file 
    Invalid document root error in httpd.conf file
    Listen to port entry error in httpd conf file 

check above three section in the httpd.conf file and correct it 

# start the apache service again
    systemctl restart httpd

# test using below curl command from jump host to each app server
    curl http://172.16.238.10:3002/ 
    curl http://172.16.238.11:3002/
    curl http://172.16.238.12:3002/


Note: Commands are correct but based on your question the server and user name might differ so please do check.


Answer for KodeKloud Question - DNS Troubleshooting

 The system admins team of xFusionCorp Industries has noticed intermittent issues with DNS resolution in several apps . App Server 2 in Stratos Datacenter is having some DNS resolution issues, so we want to add some additional DNS nameservers on this server.

As a temporary fix we have decided to go with Google public DNS (ipv4). Please make appropriate changes on this server.

Answer:

ssh <user>@<servername>
sudo su 


#To check 
cat /etc/resolv.conf

#To update 
vi /etc/resolv.conf

(press "i" to go insert mode ) paste this entry above the local DNS 

nameserver 8.8.8.8

To save the file (press "Esc" and type ":wq!")

# To test 
ping google.com

Note: Commands are correct but based on your question the server and user name might differ so please do check.

Answer for KodeKloud Question - Linux Services

 As per details shared by the development team, the new application release has some dependencies on the back end. There are some packages/services that need to be installed on all app servers under Stratos Datacenter. As per requirements please perform the following steps:

a. Install cups package on all the application servers.

b. Once installed, make sure it is enabled to start during boot.

Sample Answer: 

ssh <user>@<server>

sudo su

#Install the cups package

    yum install -y cups 

#Start the cups service

    Systemctl start cups

#Check the status of cups service

    Systemctl status cups

# Enabled cups service to start during boot 

    Systemctl enable cups


Note: **The Question copied for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.


Answer for KodeKloud Question - Create a Cron Job

 The Nautilus system admins team has prepared scripts to automate several day-to-day tasks. They want them to be deployed on all app servers in Stratos DC on a set schedule. Before that they need to test similar functionality with a sample cron job. Therefore, perform the steps below:


a. Install cronie package on all Nautilus app servers and start crond service.
b. Add a cron */5 * * * * echo hello > /tmp/cron_text for root user.

Sample Answer:

ssh <user>@<server>

#Swithc to root user
sudo su 

# Install the cronie package
        yum install cronie

#Start the crond service 
         systemctl start crond.service 

#Check cron service status 
        systemctl status crond.service

.#Create a cronjob by typing 
        crontab -e

 #Write the cron job  (press "i" to change the insert mode then paste below command then type "Esc" :wq!)

        */5 * * * * echo hello  >  /tmp/cron_text

 #Check cron job 
        crontab -l

#Check cron job for root 
        crontab -u root -l

Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.



Answer for KodeKloud Question - Linux User Expiry

A developer Kareem has been assigned Nautilus project temporarily as a backup resource. As a temporary resource for this project, we need a temporary user for Kareem. It’s a good idea to create a user with a set expiration date so that the user won't be able to access servers beyond that point.

Therefore, create a user named kareem on the App Server 1. Set expiry date to 2021-03-28 in Stratos Datacenter. Make sure the user is created as per standard and is in lowercase.

Sample Answer:

ssh <user>@<server>

sudo su 

useradd kareem

#to verify kareem accout expiry date 

 [root@stapp01 home]# chage -l kareem
Last password change                                : Oct 30, 2020
Password expires                                        : never
Password inactive                                       : never
Account expires                                          : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

# comand to change the accout expiry date

[root@stapp01 home]# chage -E 2021-03-28 kareem

#To verify again 

[root@stapp01 home]# chage -l kareem
Last password change                                    : Oct 30, 2020
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : Mar 28, 2021
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
[root@stapp01 home]#


Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

check below video too for how to do the task (i have done a sample task on  Ubuntu OS)



Answer for KodeKloud Question - Linux String Substitute

 The backup server in the Stratos DC contains several template XML files used by the Nautilus application. However, these template XML files must be populated with valid data before they can be used. One of the daily tasks of a system admin working in the xFusionCorp industries is to apply string and file manipulation commands!

Replace all occurrences of the string Sample to Cloud on the XML file /root/nautilus.xml located in the backup server.

Sample Answer: 

#ssh to server

    ssh <user>@<server>

#switch to root user

    sudo su

# verify 

    cat nautilus.xml | grep -i Sample 

#Replace command

    sed -i 's/Sample/Cloud/g' /root/nautilus.xml

#you can verify again using the below command 

    cat nautilus.xml | grep -i Sample 
 

Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

check the below video too for how to do a similar task (i have done a sample task on Ubuntu OS)



Answer for KodeKloud Question - Linux Archives

 On Nautilus storage server in Stratos DC there is a storage location /data which is used by different developers to keep their data (no confidential data). One of the developers javed has raised a ticket and asked for a copy of his/her data present in /data/javed directory on storage server. /home is an FTP location on storage server where developers can download their data. Below are the instructions shared by the system admin team to accomplish the task:

a. Make a javed.tar.gz compressed archive of /data/javed directory and move the archive to /home directory on Storage Server.

Sample Answer:

ssh <user>@<storageserver>

sudo su

tar -czvf javed.tar.gz  /data/javed

mv
javed.tar.gz /home/


Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

check below video too for how to do the task (i have done a sample task on Ubuntu OS)



Answer for KodeKloud Question - Add a user without a home directory.

The system admins team of xFusionCorp Industries has set up a new tool on all app servers, as they have a requirement to create a service user account that will be used by that tool. They are finished with all apps except for App 3 in Stratos Datacenter.


Create a user named Anita in App Server 3 without a home directory.


Answer : 

ssh <user>@app03
sudo su

useradd -M anita 

#To verify 

cd /home 
ls - lrth
 
 (there will be no home directory listed for anita but it will be presented in ect/passwrd)

cat /etc/passwd | grep anita

Note: Commands are correct but based on your question the server and user name might differ so please do check.

check below video too for how to do the task (i have done a sample task on  Ubuntu OS)



Answer for KodeKloud Question - Add a user with a non-interactive shell

 The System admin team of xFusionCorp Industries has installed a backup agent tool on all app servers. As per the tool's requirements, they need to create a user with a non-interactive shell.

Therefore, create a user named Siva with a non-interactive shell in the app01 server.

Answer

ssh <user>@<server>

sudo su 

adduser siva -s /sbin/nologin


Note: ** The question copied for learning purposes.**, Commands are correct but based on your question the server and user name(siva) might differ so please do check. 

check below video too for how to do the task (i have done a sample task on  Ubuntu OS)



 





Featured Post

Answer for Kodekloud DEVOPS Questions - Init container in Kubernetes

Question: 1. Create a Deployment named as ic-deploy-devops. 2. Configure spec as replicas should be 1 , labels app should be ic-devops , ...