Interview-Questions-Img

Top 50+ Linux Interview Questions (Basic to Advanced)

As an open-source operating system, Linux powers an extensive array of devices, servers, and systems, playing an integral role in the backbone of modern computing. For aspiring tech enthusiasts and seasoned professionals alike, Linux proficiency has become a hallmark of expertise and a gateway to countless opportunities.

Whether you're gearing up for your first Linux job interview or aiming to solidify your existing knowledge, this comprehensive guide is your compass to success. We've curated the top Linux interview questions that recruiters frequently pose to evaluate candidates' understanding of this versatile operating system. 

But this guide is more than just a list of interview questions on Linux OS. Each question explores fundamental concepts, real-world scenarios, and best practices.

From command-line essentials and file system intricacies to networking configurations and security measures, we leave no stone unturned. Whether you're a system administrator, a developer, or a curious tech enthusiast, our goal is to empower you with the knowledge and confidence needed to tackle Linux interviews head-on.

So, let’s get started and learn the most asked Linux interview questions and answers. 

Advanced Linux Interview Questions

The Linux kernel is the elemental component of a Linux system. Written in C programming language, it is the lowest level of software interacting with the hardware. It also interfaces the OS and the underlying hardware allowing communication between the two.

The kernel performs the following tasks-

  • Manages underlying hardware devices.

  • Manages and launches applications.

  • Manages OS resources, including disk utilization, RAM, and CPU.

It is legal to edit Linux Kernel as Linux is released under the General Public License (GPL); the end users can edit and modify any project released under GPL.

GRUB is designed to be flexible and powerful, offering several key features:

  • Multiboot Functionality: 

GRUB supports multiple operating systems and kernel versions on a single system. This allows users to choose which OS or kernel to boot into during startup.

  • Filesystem Support: 

GRUB can read from a variety of filesystems, enabling it to access files necessary for booting, even from complex filesystem structures.

  • User Interface: 

GRUB provides a user-friendly interface that allows users to interact with the bootloader. This can include selecting different boot options, editing boot parameters, and accessing recovery tools.

  • Modularity: 

GRUB is modular in design, allowing it to load modules that provide additional functionality. This modularity makes it relatively easy to extend and customize GRUB's capabilities.

  • Configuration: 

GRUB's configuration file allows users to define boot options, kernel parameters, and other settings. This file can be edited to customize the boot process.

  • Advanced Features: 

GRUB supports advanced features like chain loading (booting other bootloaders), automatic detection of operating systems, and recovery modes.

  • UEFI and Legacy BIOS Support: 

GRUB is compatible with both modern UEFI (Unified Extensible Firmware Interface) systems and traditional BIOS systems, making it versatile across different hardware architectures.

  • Graphical Interface: 

Some versions of GRUB, like GRUB 2, offer graphical interfaces that make the boot selection process more visually appealing.

Key characteristics of a CLI include:

  • Text-Based: 

CLI operates entirely through text input and output. Users type commands and receive text-based responses from the computer.

  • Efficiency: 

CLI can be faster for experienced users who are comfortable with typing commands, as it often requires fewer keystrokes than navigating through graphical interfaces.

  • Scripting: 

CLI commands can be combined and saved as scripts or batch files to automate repetitive tasks or complex sequences of actions.

  • Resource Efficiency: 

CLI interfaces consume fewer system resources compared to graphical user interfaces (GUIs), making them useful for remote access or resource-constrained environments.

  • Precise Control: 

CLI allows users to perform specific tasks and access system functions with greater precision and control than GUIs.

  • Learning Curve: 

While CLI offers powerful capabilities, it typically has a steeper learning curve than GUIs, as users need to remember commands and their syntax.

  • Universal Nature: 

 

CLI is often consistent across different platforms and operating systems, allowing users familiar with CLI principles to work efficiently on various systems.

Here's how virtual desktops work:

  • Multiple Workspaces: 

Instead of having all your open applications and windows cluttered on a single desktop, you can create multiple virtual desktops. Each workspace can have its own set of applications and windows.

  • Switching Workspaces: 

You can switch between virtual desktops using keyboard shortcuts or graphical controls provided by the desktop environment. This allows you to quickly move between different sets of tasks without closing or minimizing windows.

  • Application Management: 

You can move applications and windows between virtual desktops, making it easier to group related tasks together. For example, you might have one workspace for work-related tasks and another for personal activities.

  • Enhanced Productivity: 

Virtual desktops help you keep a cleaner and more organized desktop environment, reducing visual clutter and improving focus. They allow you to separate different projects, applications, or types of tasks.

  • Customization: 

Some desktop environments provide options to customize the number of virtual desktops, their layout, and the behavior of switching between them.

There are several redirection operators in Linux:

  • Standard Output (stdout) Redirection (>):

The > operator redirects the standard output of a command to a file. If the file does not exist, it is created. If it does exist, its contents are overwritten.

command > output.txt

  • Append Output Redirection (>>):

The >> operator appends the standard output of a command to a file, instead of overwriting its contents.

