Site icon CentLinux

Top 100 Linux Interview Questions for DevOps

Share on Social Media

Discover the top 100 Linux interview questions for DevOps professionals. Prepare for your next DevOps interview with these essential Linux questions and answers. #centlinux #linux #devops

Introduction

In the world of DevOps, proficiency in Linux is a must-have skill. Linux’s flexibility, robustness, and open-source nature make it a preferred operating system for developers, system administrators, and IT professionals alike. This article provides a comprehensive list of 100 interview questions that can help you prepare for a DevOps role, focusing on various aspects of the most popular operating system for Cloud Servers.

What is DevOps?

DevOps is a transformative approach that combines development (Dev) and operations (Ops) to enhance collaboration and productivity within organizations. It aims to break down traditional silos between software development and IT operations, fostering a culture of continuous integration, continuous delivery (CI/CD), and continuous feedback. By automating workflows and leveraging tools like Jenkins, Docker, and Kubernetes, DevOps facilitates faster and more reliable software releases. This methodology not only improves the efficiency and speed of software delivery but also ensures higher quality and stability of applications. Ultimately, DevOps drives innovation and agility, enabling businesses to respond swiftly to market changes and customer needs.

Basic Linux Questions

1. What is Linux?
Linux is an open-source, Unix-like operating system kernel created by Linus Torvalds. It is widely used in servers, desktops, and various embedded systems.

2. What are the basic components of a Linux system?
The basic components include the kernel, system libraries, system utilities, and application programs.

3. How do you check the current kernel version?
Use the command: uname -r

4. How do you list files in a directory?
Use the ls command.

5. What is the command to change file permissions?
Use the chmod command.

6. How do you view the contents of a file?
Use the cat, more, less, or tail commands.

7. What is the command to copy files or directories?
Use the cp command.

8. How do you move or rename a file?
Use the mv command.

9. How do you create a new directory?
Use the mkdir command.

10. What is the command to delete a file?
Use the rm command.

Top 100 Linux Interview Questions for DevOps

Intermediate Linux Questions

11. How do you monitor system processes?
Use the top or htop command.

12. What command would you use to find the IP address of your system?
Use the ifconfig or ip addr command.

13. How do you create a user in Linux?
Use the useradd command.

14. How do you change the password of a user?
Use the passwd command.

15. What is SSH and how is it used?
SSH (Secure Shell) is a protocol used to securely connect to a remote server. Use ssh username@hostname.

16. How do you check disk usage in Linux?
Use the df and du commands.

17. How do you view running processes in Linux?
Use the ps command.

18. How do you kill a process?
Use the kill command followed by the process ID (PID).

19. What is the difference between su and sudo?
su switches the current user to another user, while sudo allows permitted users to execute commands as the superuser.

20. How do you change the ownership of a file?
Use the chown command.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

Advanced Linux Questions

21. What is the Linux kernel?
The kernel is the core part of the Linux operating system that manages system resources and hardware.

22. How do you compile a new kernel?
Download the kernel source, configure it using make menuconfig, then compile and install using make and make install.

23. What are runlevels in Linux?
Runlevels are different modes of operation in Linux, each defining a different state of the machine, such as shutdown, single-user mode, or multi-user mode.

24. How do you change the runlevel?
Use the init or systemctl command.

25. What is SELinux?
SELinux (Security-Enhanced Linux) is a security module that provides a mechanism for supporting access control security policies.

26. How do you enable and disable a service?
Use the systemctl enable and systemctl disable commands.

27. What is a swap space?
Swap space is a portion of the hard disk used as virtual memory to extend the physical memory of the system. Refer to How to change Swappiness for more details.

28. How do you create a swap file?
Use dd to create the file, mkswap to set up the swap area, and swapon to enable it.

29. How do you tune the system performance?
Adjust kernel parameters using sysctl and manage system resources using tools like top, htop, and iotop.

30. What are iptables?
Iptables is a command-line firewall utility that uses policy chains to allow or block traffic.

Linux in DevOps Practices

31. What is CI/CD?
Continuous Integration (CI) is a development practice where developers integrate code into a shared repository frequently. Continuous Deployment (CD) is the practice of deploying all code changes to the testing or production environment automatically.

32. How is Linux used in CI/CD pipelines?
Linux is often used as the base OS for CI/CD servers and agents due to its robustness and flexibility.

33. What is Jenkins?
Jenkins is an open-source automation server that helps automate parts of the software development process, including build, test, and deployment.

