50 Linux Interview Questions and Answers 2025

Linux, the powerful open-source operating system, has revolutionized the world of computing and has become the backbone of many technological infrastructures. As its popularity continues to soar, job seekers in the IT industry must demonstrate their Linux expertise during interviews to secure coveted positions. Whether you’re a seasoned Linux professional or just starting your journey with the penguin, mastering these 50 Linux interview questions and answers will give you a solid foundation to excel in your next interview.

Linux Interview Questions
Linux Interview Questions

1. What is Linux?
Linux is a free and open-source operating system based on the Unix-like kernel. It was first developed by Linus Torvalds in 1991 and has since grown to power a vast range of devices and systems.

2. What is the Linux shell?
The Linux shell is a command-line interface that allows users to interact with the operating system by typing commands instead of using a graphical interface.

3. How do you find out the current working directory in the shell?
The pwd command displays the current working directory.

4. How can you list files and directories in a directory?
The ls command is used to list files and directories in a directory.

5. How do you create a new directory?
Use the mkdir command followed by the directory name to create a new directory.

6. How do you remove a file?
The rm command followed by the file name is used to remove a file.

7. What is the difference between rm and rm -r?
rm is used to remove individual files, while rm -r is used to remove directories and their contents recursively.

8. How can you copy a file?
The cp command followed by the source file and destination file allows you to copy a file.

9. What is the purpose of the mv command?
The mv command is used to move files or directories from one location to another or rename files.

10. How do you search for text within a file?
The grep command followed by the search term and the file name is used to search for text within a file.

11. How do you count the number of lines, words, and characters in a file?
The wc command followed by the file name provides the line, word, and character count.

12. What does the ps command do?
The ps command displays information about the currently running processes.

13. How can you stop a running process?
The kill command followed by the process ID terminates a running process.

14. What is the purpose of the chmod command?
The chmod command is used to change file permissions.

15. How do you grant execute permissions to a file?
Use the command chmod +x filename to grant execute permissions to a file.

16. What are the different run levels in Linux?
Run levels in Linux define the operating state of the system. Common run levels are 0 (halt), 1 (single-user mode), 5 (multi-user graphical mode), etc.

17. How can you change the run level?
The init command followed by the run level number changes the run level.

18. What is the purpose of the df command?
The df command displays information about disk space usage on the file system.

19. How do you check memory usage in Linux?
The free command provides information about memory usage.

20. What is the purpose of the top command?
The top command displays real-time information about system processes, CPU usage, and memory usage.

21. How do you find information about a command in Linux?
The man command followed by the command name displays the manual page with information about the command.

22. How do you compress files in Linux?
The tar command is used to compress files into a tarball. To compress using gzip, use tar -czvf filename.tar.gz files.

23. How do you decompress a tarball?
To decompress a tarball, use tar -xzvf filename.tar.gz.

24. What is the purpose of the ssh command?
The ssh command is used to securely connect to a remote machine.

25. How do you create an SSH key pair?
Use the ssh-keygen command to generate an SSH key pair.

26. How do you add a new user in Linux?
The useradd command followed by the username creates a new user.

27. How do you change the password for a user?
The passwd command followed by the username changes the user’s password.

28. What is a symbolic link in Linux?
A symbolic link is a reference to another file or directory. It acts as a shortcut.

29. How do you create a symbolic link?
The ln -s command followed by the source and destination creates a symbolic link.

30. What is the purpose of the crontab command?
The crontab command is used to schedule recurring tasks on Linux.

31. How do you view the contents of a file in the terminal?
The cat command displays the contents of a file.

32. What is the purpose of the tee command?
The tee command reads from standard input and writes to standard output and files simultaneously.

33. How do you terminate a frozen graphical application?
The xkill command allows you to force close a frozen graphical application.

34. How can you check the version of Linux distribution?
The lsb_release command provides information about the Linux distribution version.

35. How do you check the system hardware information?
The lshw command displays detailed information about the system hardware.

36. What is the purpose of the find command?
The find command is used to search for files and directories based on various criteria.

37. How can you find and replace text in a file from the command line?
The sed command is used for text manipulation, including find and replace operations.

38. How do you list open ports in Linux?
The netstat or ss command can be used to list open ports and network connections.

39. What is the purpose of the ifconfig command?
The ifconfig command displays information about network interfaces.

40. How can you mount and unmount devices in Linux?
The mount command is used to mount a device, and umount is used to unmount it.

41. How do you check the status of services in Linux?
The systemctl command provides information about the status of services.

42. What is the purpose of the chown command?
The chown command is used to change the ownership of files and directories.

43. How do you find files by their permissions?
The find command can search for files based on their permissions.

44. What is the purpose of the tar command?
The tar command is used to create archives or extract files from them.

45. How do you check system resource usage in real-time?
The htop command provides real-time monitoring of system resources.

46. How do you check the contents of a compressed file without extracting it?
The zcat command allows you to view the contents of a compressed file without extracting it.

47. How can you send email from the command line?
The mail command allows you to send emails directly from the terminal.

48. What is the purpose of the awk command?
The awk command is used for text processing and data extraction.

49. How do you change the hostname in Linux?
The hostname command followed by the new hostname changes the system’s hostname.

50. How do you check the history of commands executed in the shell?
The history command displays the list of previously executed commands.

Linux Interview Questions
Linux Interview Questions

Conclusion
Mastering the Linux command line is a crucial skill for any IT professional. These 50 Linux interview questions and answers cover a wide range of topics and will help you showcase your knowledge and expertise during interviews. Remember to practice these commands and concepts to gain confidence and excel in your Linux career pursuits. Whether you’re a system administrator, developer, or just a curious enthusiast, Linux offers a plethora of opportunities and challenges that continue to make it a dominant force in the tech world. Good luck with your Linux journey!

Leave a Comment