command >> output.txt

  • Standard Error (stderr) Redirection (2>):

The 2> operator redirects the standard error output of a command to a file.

command 2> error.txt

  • Standard Output and Standard Error Redirection (&> or 2>&1):

The &> operator or 2>&1 combination redirects both the standard output and standard error of a command to the same file.

command &> output_and_error.txt

# or

command 2>&1 output_and_error.txt

  • Input Redirection (<):

The < operator redirects the standard input of a command from a file, rather than the keyboard.

command < input.txt

  • Here Document (<<):

The << operator allows you to input multiple lines of data directly into a command, often used with commands that require interactive input.

command << END

Line 1

Line 2

END

  • Here String (<<<):

The <<< operator sends a string as input to a command.

command <<< "Hello, world!"

These redirection operators are essential for efficiently working with input and output in the Linux command line. They enable tasks such as saving command output to files, redirecting error messages, and manipulating input sources.

Process management in Linux involves various system calls that allow programs to create, manage, and control processes. These system calls provide an interface for interacting with the operating system's process management features.

Some important process management system calls include:

  • fork():

The fork() system call is used to create a new process, known as the child process, which is a copy of the calling process (the parent process). The child process inherits the memory, open file descriptors, and other attributes of the parent process.

  • exec():

The exec() family of system calls (e.g., execl(), execv()) are used to replace the current process image with a new process image. This allows you to run a different program in the current process context.

  • waitpid():

The waitpid() system call is used by a parent process to wait for the termination of a specific child process. It can also be used to retrieve information about the exit status of the child process.

  • exit():

The exit() system call is used to terminate the calling process. It also sends an exit status to the parent process, indicating the reason for termination.

  • getpid():

The getpid() system call returns the process ID (PID) of the calling process. The PID is a unique identifier assigned to each process.

  • getppid():

The getppid() system call returns the parent process ID (PPID) of the calling process.

  • nice() and setpriority():

These system calls allow you to adjust the scheduling priority of a process. A higher priority value makes the process less likely to be scheduled, while a lower value increases its priority.

  • kill():

The kill() system call is used to send signals to processes. A signal is a notification that indicates a particular event or request to a process. For example, you can use kill() to terminate a process by sending it the SIGTERM signal.

  • signal():

The signal() system call is used to set up signal handlers for specific signals. Signal handlers are functions that are executed when a process receives a particular signal.

  • nice():

The nice() system call adjusts the scheduling priority of a process. Processes with higher niceness values have lower scheduling priority.

The tar command in Linux is used for archiving and creating compressed archive files. The term "tar" stands for "tape archive," and the command's primary purpose is to bundle multiple files and directories into a single file, often called a "tarball." 

Tarballs can also be compressed using various compression algorithms to reduce their size. The resulting compressed archive file is usually given a ".tar.gz" or ".tar.bz2" extension, depending on the compression method used.

To change the permissions of a file or directory in Linux, you can use the chmod command. 

The chmod command allows you to modify the read, write, and execute permissions for the owner, group, and others. 

Here's the basic syntax of the chmod command:

chmod [options] permissions file(s)/directory

In Linux, you can terminate a running process using various methods and commands. Here are some common ways to terminate processes:

  • Using the kill Command:

The kill command is used to send signals to processes. The most common signal used to terminate a process is SIGTERM (signal number 15), which asks the process to terminate gracefully. If the process does not respond to SIGTERM, you can use SIGKILL (signal number 9) to forcefully terminate it.

To terminate a process using the kill command, you'll need to know the process ID (PID) of the process. You can find the PID using the ps command or other process monitoring tools.

For example, to gracefully terminate a process with PID 12345:

kill -15 12345

To forcefully terminate the same process:

kill -9 12345

  • Using the pkill Command:

The pkill command allows you to send signals to processes based on their names or other attributes. For example, to terminate all processes named "myapp":

pkill myapp

  • Using the killall Command:

Similar to pkill, the killall command can be used to terminate processes based on their names.

killall myapp

  • Using Process Managers:

Some Linux distributions provide graphical process managers that allow you to view and terminate processes in a user-friendly interface. Examples include "System Monitor" in GNOME and "KSysGuard" in KDE.

  • Using Task Manager Shortcut:

On many Linux desktop environments, you can press Ctrl + Esc or Ctrl + Alt + Del to open the task manager, which allows you to select and terminate processes.

You can run multiple commands in a single command line by separating them with special characters or operators. 

Here are some common ways to execute multiple commands:

  • Using Semicolons (;):

You can use semicolons to separate commands. Each command is executed sequentially, regardless of the success or failure of the previous command.

command1 ; command2 ; command3

  • Using Double Ampersands (&&):

Double ampersands are used to run commands sequentially, but the subsequent commands are executed only if the preceding command succeeds (returns an exit status of 0).

command1 && command2 && command3

  • Using Double Vertical Bars (||):

Double vertical bars are used to run commands sequentially, but the subsequent commands are executed only if the preceding command fails (returns a non-zero exit status).

command1 || command2 || command3

  • Using Parentheses and Semicolons:

