Interview Questions and Answers on Linux
Prepare with Interview Questions and Answers on Linux: Master essential Linux commands, concepts, and tips to ace your next Linux-based technical interview.
Q1) What is Linux?
➔
- Linux is an operating system, which is based on Linux Kernel. • It is an open-source operating system that can run on different hardware platforms.
- It provides a free and low-cost operating system for users. • It is a user-friendly environment where they can easily modify and create variations in the source code.
Q2) Who invented Linux? Explain the history of Linux.
➔
- Linus Torvalds created Linux. Linus Torvalds was a student at the University of Helsinki, Finland in 1991.
- He started writing code on his own to get the academic version of Unix for free. Later on, it became popular as a Linux Kernel.
Q3) What is the difference between Linux and Unix?
➔
And some other differences.
- Linux is a Unix clone: But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX.
- Linux Is Just Kernel: All Linux distributions include GUI system, GNU utilities, installation & management tools, GNU c/c++ Compilers, Editors (vi), and various applications like OpenOffice, and Firefox. UNIX operating systems are considered as a complete OS as everything comes from a single vendor.
- Security and Firewall: Linux comes with an open-source Netfilter and IPTables-based firewall tool to protect your server and desktop from crackers and hackers. UNIX operating systems come with its own firewall products.
- Backup and Recover: UNIX and Linux come with their own set of tools for backing up data to tape and other backup media. However, both Linux and UNIX share some common tools such as tar, dump/restore, and cpio, etc.
Q4) What is the core of the Linux operating systems Benefits?
The kernel is the core of the Linux operating system.
Q5) What is the Linux Kernel?
➔
- The kernel is the heart of the operating system. It acts as a bridge between software and hardware.
- If Software requests the hardware, then the kernel delivers the data between the software and hardware.
- For example, if you want to play a song you should launch your default player, it requests the kernel to play a song, now kernel will contact the hardware to seek the permissions or to seek the hardware components like if you plugged in any headset to the device.
- Most of the Android phones use Linux kernels.
- Yes, the kernel can edit, because it is released under General Public License.
Q6) What is BASH?
➔
- Bash is a Unix shell and command processor written by Brian Fox for the GNU project.
- It is free software and acts as a replacement for Bourne Shell. • It is an interpreted and not compiled process that can also be run in the terminal window.
- This allows users to write commands and cause actions. • Bash is capable of reading commands from shell scripts.
Q7) What is LILO?
➔
- LILO means Linux Loader is a boot loader that is used for the Linux operating system.
- Most of the Linux Operating systems use LILO, to boot the operating system into main memory to start the operations.
Q8) What is CLI?
➔
- CLI means Command language Interpreter. It interacts with the computer program, where the user issues commands in the form of text lines.
- It Interacts with the computer terminals also; the interface accepts the text lines and converts them as a command to the operating system.
Q9) What is the advantage of Open Source?
➔
- Linux was one of the first open-source technologies, many programmers added software that is completely open to the users, which means you can download the file and change the code as you like.
- It has a wide range of options for users and increased security.
Q10) What is the disadvantage of Open Source?
➔
- Difficulty of use
- Compatibility Issues
- Liabilities and warranties
- Hidden costs
Q11) What is Shell?
➔
Shell is a computer program that acts as an interface between the user and the kernel. Users can communicate with the kernel by writing programs, commands, and scripts on the shell. It accepts human-readable commands and converts them into the kernel-understandable language.
Q12) How many types of Shells are there in Linux?
➔ There are five Shells in Linux:
- C Shell (csh): It is like C syntax and provides spelling checking and job control.
- Korn Shell (ksh): This is a high-level programming language shell. • Z Shell (Zsh): It provides some unique nature like it observes login/logout watching, file name generating, startup files, and closing comments.
- Bourne Again Shell (bash): It is the default to Linux distributions.
- Friendly Interactive Shell (Fish): It provides web-based configuration, auto-suggestions, etc.
Q13) What are the basic components of Linux?
➔Basic components of Linux:
- Kernel: It is the core component of Linux, it acts as an interface between software and hardware.
- Shell: It acts as an interface between the user and the Kernel. • GUI: It stands for Graphic User Interface, which is another way for the user to interact with the system. But it is unlike images, buttons, and text boxes for interaction.
- System Utilities: These are the software functions that allow users to manage the computer.
- Application Programs: A set of functions designed to perform a set of tasks.
Q14) How do you open a command prompt when issuing a command?
➔Launch your terminal by pressing CTRL+ALT+T or by giving the terminal in the menu search bar.
Q15) What is a swap space?
- Swap Space is used when the physical Ram memory is running out. It will move the RAM inactive pages to the swap space. • It can be considered in the form of a dedicated swap partition or a swap file.
Q16) What is the GUI?
➔
- GUI means Graphical User Interface. It is a human-computer interface that uses windows, images, icons, and menus which can be manipulated by using a mouse.
- Most of the modern applications in electronic gadgets communicate with the user through GUI.
- GUI is a combination of graphical and textual interaction that uses buttons, menus, message boxes, etc.
Q17) Explain File Permission types in Linux.
➔ Each file or directory has 3 permissions
They are :
- Read– It means that only they can read the file.
- Write– It means that they can write the file or modify the file of a directory.
- Execute– It affects the user’s capability to execute the file or to view the file of a directory.
Q18) What are the environmental variables?
➔
- They are dynamic values that affect the process of programs on a computer.
- They exist in every operating system and their types may vary.
- They can be created, edited, saved, and deleted and they also give information about the system behavior.
Q19) What are the symbolic links?
➔
- It will be redirected to another file using its path. • Target files do not contain any data. Symbolic links redirect to another entry somewhere in the file system.
- If the target file is deleted, the link to that file is removed, but not the file.
Q20) What are the basic components of Linux?
➔The basic components of Linux are given below:
- GUI
- System Utilities
- Shell
- Application Programs
- Kernel
Q21) What are the hard links?
➔
- A hard link is another name for an existing file on Linux. • We can create so many numbers of hard links, for any file. • They can create links for other hard links.
Q22) What is redirection?
➔
- Redirection can be defined as changing the standard input and output devices.
- To redirect metacharacters are used, you can redirect the file or program.
Q23) What are Daemons?
➔
A daemon is a background process that accepts the requests for service from other computers, most of the operating systems use daemons in other forms.
Q24) Describe the root account.
➔
- Root is the user name, that default has access to all files and commands.
- The root user can do many things, but an ordinary user cannot do like installing software, changing file permissions, etc
Q25) Explain the virtual desktop.
➔
- Virtual Desktop is a user interface when you are facing the problem of how to manage multiple windows on your desktop, virtual desktop serves as an alternative.
- Virtual desktop stores remote servers and allows you to use one or more programs on a clean slate.
Q26) What are the different modes when using the v editor? ➔There are three kinds of modes in vi editors.
They are
- Command Mode/ Regular Mode
- Insertion Mode/Edit Mode.
- Ex Mode/ Replacement Mode.
Q27) What are inode and process IDs?
➔inode is a unique name given to each file and process id is a unique name given to each process.
Linux Admin Interview Questions
Q1) What are Linux admin interview questions?
➔
- Linux system administration involves managing and maintaining Linux operating systems.
- This includes tasks like configuring hardware, managing files, and handling security measures.
Q2) What is the role of the Linux kernel in the operating system? ➔
- The Linux kernel is the core of the Linux operating system, managing and controlling the computer’s hardware resources. • It functions as a bridge between applications and the data processing performed at the hardware level.
- Handling tasks like memory management, process management, and device control, the kernel ensures smooth communication between software and hardware components.
Q3) How can you monitor disk usage and performance in Linux? ➔
- Monitoring disk usage and performance in Linux can be accomplished through various tools and commands.
- Commands like df and du can display disk space usage, while iostat and vmstat provide insights into disk performance and I/O statistics.
- Tools like Sar and Atop offer more detailed reports, including the utilization rate and read/write speeds.
- Additionally, graphical tools such as GNOME System Monitor provide a user-friendly interface to visualize disk performance.
- These tools help identify potential issues, like bottlenecks or space shortages, ensuring the system runs efficiently and allowing for proactive measures to avoid potential problems.
Q4) Explain the distinctions between the init and system initialization systems. When would you use each one? ➔
init and systemd are initialization systems in Linux, used to bootstrap the user space and manage system processes after booting.
- init, the older of the two, follows a sequential process, starting services one by one. It’s simpler but can be slower and less flexible.
- systemd, on the other hand, uses parallel processing, starting services simultaneously, making booting faster and more efficient. It also provides features like dependency resolution and better logging.
While init might be found in older systems or those needing a lightweight solution, systemd is commonly used in modern Linux distributions for its enhanced control and efficiency.
Q5) What’s the significance of the /etc/resolv.conf file in Linux? ➔
- The /etc/resolv.conf file in Linux plays a crucial role in network communications. It contains information that the system uses
to map domain names to IP addresses. Specifically, it lists the Domain Name System (DNS) servers the system should use to perform these translations.
- Translating human-readable domain names into numerical IP addresses allows applications and users to connect to websites using common names instead of numeric addresses.
- If this file is misconfigured or missing, it may lead to issues accessing internet resources, making it an essential component in network configuration.
Q6) How would you enhance the security of a Linux server against common threats?
➔
Enhancing the security of a Linux server requires a combination of strategies:
- Regular system updates are crucial to patch vulnerabilities.
- Implementing a firewall helps control incoming and outgoing traffic.
- Disabling unnecessary services and using strong, unique passwords add extra layers of protection.
- Setting proper permissions and employing user account management restrict access to sensitive areas.
- Using security tools like SELinux to monitor and enforce security policies is also beneficial.
- Regular security audits and monitoring logs for suspicious activities help to detect threats early.
Q7) Can you explain the purpose of the /etc/fstab file in Linux? ➔
- The /etc/fstab file in Linux controls how disk drives and partitions are mounted and used by the system.
- It contains a list of entries that define the file systems, partitions, and remote storage devices, along with their mount points, file system types, and mount options.
- By configuring these options in /etc/fstab, you can set which devices are automatically mounted at boot time and how they should behave once mounted.
- It helps organize and manage storage, ensuring that the drives are mounted consistently and with the proper settings every time the system starts.
Q8) Describe the role and function of the iptables utility in Linux. ➔
- The iptables utility in Linux is a powerful tool used for configuring packet filtering rules within the kernel’s networking stack.
- It’s mainly responsible for defining how the system should handle network traffic.
- Admins can use iptables to create rules that permit or deny traffic based on criteria, like source and destination IP addresses, protocols, and ports.
- This allows for fine-grained control over network security, enabling the setup of firewalls, Network Address Translation (NAT), and other network-related functions.
Q9) Walk through the process of troubleshooting network connectivity issues in Linux.
➔
- Check the connection: Use ping to test connectivity to a known address.
- Inspect network configuration: Use commands like ifconfig or ip a to verify the network interface settings.
- Verify DNS resolution: Test DNS with nslookup or dig to ensure domain names are resolving correctly.
- Examine the routing table: The route command helps to check that the data is being routed to the right destination.
- Look into firewall rules: Check iptables or firewall configurations to see if traffic is being wrongly blocked.
- Review logs: System logs may contain information about network errors. Tools like dmesg or journalctl can be useful.
- Restart network services: If needed, restarting network services with systemctl restart networking might resolve the issue.
Q10) Compare the ext4, XFS, and Btrfs file systems, emphasizing their differences.
➔
- ext4 is a commonly used journaling file system in Linux. It supports file sizes up to 16 TB and offers good performance and reliability.
- XFS is known for handling large files and volumes efficiently. It can scale to support file systems up to 8 exabytes. It’s often used in high-performance environments.
- Btrfs (B-tree file system) offers advanced features like copy-on-write, snapshots, and built-in RAID. It’s designed for fault tolerance and easy management.
While ext4 provides a solid base for general usage, XFS excels in managing large files and volumes. Btrfs, on the other hand, introduces more advanced features, making it suitable for modern storage needs.
Q11) How do you monitor and audit activity on a Linux system? ➔
- Monitoring and auditing activity on a Linux system can be achieved through various tools and log files.
- Tools like top, htop, and ps allow you to monitor real-time system activity such as CPU usage, memory, and running processes.
- For auditing, the audit daemon (auditd) can track system events specified by rules, and the log files in /var/log/ directory record different types of system activities.
- Analyzing these logs with tools like awk, grep, and logwatch can help you to track, understand, and audit system behavior, ensuring security and optimal performance.
Q12) Explain the concept of process scheduling in Linux and the role of the nice command.
➔
Process scheduling in Linux is how the CPU allocates time to various running processes. The scheduler aims for fair distribution and efficient use of CPU resources. The nice command plays a part in this:
- Niceness value: Every process has a “niceness value”, ranging from -20 (high priority) to 19 (low priority).
- Adjust priority: Using the nice command, you can set or modify a process’s priority.
- Control resource allocation: A process with a lower niceness value gets more CPU time.
Using the nice command, users can influence how the CPU handles their processes, aligning with their specific needs.
Q13) How can you check for open ports on a Linux server using command-line tools?
➔
- Checking for open ports on a Linux server is a critical part of system administration, as it helps in managing network security.
- Command-line tools like netstat or ss can be used. To list all listening ports, you can use netstat -l or ss -l. To see TCP connections, netstat -t or ss -t is useful. These commands provide valuable information on open ports and related protocols.
- Filtering and monitoring open ports helps maintain proper security measures within the system.
Q14) How can you identify the root cause of occasional freezes on your Linux server, requiring a hard reboot?
➔
- For occasional Linux server freezes, analyze system logs (‘dmesg,’ ‘syslog,’ ‘journalctl’) for error messages and patterns leading up to the freeze.
- Monitor system resources with ‘top’ or ‘htop’ to detect potential resource exhaustion. Check for kernel panics, hardware issues, or problematic applications.
- Tools like ‘sar’ for historical system activity can also aid in diagnosis
Q15) User root has created a file “secret” with the below permission which must not be opened by anyone except root and another user “deepak”, how can this be done?
➔
Step 1: # ls -l secret
-rwx—— 1 root root 0 May 31 10:59 secret
Step 2: # setfacl -m u:oamsys:rwx secret
Output:
# getfacl secret
# file: secret
# owner: root
# group: root
user::rwx
user:oamsys:rwx
group::—
mask::rwx
other::—
Q16) What are some common network services and protocols used in Linux environments?
➔
- SSH (Secure Shell)
- FTP (File Transfer Protocol)
- SFTP (Secure File Transfer Protocol)
- SCP (Secure Copy Protocol)
- HTTP (Hypertext Transfer Protocol)
- HTTPS (Hypertext Transfer Protocol Secure)
- SMTP (Simple Mail Transfer Protocol)
- POP3 (Post Office Protocol 3)
- IMAP (Internet Message Access Protocol)
- NFS (Network File System)
- SMB/CIFS (Server Message Block/Common Internet File System)
- NTP (Network Time Protocol)
- SNMP (Simple Network Management Protocol)
- DHCP (Dynamic Host Configuration Protocol)
- DNS (Domain Name System)
Q17) What tools do you use to troubleshoot network issues in Linux (e.g., ping, traceroute, netstat)?
Q18) How do you troubleshoot network-related errors in log files? ➔
To troubleshoot network-related errors in log files, you can follow these steps:
- Identify the log file(s) that contain network-related
information. These logs are typically located in the /var/log/ directory and may include files such as syslog, dmesg, and messages.
- Use a text editor or command-line tool to search the log file(s) for error messages or warnings related to the network. Look for keywords such as “network,” “interface,” “routing,” and “firewall.”
- Analyze the error messages to determine the cause of the problem. Common network-related issues include
misconfigured interfaces, incorrect routing tables, and firewall rules that block traffic.
- Once you have identified the cause of the problem, take appropriate action to resolve it. This may involve editing configuration files, restarting services, or modifying firewall rules.
Q19) How do you monitor and manage system performance in Linux?
Q20) How do you diagnose and fix GRUB bootloader problems in Linux?
➔
- If the system fails to boot, boot from a live CD or USB drive. • Use the lsblk command to identify the disk and partition that contains the Linux installation.
- Mount the Linux installation to a temporary directory using the mount command.
- Use the chroot command to change the root directory to the mounted Linux installation.
- Use the grub-install command to reinstall the GRUB
bootloader. You may need to specify the disk and partition where GRUB should be installed.
- If the problem persists, use the grub-mkconfig command to regenerate the GRUB configuration file. This will scan the system for installed operating systems and generate a new GRUB menu.
To explore more do visit: Click Here
Author:-
Gandhar Bodas
Call the Trainer and Book your free demo Class For Linux Call now!!!
| SevenMentor Pvt Ltd.
© Copyright 2021 | SevenMentor Pvt Ltd.