Preparing for a Linux interview involves understanding various topics, ranging from basic commands to advanced system administration tasks. Here are some commonly asked Linux interview questions across different levels of expertise:
Basic Questions
-
What is Linux and what are its advantages?
- Linux is an open-source operating system based on Unix. Advantages include its security, flexibility, free cost, and strong community support.
-
Explain the directory structure of Linux.
- The Linux file system is hierarchical. Common directories include
/,/bin,/etc,/home,/var,/tmp,/usr,/lib,/opt, and/root.
- The Linux file system is hierarchical. Common directories include
-
What are the basic commands for file management?
-
ls,cp,mv,rm,mkdir,rmdir,touch,cat,more,less.
-
-
How do you change file permissions in Linux?
- Using the
chmodcommand. For example,chmod 755 filename.
- Using the
-
What is the difference between a hard link and a soft link?
- A hard link is a direct reference to the inode of a file, while a soft link (symlink) is a pointer to the pathname of the file.
Intermediate Questions
-
How do you check the system load and memory usage?
- Using commands like
top,htop,vmstat,free,uptime.
- Using commands like
-
How do you find and kill a process?
- Using
ps,top,htop, andkillcommands. For example,kill -9 PID.
- Using
-
Explain the use of the
grepcommand.-
grepis used to search text using patterns. For example,grep "pattern" file.txt.
-
-
What is a cron job and how do you set one up?
- A cron job is a scheduled task using the
crondaemon. Set up withcrontab -e.
- A cron job is a scheduled task using the
-
How do you view and manage disk usage?
- Using
dfandducommands. For example,df -hfor disk space anddu -sh *for directory sizes.
- Using
Advanced Questions
-
Explain how you would troubleshoot a network issue in Linux.
- Using tools like
ping,traceroute,netstat,ss,ifconfig/ip,tcpdump.
- Using tools like
-
What is LVM and how do you manage it?
- Logical Volume Manager (LVM) allows for flexible disk management. Commands include
pvcreate,vgcreate,lvcreate,lvextend,lvreduce.
- Logical Volume Manager (LVM) allows for flexible disk management. Commands include
-
How do you secure a Linux server?
- Regular updates, configuring firewalls (
iptables/firewalld), SSH hardening, using SELinux/AppArmor, setting up proper permissions, disabling unnecessary services.
- Regular updates, configuring firewalls (
-
What is a kernel, and how do you upgrade it?
- The kernel is the core of the OS managing system resources. Upgrade using package managers like
apt,yum, or compiling from source.
- The kernel is the core of the OS managing system resources. Upgrade using package managers like
-
Explain the use of Docker in Linux.
- Docker is used for containerization. Commands include
docker run,docker build,docker ps,docker-compose.
- Docker is used for containerization. Commands include
Scripting and Automation
-
Write a simple bash script to back up a directory.
#!/bin/bash tar -czvf backup.tar.gz /path/to/directory -
How do you automate tasks in Linux?
- Using shell scripts, cron jobs, and tools like Ansible, Puppet, or Chef.
-
What are environment variables and how do you set them?
- Variables that affect the behavior of processes. Set them using
export VAR=value.
- Variables that affect the behavior of processes. Set them using
-
Describe the use of
awkandsed.-
awkis used for pattern scanning and processing.sedis a stream editor for filtering and transforming text.
-
-
How do you monitor log files in real-time?
- Using
tail -f /var/log/syslogorless +F /var/log/syslog.
- Using
Practical Scenario Questions
-
How would you recover a deleted file in Linux?
- Using tools like
extundelete,testdisk, or from backups.
- Using tools like
-
What steps would you take to improve the performance of a Linux server?
- Optimize applications, adjust kernel parameters, monitor resource usage, upgrade hardware, and use load balancing.
-
How do you set up a simple web server on Linux?
- Install and configure Apache (
httpd), Nginx, or another web server.
- Install and configure Apache (
-
How would you configure a RAID array in Linux?
- Using
mdadmfor software RAID.
- Using
-
Describe the process of setting up a firewall in Linux.
- Using
iptablesorfirewalldto create rules for traffic filtering.
- Using
These questions cover a broad range of topics and are commonly asked in Linux interviews to assess a candidate's knowledge and problem-solving skills.
Top comments (0)