You can group commands using parentheses and semicolons to ensure that multiple commands are executed together.

(command1 ; command2) ; command3

  • Using Line Continuation (\):

If a command is long and spans multiple lines, you can use the backslash \ character to continue the command on the next line.

command1 \

&& command2 \

&& command3

  • Using Command Substitution:

You can use command substitution with backticks (``) or the $() syntax to run a command and use its output as part of another command.

echo "Today is $(date)"

To check how long the Linux system has been running, you can use the uptime command. 

The uptime command displays information about the system's current time, how long it has been running, the number of users logged in, and the system's load averages.

Simply run the following command in the terminal:

uptime

The output will look something like this:

 09:12:45 up  1:23,  2 users,  load average: 0.15, 0.22, 0.18

In this example, the system has been running for 1 hour and 23 minutes (1:23), and there are currently 2 users logged in. The load averages indicate the system's workload over the past 1, 5, and 15 minutes, respectively.

In Linux, network bonding is a technique that allows you to combine multiple network interfaces (NICs) into a single virtual interface, providing higher throughput, fault tolerance, and load balancing. 

There are several modes of network bonding available:

  • Mode 0 - Round Robin (balance-rr):

In this mode, network traffic is distributed sequentially across all available interfaces. It provides load balancing but does not consider interface speeds or utilization.

  • Mode 1 - Active-Backup (active-backup):

In Active-Backup mode, one interface (the active one) is used for traffic while the others are in standby mode. If the active interface fails, the backup interface takes over.

  • Mode 2 - XOR (balance-xor):

XOR mode combines MAC addresses and IP addresses to determine how traffic is distributed across interfaces. It provides better load balancing but requires compatible switches.

  • Mode 3 - Broadcast (broadcast):

In Broadcast mode, all traffic is sent through all interfaces. This mode is mainly used for testing and not recommended for production environments.

  • Mode 4 - IEEE 802.3ad (802.3ad or balance-tlb):

Also known as Dynamic Link Aggregation or LACP (Link Aggregation Control Protocol), this mode uses Link Aggregation Groups (LAGs) to aggregate links. It requires switch support and provides both load balancing and fault tolerance.

  • Mode 5 - Adaptive Load Balancing (balance-alb):

This mode balances traffic by adjusting the routing of outgoing packets based on the current load and link status. Incoming traffic is received on the active interface.

In Linux, hidden files are files whose names start with a dot (.). These files are hidden from normal directory listings and are typically used to store configuration data, settings, or other information that is not meant to be directly accessed or modified by users. 

Hidden files are primarily used to keep the user interface uncluttered and to separate important system files from user-specific files.

Linux is often regarded as a more secure operating system compared to other operating systems due to several key factors:

  • Open Source Nature:

The open-source nature of Linux allows security experts and the community to review the source code and identify security vulnerabilities. This transparency enables prompt detection and resolution of security issues.

  • Quick Security Updates:

Linux distributions usually offer rapid security updates. When vulnerabilities are discovered, patches and updates are released quickly, reducing the exposure time to potential threats.

  • Privilege Separation:

Linux follows the principle of least privilege, which means processes and users have only the necessary permissions to perform their tasks. This limits the potential impact of security breaches.

  • Strong User and Group Management:

Linux's user and group management system enables precise control over who can access and modify files and processes. This helps prevent unauthorized access and reduces the risk of data breaches.

  • Secure Software Repositories:

Linux distributions use centralized repositories to distribute software. This reduces the likelihood of downloading software from untrusted sources, minimizing the risk of malware infection.

  • Mandatory Access Control:

Some Linux distributions (e.g., SELinux, AppArmor) offer mandatory access control mechanisms that enhance security by specifying rules for processes' interactions with resources. This helps prevent unauthorized actions.

  • Limited Kernel Access:

In Linux, the kernel handles core functions and is protected from direct user access. This separation mitigates the risk of unauthorized changes to critical system components.

  • Customizable Security Policies:

Linux's modular design allows administrators to tailor security settings to their specific needs. This flexibility ensures that security measures align with the organization's requirements.

  • Network Security Tools:

Linux offers a range of network security tools and utilities, making it easier to secure network connections, monitor traffic, and protect against cyber threats.

  • Strong Community and Support:

The Linux community actively contributes to security by developing tools, sharing knowledge, and participating in security-related discussions. This collective effort leads to a more secure environment.

  • Consistent Auditing and Logging:

Linux provides robust auditing and logging capabilities, enabling administrators to track system activity and identify potential security breaches.

  • Built-in Encryption Support:

Many Linux distributions provide built-in support for encryption, ensuring data privacy and protection against unauthorized access.

Basic Linux Interview Questions

Linux is an open-source, Unix-like operating system kernel that serves as the foundation for a wide range of operating systems, often referred to as "Linux distributions" or "distros." 

Developed by Linus Torvalds in 1991, Linux has grown into a powerful and versatile platform used in various computing environments, from personal computers and servers to embedded systems and mobile devices.