34. How do you install Jenkins on Linux?
Download and install using package managers like apt or yum, or using Docker. Or you can follow our detail guide on how to install Jenkins

35. What is Ansible?
Ansible is an open-source automation tool for configuration management, application deployment, and task automation.

36. How do you manage infrastructure with Ansible?
Write playbooks in YAML format to define tasks and configurations, and run them using the ansible-playbook command. For more details, Please read our tutorial to Setup Ansible Automation Platform.

37. What is Docker?
Docker is a platform for developing, shipping, and running applications inside containers.

38. How do you install Docker on Linux?
Use the package manager (apt, yum, etc.) to install Docker. For more information, you can refer to our step by step tutorial on how to install Docker

39. What is Kubernetes?
Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications.

40. How do you deploy an application on Kubernetes?
Create deployment manifests in YAML and apply them using the kubectl apply command. For more information, have a look at our blog post to install Kubernetes cluster

Containerization and Virtualization

41. What are containers?
Containers are lightweight, portable, and self-sufficient environments that include everything needed to run a piece of software.

42. How do containers differ from virtual machines?
Containers share the host OS kernel and are more lightweight, while VMs include a full OS and are heavier.

43. What is Docker Compose?
Docker Compose is a tool for defining and running multi-container Docker applications using a docker-compose.yml file.

44. How do you create a Docker image?
Write a Dockerfile with the necessary instructions and build it using the docker build command.

45. What is a Docker Registry?
A Docker Registry is a storage and distribution system for Docker images. You may also read our guide to Setup a Private Docker Registry

46. How do you push an image to Docker Hub?
Tag the image and use the docker push command to upload it to Docker Hub.

47. What is a Kubernetes Pod?
A Pod is the smallest deployable unit in Kubernetes, which can contain one or more containers.

48. How do you scale a Kubernetes deployment?
Use the kubectl scale command or define replicas in the deployment manifest.

49. What is Helm?
Helm is a package manager for Kubernetes, allowing you to define, install, and upgrade complex Kubernetes applications.

50. What are Virtual Machines (VMs)?
VMs are software emulations of physical computers that run an entire operating system. To setup a Virtualization server, you can refer Install KVM Host

Scripting and Automation

51. What is a shell script?
A shell script is a script written for the shell, or command line interpreter, of an operating system.

52. How do you create and execute a shell script?
Create a script file with .sh extension and run it using bash scriptname.sh or ./scriptname.sh.

53. What is Bash?
Bash (Bourne Again Shell) is a Unix shell and command language.

54. How do you use variables in a shell script?
Define variables with varname=value and access them using $varname.

55. What are conditionals in shell scripting?
Conditionals (if, else, elif) are used to perform different actions based on different conditions.

56. How do you use loops in shell scripting?
Use for, while, and until loops to iterate over commands or values.

57. What is cron?
Cron is a time-based job scheduler in Unix-like operating systems.

58. How do you schedule a cron job?
Edit the crontab file using crontab -e and define the schedule.

59. What is Ansible playbook?
An Ansible playbook is a configuration file written in YAML that defines the tasks to be executed on remote hosts.

60. How do you run an Ansible playbook?
Use the ansible-playbook command followed by the playbook filename.

System Performance and Monitoring

61. What is the top command?
top displays real-time information about system processes and resource usage.

62. How do you monitor disk usage?
Use the df command to check disk space and du to check disk usage of files and directories.

63. What is htop?
htop is an interactive process viewer for Unix systems.

64. How do you check memory usage?
Use the free command or vmstat.

65. What is iotop?
iotop monitors disk I/O usage by processes.

66. How do you analyze system logs?
Use the journalctl command for systemd logs or tail -f /var/log/syslog for syslog.

67. What is Nagios?
Nagios is an open-source monitoring system for computer systems, networks, and infrastructure.

68. How do you install Nagios on Linux?
Follow the official documentation for downloading and configuring Nagios.

69. What is Prometheus?
Prometheus is an open-source systems monitoring and alerting toolkit.

70. How do you set up Prometheus on Linux?
Download and configure Prometheus according to the official documentation, usually involving setting up a configuration file and running the Prometheus binary. You can also follow our step by step guide on Install Prometheus Software

Networking and Security

71. How do you configure a static IP address in Linux?
Edit the network configuration files (/etc/network/interfaces or /etc/sysconfig/network-scripts/) and restart the network service.

72. What is the ping command used for?
ping checks the network connectivity between the host and a destination IP address.

73. How do you check open ports in Linux?
Use the netstat or ss command.

74. What is a firewall?
A firewall is a network security system that monitors and controls incoming and outgoing network traffic.

