Linux Interview Questions

What is the Linux kernel?

The Linux kernel is the core component of the Linux operating system. It handles essential tasks such as managing hardware resources, running processes, and providing system services. It acts as the intermediary between software applications and the computer hardware, enabling the operating system to function properly.

Explain the difference between Unix and Linux.

Unix is an operating system that was developed in the 1970s, while Linux is a Unix-like operating system that was created in the 1990s. Unix is proprietary and typically used in commercial settings, while Linux is open source and widely used in both commercial and personal computing environments.

How do you check the current disk usage on a Linux system?

To check the current disk usage on a Linux system, you can use the "df" command. Simply open a terminal and type "df -h" to display the disk usage in a human-readable format, showing the amount of used and available disk space on each mounted filesystem.

0+ jobs are looking for Linux Candidates

Curated urgent Linux openings tagged with job location and experience level. Jobs will get updated daily.

Explore

What is a shell in Linux and why is it important?

A shell in Linux is a command-line interface that allows users to interact with the operating system by executing commands. It is important because it provides a way to control the system, automate tasks, manage files and processes, and access various utilities and applications.

Explain the difference between a process and a thread in Linux.

In Linux, a process is a running instance of a program that has its own memory space, file descriptors, and other resources. A thread, on the other hand, is a subset of a process that shares the same memory space and resources but has its own execution path.

What is the purpose of the 'chmod' command in Linux?

The 'chmod' command in Linux is used to change the permissions of files and directories. This command allows users to set who has access to read, write, or execute a file, and can be used to restrict or grant different levels of access to different users or groups.

How do you find all files modified in the last 30 days in a directory?

To find all files modified in the last 30 days in a directory, you can use the "find" command with the "-mtime" option. The command would be: ```bash find /path/to/directory -type f -mtime -30 ``` This will list all files modified within the last 30 days in the specified directory.

Explain the purpose of the 'grep' command in Linux.

The 'grep' command in Linux is used to search for specific patterns or text strings within files or output. It allows users to quickly find and display lines containing the desired text, making it a powerful tool for text processing and data extraction in the command line.

What is a symbolic link in Linux and how is it created?

A symbolic link, also known as a symlink, is a file that points to another file or directory. It acts as a shortcut to the target file/directory. In Linux, it is created using the `ln -s` command followed by the target file/directory and the name of the symbolic link.

How do you check the list of currently running processes on a Linux system?

To check the list of currently running processes on a Linux system, you can use the `ps` command. Simply type `ps` in the terminal to display a list of processes along with their associated information such as PID, TTY, %CPU, %MEM, and command.

What is the difference between a soft link and a hard link in Linux?

A soft link (symbolic link) is a pointer to the original file or directory, while a hard link is a second physical link to the same file or directory on the disk. Soft links can cross filesystem boundaries and can link to directories, while hard links can only link to files within the same filesystem.

How can you check the network connectivity on a Linux system?

You can check network connectivity on a Linux system by using the `ping` command to send a signal to a specific IP address or domain name. You can also use tools like `ifconfig` or `ip addr show` to view network interfaces and their configurations.

Explain the difference between 'rm' and 'rmdir' commands in Linux.

The 'rm' command in Linux is used to remove files or directories, while the 'rmdir' command is specifically used to remove empty directories. 'rm' can also be used with additional options to forcefully remove directories or directories with content, whereas 'rmdir' will only work on empty directories.

How do you set up a firewall using iptables in Linux?

To set up a firewall using iptables in Linux, you can use the following commands: 1. Define your rules using iptables commands 2. Save your rules using `iptables-save` command 3. Enable the firewall using `iptables-restore` command 4. Make sure to start iptables service to ensure persistence across reboots

Explain how to use 'awk' command in Linux for text processing.

The 'awk' command in Linux is used for text processing and manipulation. It allows you to search and extract specific patterns or fields from text files, perform calculations, and format output. You can use 'awk' by specifying patterns, actions, and input files in the command line.

What is RAID and how can it be implemented in a Linux system?

RAID (Redundant Array of Independent Disks) is a storage technology that combines multiple hard drives into one logical unit for improved performance, redundancy, and/or data protection. In a Linux system, RAID can be implemented using software RAID (mdadm) or hardware RAID controllers, depending on the system's requirements.

How do you troubleshoot performance issues on a Linux server?

To troubleshoot performance issues on a Linux server, you can start by checking system resources using tools like top, htop, or vmstat to identify any processes consuming high CPU or memory. Analyze logs for any errors or warnings, optimize disk usage, and consider tuning kernel parameters or adjusting settings for specific applications.

Explain the purpose of the 'systemd' service in Linux.

Systemd is a system and service manager for Linux that is responsible for initializing and managing system services, such as the startup and shutdown processes. It also handles logging, hardware and device management, and various other system tasks to ensure efficient and reliable operation of the system.

What is the Linux kernel?

The Linux kernel is the core component of the Linux operating system. It handles essential tasks such as managing hardware resources, running processes, and providing system services. It acts as the intermediary between software applications and the computer hardware, enabling the operating system to function properly.

The Linux kernel is the core component of the Linux operating system. It serves as the foundation upon which all other software and hardware interactions are built. The Linux kernel is responsible for managing system resources, such as memory, processors, devices, and providing essential functionalities like process scheduling, security, and file system management.

The Linux kernel is an open-source project, developed and maintained by a global community of developers. It is written primarily in the C programming language and is released under the terms of the GNU General Public License (GPL). This open nature allows users and developers to study, modify, and distribute the kernel freely.

Here is a simple code snippet demonstrating the basic structure of the Linux kernel:

    
#include 
#include 

static int __init hello_init(void) {
    printk(KERN_INFO "Hello, Linux Kernel!\n");
    return 0;
}

static void __exit hello_exit(void) {
    printk(KERN_INFO "Goodbye, Linux Kernel!\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
    

The Linux kernel is a crucial component of numerous devices and systems, powering everything from smartphones and desktop computers to servers and embedded devices. Its flexibility, scalability, and robustness make it a popular choice for various computing environments.