At its core, the Linux kernel manages hardware resources, offers core services, and provides a framework for applications to interact with the underlying hardware. It is known for its stability, security, and customization options. 

One of the most notable features of Linux is its open-source nature, which means that its source code is freely available to the public, allowing developers to modify, enhance, and distribute it under open-source licenses.

Linux distributions combine the Linux kernel with software components from various sources to create complete operating systems. Popular Linux distributions include Ubuntu, CentOS, Debian, Fedora, and more. These distributions often come with package managers that simplify the process of installing, updating, and managing software on the system.

Linux has gained widespread adoption due to its flexibility, scalability, and cost-effectiveness. It's used in a wide range of applications, from powering web servers and cloud infrastructure to running mobile devices and Internet of Things (IoT) devices. 

Its strong command-line interface, vast software ecosystem, and community support make it a popular choice among developers, administrators, and technology enthusiasts.

In the context of Linux and software in general, "open source" means a type of software license that grants users the rights to view, modify, and distribute the source code of a program. 

Open source software is typically developed collaboratively, with the source code made available to the public, allowing anyone to contribute improvements, fixes, or modifications to the software.

In the case of Linux, being an open-source operating system means that its source code is freely accessible to the public. 

One of the most well-known licenses for open-source software is the GNU General Public License (GPL), which is used by the Linux kernel and many other open-source projects. The GPL ensures that derivative works of the software also remain open source

Linux, as an open-source Unix-like operating system, boasts a wide range of features that contribute to its popularity, versatility, and robustness. Here are some key features of Linux:

  • Open Source:

Linux's source code is freely available, allowing users to view, modify, and distribute it. This fosters collaboration, rapid development, and a strong sense of community.

  • Multiuser and Multitasking:

Linux supports multiple users concurrently and allows for multitasking, enabling several processes to run simultaneously without interfering with each other.

  • Stability and Reliability:

Linux is known for its stability, with many systems running for extended periods without requiring reboots. This is especially important for servers and critical applications.

  • Security:

Linux's robust permission and security model ensures that users and processes have limited access to resources. Regular updates and quick response to vulnerabilities contribute to its strong security profile.

  • Compatibility and Portability:

Linux supports a wide range of hardware architectures, making it highly portable. This compatibility allows it to run on diverse devices, from embedded systems to supercomputers.

  • Package Management:

Linux distributions offer package management systems (e.g., APT, YUM, Pacman) that simplify software installation, updates, and dependency resolution.

  • Customization:

Linux allows users to customize various aspects of the operating system, from the graphical environment to system behavior, tailoring it to their preferences.

  • Command Line Interface (CLI):

Linux offers a powerful and versatile command-line interface, enabling users to perform tasks efficiently, automate processes, and manage systems remotely.

  • Graphical User Interfaces (GUI):

Linux desktop environments (e.g., GNOME, KDE, XFCE) provide user-friendly graphical interfaces, making it accessible to users of varying technical backgrounds.

  • Networking Capabilities:

Linux's networking capabilities support a wide range of protocols and services, making it an excellent choice for servers and networking equipment.

  • Device Support:

Linux supports a plethora of devices, thanks to a robust device driver framework. This support ranges from common peripherals to specialized hardware.

  • Virtualization and Containerization:

Linux is widely used in virtualization and containerization technologies (e.g., KVM, Docker), allowing efficient utilization of resources and isolation of applications.

  • Scalability:

Linux can scale from small embedded systems to large clusters of servers, providing the flexibility to handle various workloads.

  • Community and Documentation:

The Linux community is vast and active, providing comprehensive documentation, tutorials, and forums to support users at all skill levels.

  • Enterprise Adoption:

Many enterprises use Linux due to its reliability, security, and cost-effectiveness. Major organizations rely on Linux for their critical systems and applications.

Here are the primary differences between Windows and Linux operating system:

 

Aspect

Linux

Windows

Licensing

Generally open-source with various licenses

Proprietary commercial licensing

Kernel

Monolithic kernel architecture

Hybrid kernel architecture

User Interface

Diverse desktop environments available

Primarily Windows Desktop

Software

Vast range of open-source and free software

Proprietary software, some open-source

Customization

Highly customizable and modifiable

Limited customization

Security

Generally more secure due to user privileges

Frequent target of malware and attacks

Stability

Known for stability, especially in servers

Subject to occasional crashes

Hardware Support

Good support, but drivers may vary

Extensive hardware compatibility

Command Line

Powerful terminal with many commands

Command Prompt and PowerShell

File System

Extensive choice, like ext4, Btrfs, etc.

Primarily NTFS, FAT32

Updates

Centralized package management system

Windows Update for patches and upgrades

Cost

Often free or low cost for distributions

Commercial licenses, varying costs

Enterprise Usage

Widely used in servers and data centers

Commonly used in office environments

Community Support

Strong open-source community support

Official support from Microsoft

 

The difference between Linux and Unix is tabulated below-

Linux

Unix

Available in both paid and free distributions.

Different paid structures for various Unix levels.

Uses GUI with an optional command-line interface.

Unix uses the command-line interface.

