0% found this document useful (0 votes)
88 views9 pages

Linux Interview Questions

The document is an article providing a comprehensive list of Linux interview questions and answers, aimed at helping candidates prepare for Linux-related job roles. It covers a range of topics from basic to advanced levels, including system administration, networking, file management, security, and virtualization. Each question is paired with a concise answer, making it a useful resource for interview preparation.

Uploaded by

rajavarapu.v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views9 pages

Linux Interview Questions

The document is an article providing a comprehensive list of Linux interview questions and answers, aimed at helping candidates prepare for Linux-related job roles. It covers a range of topics from basic to advanced levels, including system administration, networking, file management, security, and virtualization. Each question is paired with a concise answer, making it a useful resource for interview preparation.

Uploaded by

rajavarapu.v
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

An article featuring Linux Interview Questions and Answers, which is

designed to help candidates prepare for Linux-based roles. The


questions range from basic to advanced levels to cover a variety of
Linux topics.📚

Follow – Krishan Bhatt

Top Linux Interview Questions and Answers


Basic Linux Questions
1. What is Linux?

Linux is a free and open-source operating system based on Unix. It is known for its stability,
security, and flexibility.

2. What is the difference between Linux and Unix?

Linux is open-source and free, while Unix is proprietary and licensed. Linux is widely used
on servers and desktops, whereas Unix is more commonly used in academic and enterprise
environments.

3. What is the Linux kernel?

The Linux kernel is the core of the Linux operating system that interacts with hardware and
manages resources like CPU, memory, and storage.

4. What are the features of Linux?


• Open-source
• Multitasking
• Multi-user support
• Security (IPTables, SELinux)
• Portability
• Rich networking support

5. How do you check the current Linux kernel version?

Use the command:

uname -r

6. What are Linux distributions?


Linux distributions are different versions of Linux built on the Linux kernel, e.g., Ubuntu,
Fedora, CentOS, Debian, and Red Hat Enterprise Linux (RHEL).

7. What command is used to display system information?


uname -a

8. How do you check disk usage in Linux?


df -h

9. What does the ls command do?

It lists the contents of a directory.

10. How do you create a file in Linux?


• Using touch: touch filename
• Using a text editor: vim filename or nano filename

Intermediate Linux Questions


11. How do you view the contents of a file?
• cat filename
• less filename
• more filename

12. What is the purpose of the chmod command?

It changes file permissions.

13. Explain file permissions in Linux.

Linux permissions include:


• Read (r): 4
• Write (w): 2
• Execute (x): 1

They are grouped into:


• User (u): Owner
• Group (g): Assigned group
• Others (o): Everyone else
14. What is the use of the grep command?

grep searches for patterns in files.

Example:

grep "pattern" filename

15. How do you find the size of a directory?


du -sh directory_name

16. What is a symbolic link?

A symbolic link is a reference or shortcut to another file or directory.

17. What is the difference between a hard link and a soft link?
• Hard link: Directly points to the file’s inode, even if the original file is deleted.
• Soft link: Points to the file path and breaks if the original file is deleted.

18. How do you kill a process in Linux?

Use the kill command followed by the process ID (PID):

kill -9 PID

19. How do you find running processes?


ps aux

20. What does the cron command do?

The cron utility schedules repetitive tasks.

Advanced Linux Questions


21. What is SELinux?

SELinux (Security-Enhanced Linux) is a security module that enforces access control


policies.

22. What is the difference between ext4 and xfs?


• ext4: Widely used, supports journaling, and is good for general-purpose use.
• xfs: High-performance, ideal for large-scale data management.

23. How do you check open ports on a system?


netstat -tuln

or

ss -tuln

24. Explain the difference between df and du.


• df: Shows disk space usage at the filesystem level.
• du: Shows disk usage of files and directories.

25. What is the umask command?

umask sets default permissions for newly created files.

Network and System Administration

26. How do you configure a static IP in Linux?

Edit the network configuration file:

/etc/sysconfig/network-scripts/ifcfg-eth0

27. What does the ifconfig command do?

It displays or configures network interfaces.

28. How do you check the system’s uptime?


uptime

29. How do you restart a service?


systemctl restart service_name

30. What is the iptables command used for?

It manages firewall rules.

Shell Scripting and Automation


31. What is a shell?

A shell is a command-line interpreter that executes user commands.

32. Write a simple shell script to display “Hello, World.”


#!/bin/bash
echo "Hello, World"
33. How do you schedule a one-time task?

Use the at command:

echo "command" | at 10:00


Advanced Linux Questions:
34. What is the purpose of the /etc/fstab file?

It contains the details of file systems to be automatically mounted at boot.

35. How do you view the contents of the /etc/fstab file?


cat /etc/fstab

36. What is a runlevel? How do you check it?

Runlevels define the state of the system, such as single-user mode or graphical mode. You
can check it using:

who -r

37. What is the difference between soft and hard mounts in NFS?
• Soft Mount: Returns an error if the server is unavailable.
• Hard Mount: Keeps retrying until the server responds.

38. How do you add a user in Linux?


useradd username

39. How do you change a user’s password?


passwd username

40. How do you delete a user?


userdel username

Performance Monitoring
41. How do you check CPU usage in Linux?
top

42. How do you monitor memory usage?


free -h
43. What is the purpose of the vmstat command?

vmstat provides information about system performance, including memory, CPU, and I/O.

44. How do you check disk I/O performance?


iostat

45. What is the sar command used for?

The sar command is used for collecting and viewing system activity reports.

Networking
46. How do you test network connectivity?
ping hostname_or_ip

47. What is the purpose of the traceroute command?

It shows the route packets take to reach a host.

48. How do you check open connections on the server?


netstat -an

or

ss -an

49. How do you list all network interfaces?


ip link show

50. How do you configure a DNS server in Linux?

Edit the /etc/resolv.conf file to include nameserver entries:

nameserver 8.8.8.8
nameserver 8.8.4.4

Storage and File Systems


51. How do you mount a filesystem?
mount /dev/sdX /mnt

52. How do you unmount a filesystem?


umount /mnt

53. What is the fsck command?

fsck checks and repairs file system errors.

54. How do you create a partition in Linux?

Use the fdisk command:

fdisk /dev/sdX

55. How do you create a filesystem?


mkfs.ext4 /dev/sdX

File Management
56. How do you copy a file in Linux?
cp source_file destination_file

57. How do you move or rename a file?


mv source_file destination_file

58. How do you delete a file?


rm filename

59. What is the difference between tar and gzip?


• tar: Archives multiple files into a single file.
• gzip: Compresses a single file.

60. How do you extract a .tar.gz file?


tar -xvzf filename.tar.gz

Security
61. How do you change the ownership of a file?
chown user:group filename

62. How do you find files with specific permissions?


find /path -perm 777
63. How do you set a firewall rule to allow traffic on port 80?
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

64. What is the sudo command?

sudo allows users to run commands with administrative privileges.

65. How do you check the status of SELinux?


sestatus

Package Management
66. How do you install a package in Red Hat-based systems?
yum install package_name

or

dnf install package_name

67. How do you install a package in Debian-based systems?


apt install package_name

68. How do you check installed packages?


rpm -qa

or

dpkg -l

69. How do you remove a package?

For Red Hat:

yum remove package_name

For Debian:

apt remove package_name

70. How do you update all packages?

For Red Hat:

yum update
For Debian:

apt upgrade

Virtualization and Containers


71. What is virtualization?

Virtualization allows multiple operating systems to run on the same hardware by


abstracting resources.

72. What is Docker?

Docker is a containerization platform that packages applications and dependencies into


portable containers.

73. How do you list Docker containers?


docker ps

74. How do you start a Docker container?


docker start container_id

75. How do you stop a Docker container?


docker stop container_id

You might also like