Basic Questions
- What is Linux?
- Answer: Linux is an open-source, Unix-like operating system kernel that is widely used in servers, desktops, and embedded systems.
- What is the Linux kernel?
- Answer: The Linux kernel is the core part of the operating system that manages hardware resources, system processes, and enables software to interact with hardware.
- What is a Linux distribution?
- Answer: A Linux distribution (distro) is a packaged version of the Linux operating system, including the kernel and a variety of software, tools, and a package management system (e.g., Ubuntu, CentOS, Debian).
- How do you check the current version of the kernel?
- Answer: Use the
uname -r
command.
- Answer: Use the
- What is a shell in Linux?
- Answer: A shell is a command-line interpreter that provides a user interface for accessing the services of the kernel (e.g., Bash, Zsh).
Intermediate Questions
- What is the purpose of the
/etc/fstab
file?- Answer: The
/etc/fstab
file contains information about disk partitions and filesystems, specifying how they should be automatically mounted during boot.
- Answer: The
- How do you change file permissions in Linux?
- Answer: Use the
chmod
command to change file permissions.
- Answer: Use the
- What is the difference between
apt
andyum
?- Answer:
apt
is a package management tool used in Debian-based distributions, whileyum
is used in RedHat-based distributions.
- Answer:
- How do you view running processes in Linux?
- Answer: Use the
ps
,top
, orhtop
commands to view running processes.
- Answer: Use the
- What is a symbolic link?
- Answer: A symbolic link (symlink) is a type of file that points to another file or directory, allowing you to create shortcuts or references.
Advanced Questions
- Explain how you would troubleshoot a network issue in Linux.
- Answer: Use tools like
ping
to check connectivity,ifconfig
orip
to check interface configurations,netstat
orss
to check active connections, andtraceroute
to track packet paths.
- Answer: Use tools like
- What is
crontab
and how do you use it?- Answer:
crontab
is a configuration file that specifies scheduled tasks (cron jobs) to be run at specific times. Usecrontab -e
to edit,crontab -l
to list, andcrontab -r
to remove cron jobs.
- Answer:
- What is SELinux?
- Answer: Security-Enhanced Linux (SELinux) is a security module in the Linux kernel that provides a mechanism for supporting access control security policies.
- How do you monitor system performance in Linux?
- Answer: Use commands like
top
,vmstat
,iostat
,free
,sar
, and tools likenmon
,glances
, orperf
.
- Answer: Use commands like
- What are inodes in Linux?
- Answer: Inodes are data structures on a filesystem that store information about a file or directory, such as its size, owner, permissions, and disk location.
Scenario-Based Questions
- Describe how you would set up a web server on Linux.
- Answer: Install a web server package (e.g., Apache or Nginx) using the package manager, configure the server settings in the configuration files, start and enable the service, and ensure proper firewall rules are set.
- How would you handle disk space issues on a Linux server?
- Answer: Use commands like
df
anddu
to identify disk usage, clean up unnecessary files, compress large files, and consider adding more storage or resizing partitions.
- Answer: Use commands like
- How do you secure a Linux server?
- Answer: Implement strong passwords, disable root login over SSH, use SSH keys for authentication, keep the system updated, configure firewalls, enable SELinux or AppArmor, and regularly review security logs.
- What steps would you take to troubleshoot a slow-performing Linux system?
- Answer: Check CPU and memory usage with
top
orhtop
, analyze disk I/O withiostat
, check network activity withnetstat
, and review system logs in/var/log
.
- Answer: Check CPU and memory usage with
- How do you backup and restore data on a Linux server?
- Answer: Use tools like
rsync
,tar
, ordd
for backups, and restore data using the same tools. Automate backups with cron jobs and ensure backups are stored securely.
- Answer: Use tools like
- How would you configure RAID on a Linux server?
- Answer: Use
mdadm
to create and manage RAID arrays, specify RAID level, configure the array, and update the/etc/mdadm/mdadm.conf
file to ensure persistence.
- Answer: Use
- Explain how you would set up a firewall on a Linux server.
- Answer: Use
iptables
orfirewalld
to configure firewall rules, define policies for incoming and outgoing traffic, and ensure the firewall service is enabled and running.
- Answer: Use
- How do you manage software packages in Linux?
- Answer: Use package managers like
apt
for Debian-based distributions oryum
/dnf
for RedHat-based distributions to install, update, and remove software packages.
- Answer: Use package managers like
- Describe how you would configure a new user and set permissions in Linux.
- Answer: Use
useradd
oradduser
to create a new user, set a password withpasswd
, assign the user to groups withusermod
, and set file permissions usingchmod
andchown
.
- Answer: Use
- What is LVM and how do you use it?
- Answer: Logical Volume Manager (LVM) allows for flexible disk management. Use
pvcreate
to create physical volumes,vgcreate
to create volume groups, andlvcreate
to create logical volumes.
- Answer: Logical Volume Manager (LVM) allows for flexible disk management. Use
Advanced Questions
- Explain how you would configure and use
systemd
for managing services.- Answer:
systemd
is a system and service manager for Linux. Usesystemctl
commands to start, stop, enable, and disable services. Create and edit unit files in/etc/systemd/system/
to define services and their dependencies.
- Answer:
- What is the purpose of the
/proc
filesystem and how is it used?- Answer: The
/proc
filesystem is a virtual filesystem that provides an interface to kernel data structures. It is used to access process information and system statistics, such as CPU and memory usage, in a hierarchical file structure.
- Answer: The
- How do you handle kernel module management in Linux?
- Answer: Use
modprobe
to add or remove modules,lsmod
to list loaded modules,rmmod
to remove modules, and configure module loading options in/etc/modprobe.d/
.
- Answer: Use
- Describe the process of configuring and using SELinux in enforcing mode.
- Answer: Set SELinux to enforcing mode by editing
/etc/selinux/config
or usingsetenforce 1
. Usesemanage
andrestorecon
to manage and restore security contexts. Define policies with.te
files and compile them withcheckmodule
andsemodule_package
.
- Answer: Set SELinux to enforcing mode by editing
- What are cgroups in Linux, and how do you use them?
- Answer: Control Groups (cgroups) are a feature that limits, accounts for, and isolates resource usage (CPU, memory, disk I/O, etc.) of a collection of processes. Use
cgcreate
,cgset
, andcgexec
commands to create and manage cgroups.
- Answer: Control Groups (cgroups) are a feature that limits, accounts for, and isolates resource usage (CPU, memory, disk I/O, etc.) of a collection of processes. Use
Scenario-Based Questions
- How would you diagnose and resolve a high CPU usage issue on a Linux server?
- Answer: Use
top
orhtop
to identify processes with high CPU usage. Investigate the cause by checking logs, reviewing recent changes, and profiling the application if necessary. Optimize or kill the offending processes and consider resource limits if needed.
- Answer: Use
- Explain how you would set up a high-availability cluster using Linux.
- Answer: Use tools like
Pacemaker
andCorosync
to manage cluster resources and services. Configure fencing devices for node isolation, set up a shared storage system like DRBD or a distributed filesystem, and ensure proper network configuration for redundancy.
- Answer: Use tools like
- How do you implement disk quotas in Linux?
- Answer: Enable disk quotas by editing
/etc/fstab
to includeusrquota
andgrpquota
options, remount the filesystem, and usequotacheck
to create quota files. Set quotas withedquota
and enforce them withquotaon
.
- Answer: Enable disk quotas by editing
- Describe how you would recover a Linux system that fails to boot.
- Answer: Boot from a live CD or rescue mode. Check and repair filesystem errors with
fsck
, reconfigure the bootloader (GRUB) if needed, review and edit configuration files in/etc
, and check kernel logs for errors.
- Answer: Boot from a live CD or rescue mode. Check and repair filesystem errors with
- How would you secure a Linux server against unauthorized access?
- Answer: Implement strong passwords and use SSH keys for authentication. Disable root login over SSH, configure firewalls with
iptables
orfirewalld
, use SELinux or AppArmor for access control, keep the system updated, and regularly review logs.
- Answer: Implement strong passwords and use SSH keys for authentication. Disable root login over SSH, configure firewalls with
- Explain how you would set up a Linux server to act as a router.
- Answer: Enable IP forwarding by editing
/etc/sysctl.conf
or usingsysctl -w net.ipv4.ip_forward=1
. Configureiptables
ornftables
for NAT and routing rules. Ensure network interfaces are properly configured for internal and external traffic.
- Answer: Enable IP forwarding by editing
- How do you automate tasks in Linux using cron and anacron?
- Answer: Use
crontab -e
to edit cron jobs for periodic tasks and define their schedule with cron syntax. Use/etc/anacrontab
to configureanacron
for tasks that need to run on a non-fixed schedule or on systems that are not always on.
- Answer: Use
- What steps would you take to investigate a disk I/O bottleneck on a Linux system?
- Answer: Use
iostat
,vmstat
, andiotop
to monitor disk I/O performance. Check for high usage processes, review filesystem performance, optimize applications accessing the disk, and consider hardware upgrades or additional disks if necessary.
- Answer: Use
- How would you set up and manage a software RAID array on a Linux server?
- Answer: Use
mdadm
to create and manage RAID arrays. Configure the array withmdadm --create
, monitor it withmdadm --detail
, and ensure persistence by updating/etc/mdadm/mdadm.conf
and creating an appropriate entry in/etc/fstab
.
- Answer: Use
- Describe how you would secure network services on a Linux server.
- Answer: Limit the exposure of services by configuring firewalls and using TCP wrappers. Disable unnecessary services, use TLS/SSL for encrypted communication, regularly update software, and use tools like
fail2ban
to protect against brute-force attacks.
- Answer: Limit the exposure of services by configuring firewalls and using TCP wrappers. Disable unnecessary services, use TLS/SSL for encrypted communication, regularly update software, and use tools like
- How do you configure and use LVM snapshots for backups?
- Answer: Create LVM snapshots using
lvcreate --snapshot
, mount the snapshot, and perform backups from the mounted snapshot to avoid downtime. After backups, remove the snapshot withlvremove
.
- Answer: Create LVM snapshots using
- Explain how you would configure a VPN server on Linux.
- Answer: Install and configure a VPN solution like OpenVPN or WireGuard. Set up server and client configurations, manage keys and certificates, and configure firewall and routing rules to ensure secure communication.
- How would you set up centralized logging for multiple Linux servers?
- Answer: Use
rsyslog
orsyslog-ng
to configure a centralized logging server. Set up client servers to forward logs to the central server using appropriate configurations in/etc/rsyslog.conf
or/etc/syslog-ng/syslog-ng.conf
.
- Answer: Use
- Describe how you would optimize the performance of a MySQL database running on Linux.
- Answer: Tune MySQL configuration parameters in
my.cnf
, optimize queries and indexing, use tools likemysqltuner
for recommendations, regularly analyze slow query logs, and consider hardware upgrades like SSDs for better performance.
- Answer: Tune MySQL configuration parameters in
- How do you configure and use
iptables
for firewall management?- Answer: Define firewall rules using
iptables
commands to accept, drop, or reject traffic based on criteria like source/destination IP, port, and protocol. Save the configuration withiptables-save
and ensure rules are loaded at boot with appropriate init scripts or systemd services.
- Answer: Define firewall rules using
- Explain how you would set up and manage a Docker environment on Linux.
- Answer: Install Docker, configure the Docker daemon, create and manage containers using
docker
commands, use Docker Compose for multi-container applications, and secure the Docker environment by controlling access to the Docker daemon.
- Answer: Install Docker, configure the Docker daemon, create and manage containers using
- How do you use and manage system logs in Linux?
- Answer: View system logs using
journalctl
forsystemd
systems andtail
,less
, orgrep
for log files in/var/log
. Rotate logs usinglogrotate
to manage log size and retention, and configure logging services likersyslog
orsyslog-ng
.
- Answer: View system logs using
- Describe the process of patch management in Linux.
- Answer: Regularly update the package repository metadata using
apt-get update
oryum check-update
. Apply updates and patches usingapt-get upgrade
oryum update
. Automate updates using cron jobs or tools likeunattended-upgrades
for Debian-based systems.
- Answer: Regularly update the package repository metadata using
- How would you implement and manage disk encryption on a Linux system?
- Answer: Use
LUKS
(Linux Unified Key Setup) for disk encryption. Create an encrypted partition withcryptsetup
, open and format the partition, and configure/etc/crypttab
and/etc/fstab
to ensure the partition is mounted at boot.
- Answer: Use
- How do you ensure system integrity and detect unauthorized changes on a Linux server?
- Answer: Use tools like
AIDE
(Advanced Intrusion Detection Environment) orTripwire
to create and monitor integrity databases. Regularly check for unauthorized changes and set up alerts for detected discrepancies.
- Answer: Use tools like