Linux is portable and executed on multiple hard drives.

Unix OS is not portable.

A worldwide Linux community develops Linux.

AT&T developers develop Unix.

Linux is free and downloaded through the internet under GNU licenses.

Most Unix OS is not free.

Linux is used on home-based PCs, phones, etc.

Unix is used in server systems.

The following are the essential components of Linux-

  • Shell: It is a Linux interpreter for executing commands.

  • Kernel: Kernel is the core part of the operating system to manage hardware and operations.

  • System Utilities: These are the software functions that help users to manage their computers.

  • GUI: GUI denotes Graphical User Interface through which users can interact with the system. But unline CLI, GUI comprises buttons, images, and TextBoxes for interaction.

  • Application Programs: Software programs are designed to complete a particular task.

LILO, short for "LInux LOader," is a bootloader program used in some Linux distributions to manage the process of booting the operating system. The bootloader is a small software program that resides in the Master Boot Record (MBR) of a computer's hard drive or other storage devices. Its primary function is to load the operating system into memory and start its execution.

LILO in Linux was one of the early bootloader programs used in Linux systems. It allowed users to choose from multiple operating systems or kernel versions during the boot process. LILO was relatively simple to configure but had some limitations, such as a lack of support for some modern filesystems and a limited user interface.

However, LILO has largely been replaced by newer bootloader programs like GRUB (GRand Unified Bootloader), which offers more advanced features and greater flexibility. GRUB supports a wider range of filesystems, has a more user-friendly interface, and can load the kernel and initial RAM disk from separate filesystems. Additionally, GRUB supports both legacy BIOS and newer UEFI systems.

GRUB, which stands for "GRand Unified Bootloader," is a widely used bootloader program in the Linux and Unix-like operating systems. It plays a crucial role in the boot process, facilitating the loading of the operating system kernel and necessary files into memory, enabling the computer to start up and run.

CLI stands for "Command Line Interface." It is a method of interacting with a computer or operating system by typing text-based commands into a terminal or command prompt. 

In a CLI, users enter specific commands, often accompanied by arguments and options, to perform various tasks, execute programs, manage files, configure settings, and more.

Examples of CLI environments include the Command Prompt on Windows, Terminal on macOS and Linux, and shells like Bash, Zsh, and PowerShell. Users type commands such as "ls" to list files, "cd" to change directories, "mkdir" to create directories, and "rm" to remove files.

The following are the most common type of Shells used in Linux-

  • fish: Friendly Interactive Shell offers unique features such as web-based configuration, fully scriptable, and auto suggestions with clean scripts.

  • bash: Bourne Again, Shell is the default for most Linux distributions.

  • zsh: Z Shell offers unique features like startup files, filename generation, log-in or logout watching, and closing comments.

  • csh: C Shell follows C-like syntax with a spelling correction and Job Control features.

Swap space extends the RAM or physical memory on the hard drive. The system uses it when the RAM capacity is almost depleted and can no longer support running applications. Swap space stores additional programs that the RAM can no longer process.

Here's a comparison between BASH (Bourne-Again SHell) and DOS (Disk Operating System):

Aspect

BASH (Bourne-Again SHell)

DOS (Disk Operating System)

Origin

Derived from the original Bourne Shell

Developed by Microsoft

Platform

Mainly used in Unix-like systems (Linux)

Primarily used in early Windows systems

Command Syntax

Follows Unix-like command syntax

Follows a different command syntax

Commands

Offers a wide range of powerful commands

Has a more limited set of commands

Scripting

Highly suitable for scripting and automation

Limited scripting capabilities

File Paths

Uses forward slashes in file paths (/)

Uses backslashes in file paths ()

Environment

Part of the Unix-like environment

Typically runs in a single-user environment

Wildcards

Supports powerful wildcards (e.g., *)

Supports simpler wildcards (e.g., *)

Variables

Utilizes variables with $ prefix

Uses variables with % prefix

Functions

Supports functions and command pipelines

Limited support for batch file functions

Redirects

Offers various input/output redirections

Supports basic input/output redirection

Pipelines

Enables complex command pipelines

Limited support for simple pipelines

File Permissions

Follows Unix-like file permission system

Has a simpler file permission system

Script Extension

Usually has .sh extension for scripts

Uses .bat or .cmd extension for scripts

Multitasking

Supports multitasking and background tasks

Limited multitasking capabilities

Aliases

Supports creating command aliases

Does not natively support command aliases

Case Sensitivity

Case-sensitive in command and file names

Case-insensitive in command and file names

User Community

Larger community in Unix-like environments

Historically used by early Windows users

 

GUI stands for "Graphical User Interface." It refers to the visual interface that allows users to interact with a computer or software using graphical elements such as icons, windows, menus, buttons, and dialog boxes, as opposed to a text-based interface like a command-line interface (CLI).

In the context of Linux, a GUI provides a user-friendly and visually intuitive way to interact with the operating system and its applications. GUIs are designed to simplify complex tasks and make computing more accessible to a wider audience, including users who might not be familiar with command-line operations.