75. How do you configure a firewall in Linux?
Use iptables or firewalld. For more details, please read 3 ways to Create a Firewall Service

76. What is SELinux?
Security-Enhanced Linux is a security architecture integrated into the Linux kernel.

77. How do you disable SELinux?
Edit the /etc/selinux/config file and set SELINUX=disabled, then reboot the system.

78. What is SSH?
SSH (Secure Shell) is a protocol for securely connecting to remote systems over a network.

79. How do you set up SSH key-based authentication?
Generate a key pair using ssh-keygen and copy the public key to the remote server using ssh-copy-id.

80. How do you secure a Linux server?
Implement best practices such as using firewalls, keeping the system updated, using SSH key-based authentication, and configuring SELinux.

Practical Scenario-Based Questions

81. How would you troubleshoot a slow system?
Check system resource usage (top, htop), disk I/O (iotop), and network traffic (iftop). Analyze system logs and identify any resource-hogging processes.

82. What would you do if a server is not responding?
Check network connectivity, ensure the server is powered on, and verify that essential services are running. Use ping, ssh, and telnet for troubleshooting.

83. How do you recover a deleted file in Linux?
If backups are in place, restore from backup. Use tools like extundelete or testdisk for file recovery on ext file systems.

84. How would you handle a disk space full issue?
Identify large files using du and clean up unnecessary files. Check for log files that can be archived or deleted.

85. How do you update a package without breaking dependencies?
Use package managers (apt-get, yum, etc.) and ensure to update all dependencies as needed.

86. What steps would you take to secure a newly deployed Linux server?
Configure firewalls, disable root login, set up SSH key-based authentication, apply security updates, and configure SELinux.

87. How do you monitor a specific process?
Use top, htop, or ps to monitor the process. For long-term monitoring, use tools like Prometheus.

88. How do you handle a failing service?
Check the service status using systemctl, review logs for errors, restart the service, and investigate the root cause.

89. What would you do if you forgot the root password?
Boot into single-user mode or use a live CD to reset the root password.

90. How do you handle kernel panic?
Review logs to identify the cause, check for hardware issues, update or revert the kernel, and consult documentation or support.

Troubleshooting and Debugging

91. How do you analyze a core dump?
Use the gdb tool to analyze core dumps and identify the cause of a crash.

92. What is the dmesg command used for?
dmesg displays kernel-related messages and can be used to troubleshoot hardware and driver issues.

93. How do you debug a shell script?
Use set -x to enable debugging mode and set +x to disable it.

94. What are the common causes of a slow Linux system?
High CPU or memory usage, disk I/O issues, network congestion, and software bugs.

95. How do you troubleshoot network issues in Linux?
Use commands like ping, traceroute, netstat, ss, and tcpdump.

96. How do you find the cause of a system crash?
Review system logs (/var/log/), use dmesg, and analyze core dumps.

97. What is log rotation and how do you configure it?
Log rotation manages log file sizes and durations. Configure it using the logrotate utility.

98. How do you handle a file permission error?
Use ls -l to check permissions and chmod or chown to correct them. Please read A Comprehensive Guide to Linux File Permissions

99. What is the strace command used for?
strace is used to trace system calls and signals, helpful for debugging.

100. How do you check for hardware errors?
Use dmesg, lshw, lsblk, and smartctl to diagnose hardware issues.

Conclusion

Mastering Linux is essential for anyone in the DevOps field. This comprehensive list of 100 Linux interview questions covers a wide range of topics, from basic commands to advanced troubleshooting. Whether you’re preparing for an interview or looking to deepen your understanding, these questions and answers will serve as a valuable resource. Keep learning and stay updated with the latest trends and tools in the DevOps ecosystem.

If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.

Linux Interview Questions for DevOps – FAQs

1. What is the most important skill for a DevOps engineer?
Proficiency in Linux and scripting is crucial for automating processes and managing infrastructure efficiently.

2. How can I improve my Linux skills for a DevOps role?
Practice regularly, use Linux in your projects, and study advanced topics like kernel tuning and security practices.

3. What are some common tools used in DevOps?
Common tools include Jenkins, Docker, Kubernetes, Ansible, and Prometheus.

4. Why is Linux preferred in DevOps environments?
Linux offers flexibility, robustness, and a rich set of tools and utilities that are ideal for automation and deployment.

5. How do you stay updated with DevOps practices?
Follow industry blogs, participate in online forums, attend conferences, and take courses to keep up with the latest trends and technologies.

Exit mobile version