Top DevOps Interview Q&A [Part 1]

aks_404aks_404
4 min read

1. Tell me about your daily activities in your workplace?

Ans- The expected answer should include the below points in detail, as the interviewer wants to know about your practical day-to-day activities.

  • Your first work on shift start (Checking ticketing queue or Client Email or assigned tasks)

  • Explain to them, if you analyze any logs/events/alarms/tickets

  • If you implement any change requests, explain in detail.

2. du and df command shows different Disk usage, Why?

Ans- This could be because of open file deletion, i.e when someone deletes the log file that is being used or opens by the other process if we try to delete this file name will be deleted but its inode number and data will not be deleted.

By using the “lsof” command we can get the list of open files, run this command under the /var path to get the details

# lsof /var | egrep “^COMMAND|deleted”

To release the space, We could kill the command by using its PID number. Name the Linux commands you use frequently.

Ans- You should mention commands you use on a frequent basis, be sure to know about them in detail. (ls, telnet, netcat, systemctl, iptables, crontab etc )

3. Buff/Cache in SWAP space is full, what is the best way to clear it without any data loss?

Ans - #swapoff -a (will clear swap memory and move information in RAM)

# swapon -a (To re-enable swap)

4. Explain the fields of Crontab?

Ans- * [-u user] file

field Allowed values

minute 0–59

hour 0–23

day of month 1–31

month 1–12 (or names; see example below)

day of week 0–7 (0 or 7 is Sunday or use names; see below)

5. What are the steps you will perform to configure the apache webserver?

Ans - Edit the apache conf file with the required details :

# vi /etc/httpd/conf/httpd.conf

Check the syntax in httpd.conf

# apachectl configtest

Enable the service to start on VM startup

# systemctl enable httpd

Start httpd service

# systemctl restart httpd

Check if the service is running properly

# systemctl status httpd.service

6. How will you troubleshoot if the apache service is not running or accessible?

Ans -Check if the service is running

# systemctl status httpd.service

Check the logs on the below path

# cd /var/log/httpd

Check the process of the service

# ps -ef | grep -i httpd

Check if the port for httpd is not being used by any other process.

# lsof -i :80

7. Apache(httpd) package is not installed, but the service is running can you explain how?

Ans -Apache package may be compiled from the source.

8. Can you write a command to find all files which have been accessed within the last 15 days?

Ans -# find / -type f -atime -15 > filelist.txt

9. What does the following command line produce ? Explain each aspect of this line.

# (date ; ps -ef | awk „{print $1}‟ | sort | uniq | wc -l ) >> Activity.log

Ans- This writes the date and time into the file Activity.log together with the number of distinct users who have processes running on the system at that time. If the file already exists, then these items are appended to the file, otherwise, the file is created.

Explanation = The date gives the date and time as the first command of the line, followed by ps -ef which gives the list of all running processes in long form with UIDs listed first, These are fed into the awk which filters out all and gives UIDs, these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort — uniq only works on sorted data — if the list is A, B, A, then A, B, A will be the output of uniq, but if it‟s A, A, B then A, B is the output) which produces only one copy of each UID. These UIDs are fed into wc -l which counts the lines — in this case, the number of distinct UIDs running processes on the system. Finally, the results of these two commands, the date and the wc -l, are appended to the file “Activity.log”.

10. How you can use a firewall to restrict ssh, telnet, and FTP on the Linux machine?

Ans- For SSH

# iptables -A INPUT -s -p tcp — dport <22> -j REJECT/DROP/DENY

For Telnet

# iptables -A INPUT -s -p tcp — dport <23> -j REJECT/DROP/DENY

For FTP

# iptables -A INPUT -s -p tcp — dport <21> -j REJECT/DROP/DENY

Let me know in the comments if you are interested in more Linux Scenario Based Interview questions.

Kindly Sponsor, Comment and Subscribe. I will be coming up with a new write-up every week.

10
Subscribe to my newsletter

Read articles from aks_404 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

aks_404
aks_404