Linux distributions typically come with a default desktop environment, which is a specific GUI implementation that includes a set of tools, utilities, and visual elements. 

Some popular desktop environments for Linux include:

  • GNOME: 

Known for its modern and streamlined design, GNOME offers a clean interface and focuses on simplicity and user experience.

  • KDE Plasma: 

KDE Plasma provides a rich and customizable interface with various features and visual effects. It offers a balance between aesthetics and functionality.

  • Xfce

Xfce is known for being lightweight and efficient while still providing a user-friendly experience. It's a great choice for older hardware or systems with limited resources.

  • Cinnamon:

Built on top of the GNOME desktop environment, Cinnamon aims to provide a traditional and familiar user interface reminiscent of older desktop environments.

  • MATE: 

Also based on the GNOME 2 desktop environment, MATE offers a classic and straightforward interface that appeals to users who prefer the look and feel of older operating systems.

There are three main types of permissions in Linux: read (r), write (w), and execute (x). 

These permissions can be assigned to three distinct groups: the owner of the file, the group associated with the file, and others (everyone else). 

Each permission type has a specific purpose:

i) Read (r):

  • Files: Allows a user to view the contents of a file.

  • Directories: Allows a user to list the contents of a directory.

ii) Write (w):

  • Files: Allows a user to modify the contents of a file, including appending data or deleting content.

  • Directories: Allows a user to create, delete, or rename files and directories within the directory.

iii) Execute (x):

  • Files: Allows a user to execute a file if it is a script or executable binary.

  • Directories: Allows a user to access the contents of a directory. Without execute permission on a directory, a user cannot access files within it even if they have read permission for the files.

An inode, short for "index node," is a fundamental data structure in a Unix-like file system. It contains metadata about a file, such as its permissions, ownership, timestamps, file size, and pointers to the actual data blocks on the disk. Inodes play a crucial role in organizing and managing files within the file system.

When a file is created, the operating system allocates an inode to store its metadata. This inode contains all the necessary information about the file except for its actual content, which is stored in data blocks linked to the inode.

Inodes are essential for efficient file system operations. They allow the system to quickly locate and access files, determine their characteristics, and manage disk space allocation. Each file on the file system corresponds to a unique inode, even if the file has the same name as another in a different directory.

A Process ID (PID) is a unique numerical identifier assigned to each running process in an operating system. A process is an executing instance of a program, representing the basic unit of execution. Each time a program is executed, it creates a process, and that process is assigned a unique PID for identification.

Process IDs are used by the operating system to manage and control processes. They help the OS keep track of various attributes of each process, such as its memory usage, execution state, and resource allocation. Processes with different PIDs can run concurrently and independently of each other.

The PID space is finite, meaning that PIDs are eventually recycled as processes terminate. When a process exits, its PID becomes available for reuse by new processes.

In Linux, processes go through various states as they execute and interact with the system. These process states indicate what the process is currently doing and whether it's actively executing or waiting for a particular event. 

The process states are as follows:

  • Running: 

The process is currently being executed by one of the CPU cores. It's actively using the CPU resources to perform its tasks.

  • Waiting (Interruptible): 

The process is waiting for an event to occur, such as input from a user or data from an I/O operation. It's in a state where it can be interrupted and resumed when the event occurs.

  • Waiting (Uninterruptible): 

Similar to interruptible waiting, the process is waiting for an event, but it cannot be interrupted or terminated. This often happens when the process is waiting for I/O and the operation is expected to complete.

  • Stopped: 

The process has been stopped, usually by a user or another process, using a signal. It's not currently executing and can be resumed or terminated by the user.

  • Zombie: 

Also known as a "defunct" process, a zombie process is a terminated process that still has an entry in the process table. It remains in this state until its parent process acknowledges its termination. Zombies do not consume system resources, but they indicate a potential issue with process management.

  • Dead:

This is not an official process state, but it refers to a process that has completed its execution and is no longer active.

Linux provides several commands for working with directories (also known as folders) in the command-line interface. These commands help you navigate, create, manage, and manipulate directories on the filesystem. 

Here are some of the commonly used Linux directory commands:

  • pwd (Print Working Directory):

Displays the current working directory's full path.

pwd

  • ls (List):

Lists the files and directories in the current directory.

ls

Common flags:

-l: Long format, displays detailed information.

-a: Displays hidden files (those starting with a dot).

-h: Human-readable file sizes.

  • cd (Change Directory):

Changes the current working directory to the specified directory.

cd /path/to/directory

Special symbols:

..: Represents the parent directory.

.: Represents the current directory.

  • mkdir (Make Directory):

Creates a new directory with the specified name.

mkdir new_directory

Flags:

-p: Creates parent directories if they don't exist.

  • rmdir (Remove Directory):

Removes an empty directory.

rmdir directory_name

  • rm (Remove):

Deletes files or directories.

rm file_name

rm -r directory_name

Flags:

-r or -R: Recursively removes directories and their contents.

-f: Forces removal without confirmation.

  • cp (Copy):

