Linux Interview Questions
Linux Interview Questions
3. Process Management
How do you check running processes in Linux?
o Use ps aux, top, or htop.
How do you terminate a process using kill, killall, or pkill?
o Use kill PID, killall process_name, or pkill process_name.
What is the difference between nice and renice?
o nice sets priority for a new process, renice changes priority of a running
process.
How do you check CPU and memory usage of a process?
o Use top, htop, or ps aux --sort=-%mem | head -5.
What does the top and htop command do?
o top shows running processes, htop is a more user-friendly version of top.
4. Package Management
What is the difference between apt, yum, dnf, and zypper?
o apt (Debian-based), yum & dnf (RHEL-based), zypper (SUSE-based) are
package managers.
How do you install, remove, and update packages in Linux?
o apt install/remove/update package (Debian), yum/dnf
install/remove/update package (RHEL).
How do you find the location of an installed package?
o Use which package or dpkg -L package.
What is the difference between dpkg and rpm?
o dpkg is for Debian-based systems, rpm is for RHEL-based systems.
5. Networking Commands
How do you check open ports in Linux?
o Use netstat -tulnp or ss -tulnp.
What is the difference between netstat and ss?
o ss is faster and more powerful than netstat.
How do you test network connectivity using ping?
o Use ping destination_IP.
How do you check DNS resolution in Linux?
o Use nslookup or dig domain.com.
How do you find your system's IP address?
o Use ip a or hostname -I.
How do you permanently change the hostname of a Linux machine?
o Modify /etc/hostname and restart the system.
o Using this command : hostnamectl set-hostname “vaibhav”
6. Log Management
Where are system logs stored in Linux?
o In /var/log/ directory.
How do you check system logs using journalctl?
o Use journalctl -xe.
How do you filter logs using grep?
o Use grep "keyword" /var/log/syslog.
What is the purpose of /var/log/messages and /var/log/syslog?
o They store system messages and logs.
8. Disk Management
How do you check disk partitions in Linux?
o Use lsblk or fdisk -l.
How do you mount and unmount a file system?
o Use mount /dev/sdX /mnt and umount /mnt.
How do you create a new partition using fdisk or parted?
o Use fdisk /dev/sdX, then create partitions interactively.
What is LVM, and how do you create an LVM partition?
o LVM allows flexible disk management; use pvcreate, vgcreate, and
lvcreate.
How do you start, stop, restart, and check the status of a service?
o Start: systemctl start <service>
o Stop: systemctl stop <service>
o Restart: systemctl restart <service>
o Status: systemctl status <service>
What is the difference between systemctl and service commands?
o systemctl is used in modern Linux distributions (systemd-based) and
provides more functionality.
o service is used in older distributions that use SysVinit.
How do you enable a service to start at boot?
o systemctl enable <service> ensures the service starts automatically on
boot.