Copies files or directories to a new location.

cp file_name destination_directory

cp -r directory_name destination_directory

  • mv (Move):

Moves files or directories to a new location or renames them.

mv old_name new_name

mv file_name destination_directory

  • ln (Link):

Creates hard or symbolic links to files.

ln source_file link_name

ln -s source_file symbolic_link_name

  • tree:

Displays the directory structure as a tree.

tree

Install it if needed:

sudo apt-get install tree  # For Debian/Ubuntu

sudo yum install tree      # For CentOS

  • du (Disk Usage):

Displays the disk usage of files and directories.

du -h directory_name

In Linux, the root account is a special user account that has administrative privileges and is also referred to as the "superuser" or "administrator" account. The root account is the most powerful account on a Linux system and has unrestricted access to all files, directories, and system resources. 

It can perform actions that regular users are not allowed to do, such as modifying system files, installing software, and changing system configurations.

In Linux, a virtual desktop, also known as a workspace, is a feature of the graphical user interface (GUI) that allows users to have multiple desktop environments within a single physical screen. 

Each virtual desktop is like a separate workspace that can contain its own set of open applications and windows. This feature helps users manage their workflow more efficiently by organizing tasks and applications into different workspaces.

In Linux, the redirection operator is used to control where the input and output of commands and programs are directed. It allows you to manipulate the flow of data between processes, files, and devices. 

Redirection is a powerful feature that enables you to capture, redirect, and combine input and output streams in various ways.

Environmental variables are dynamic values affecting the process of programs on a system. They exist in every operating system, and their types vary. Further, they can be created, edited, saved, and deleted, giving information about the system's behavior.

The vi text editor, commonly found on Unix-like operating systems including Linux, has different modes that determine how you interact with the editor and manipulate text. 

The three primary modes of the vi editor are:

i) Normal Mode (Command Mode):

This is the default mode when you open a file in vi. In Normal mode, you can navigate through the text, perform editing tasks, and execute various commands. You cannot directly type or insert text in this mode. 

Some commonly used commands in Normal mode include:

  • i: Switch to Insert mode before the cursor.

  • a: Switch to Insert mode after the cursor.

  • o: Open a new line below the current line and switch to Insert mode.

  • x: Delete the character under the cursor.

  • dd: Delete the entire line.

  • yy: Yank (copy) the entire line.

  • p: Paste the yanked or deleted text.

ii) Insert Mode:

In Insert mode, you can directly type and insert text into the file. 

To enter Insert mode:

  • Press i to start inserting text before the cursor.

  • Press a to start inserting text after the cursor.

  • Press I to start inserting text at the beginning of the current line.

  • Press A to start inserting text at the end of the current line.

  • Press o to open a new line below the current line and start inserting text.

  • Press O to open a new line above the current line and start inserting text.

iii) Visual Mode:

Visual mode allows you to select and manipulate blocks of text visually. You can enter Visual mode by pressing v in Normal mode. Once in Visual mode, you can use movement commands to select the desired text. After selecting the text, you can perform actions like copying, cutting, or replacing the selected text.

Vim, an improved version of the vi text editor, provides several modes that determine how you interact with the editor and manipulate text. These modes help you navigate, edit, and perform various tasks efficiently. 

The main modes in Vim are:

i) Normal Mode:

Similar to vi, Vim starts in Normal mode by default. In this mode, you can navigate, execute commands, and manipulate text without directly entering new content. Some commonly used commands in Normal mode include navigation, searching, and text manipulation.

ii) Insert Mode:

In Insert mode, you can directly type and insert text into the file. 

To enter Insert mode:

  • Press i to start inserting text before the cursor.

  • Press I to start inserting text at the beginning of the current line.

  • Press a to start inserting text after the cursor.

  • Press A to start inserting text at the end of the current line.

  • Press o to open a new line below the current line and start inserting text.

  • Press O to open a new line above the current line and start inserting text.

iii) Visual Mode:

Visual mode allows you to select blocks of text visually for copying, cutting, or other operations. Press v in Normal mode to enter Visual mode. Then use movement commands to select text. After selecting text, you can apply commands to the selected region.

iv) Command-Line Mode:

Command-Line mode is used for entering and executing various commands. To enter Command-Line mode, press : in Normal mode. This mode allows you to perform tasks like saving, quitting, searching, and executing Vim commands.

v) Replace Mode:

Replace mode is similar to Insert mode, but it replaces existing characters rather than inserting new ones. To enter Replace mode, press R in Normal mode. You can start replacing characters from the cursor position.

vi) Visual Block Mode:

Visual Block mode is an extension of Visual mode that allows you to select text in a block shape. Press Ctrl + V in Normal mode to enter Visual Block mode. You can then select a block of text and perform operations on the selected block.

A symbolic link, often referred to as a symlink or soft link, is a special type of file in Unix-like operating systems (including Linux) that acts as a reference or pointer to another file or directory. Symbolic links provide a way to create a shortcut or alias to another location in the filesystem, allowing you to access files or directories from different paths.

A hard link is a shortcut linking a file's contents. The size is the same as the original file and shares the same inode id as the original file.

When the original file is updated, the contents of the rigid link also get updated. Additionally, the hard link remains unaffected even if the original file is removed.

The drawback of a hard link is it cannot be created across different file systems.

A daemon is a computer application that runs in the background to perform functions that aren't available in the standard Operating System. 

Daemons are typically employed to operate services in the background while avoiding direct user interaction. Daemons are responsible for handling periodic requests and forwarding them to the proper programs for execution.

An alias in Linux is a custom shortcut or abbreviation that you can create to simplify or modify the usage of command-line commands. Aliases allow you to define shorter versions of commands, apply default options, or create new behaviors for commonly used commands. 

They are particularly useful for reducing typing and making complex or frequently used commands more manageable.

Here's how aliases work:

  • Defining Aliases:

You can define aliases using the alias command in the terminal. The basic syntax is as follows:

alias alias_name='command_to_replace_original'

For example, to create an alias that substitutes ls with ls -l:

alias ll='ls -l'

  • Temporary and Permanent Aliases:

Aliases created using the alias command are temporary and valid only for the current session. To make an alias permanent, add it to your shell's configuration file (e.g., ~/.bashrc for Bash) so that it's loaded every time you open a new terminal session.

  • Removing Aliases:

You can remove an alias using the unalias command:

unalias alias_name

For example:

unalias ll

  • Using Variables in Aliases:

You can use variables within aliases to make them more versatile. For example:

alias grep='grep --color=auto'

This alias adds color highlighting to grep output.

  • Quoting and Escaping:

When defining aliases, ensure you use single quotes (') to prevent unwanted expansion of variables or commands.

You can list all processes that are running on Linux using various commands. Here are some commonly used methods:

  • ps Command:

The ps command is used to display information about running processes. The basic usage to list all processes is:

ps aux

This command provides a detailed list of all processes in a tabular format. You can use different options to customize the output. For example, ps aux shows processes for all users, while ps -ef is another commonly used option.

  • top Command:

The top command provides real-time information about system processes, including resource usage, memory consumption, and CPU utilization. Run the following command:

top

Press q to exit top.

  • htop Command:

htop is an interactive process viewer that provides a more user-friendly interface compared to top. Install it if not already available and run:

htop

Use arrow keys and function keys for navigation and interaction.

  • pgrep and pkill Commands:

The pgrep command can be used to list processes based on various criteria, such as process name or user. For example, to list all processes for a specific user:

pgrep -u username

The grep command is a powerful text-searching utility available in Unix-like operating systems, including Linux. It is used to search for specific patterns or strings within files or text streams. 

The name "grep" stands for "Global Regular Expression Print," indicating its primary function of finding and printing lines that match a specified pattern.

Here's the basic syntax of the grep command:

grep [options] pattern [file...]

  • pattern: The regular expression or plain text pattern you want to search for.

  • file: The file or files in which you want to search. If omitted, grep reads from standard input.

To identify which shell you are currently using in a Linux or Unix-like system, you can use the echo command with the $SHELL environment variable. Here's how you can do it:

Open a terminal and enter the following command:

echo $SHELL

After executing this command, you'll see the path to the shell you're currently using. It might look something like:

/bin/bash

In this example, the shell being used is Bash. The path to the shell executable will vary depending on the shell you're using. 

Here are some common shell paths:

  • Bash: /bin/bash

  • Zsh: /usr/bin/zsh

  • Fish: /usr/bin/fish

  • Dash: /bin/dash

  • Sh (Bourne Shell): /bin/sh

The output will help you identify the shell you are currently working in.

To sort the entries in a text file in ascending order, you can use the sort command in Linux. The sort command reads lines from a text file and outputs them in sorted order. 

Here's how you can use the sort command to sort entries in ascending order:

sort input.txt

Replace input.txt with the name of the text file you want to sort. By default, the sort command sorts the lines in ascending alphabetical order based on the contents of each line.

If you want to save the sorted output to a new file, you can use output redirection:

sort input.txt > sorted_output.txt

This will create a file named sorted_output.txt containing the sorted lines from input.txt.

In Linux, there are two primary user modes: User Mode and Kernel Mode. These modes determine the level of access and privileges that processes and users have while interacting with the system.

  • User Mode (User Space):

User Mode is the standard mode in which user-level processes run. In this mode, processes have limited access to system resources and hardware. User Mode processes are isolated from one another and the kernel, ensuring stability and security.

User Mode processes cannot directly access hardware devices or execute privileged instructions. Instead, they interact with the kernel through system calls, which provide controlled access to kernel-level functionality. Most applications and user activities occur in User Mode.

  • Kernel Mode (Kernel Space):

Kernel Mode, also known as Supervisor Mode or Privileged Mode, is where the operating system's kernel operates. In this mode, the kernel has unrestricted access to the system's hardware, memory, and resources.

Kernel Mode is used to execute critical system tasks, manage hardware devices, and maintain system integrity. Device drivers and kernel modules run in this mode to interact directly with hardware components.