Google News
logo
Linux Interview Questions
Linux is an open-source operating system kernel that serves as the foundation for a wide range of Unix-like operating systems. It was initially developed by Linus Torvalds in 1991 as a hobby project, and it has since grown into one of the most popular and widely used operating systems worldwide. Additionally, it can be installed in notebooks, computers, laptops, mobiles, etc. Linux operating system flavors include Gentoo, SUSE Linux, Debian, Ubuntu, etc.

Here are some key points about Linux :

Open Source : Linux is distributed under an open-source license, which means that its source code is freely available to the public. This allows developers to study, modify, and distribute the code according to their needs.

Kernel : Linux is primarily known for its kernel, which is the core component of the operating system responsible for managing hardware resources, providing essential services, and facilitating communication between software and hardware components.

Unix-Like : Linux is Unix-like, which means that it follows many of the design principles and conventions established by the Unix operating system. However, Linux is not Unix itself; it is a separate and independent implementation inspired by Unix.
Modularity : Linux is highly modular, allowing users to customize and configure various components of the operating system according to their requirements. This modularity enables Linux to be used in a wide range of computing environments, from embedded systems to servers and desktops.

Distributions : Linux is distributed in the form of distributions (distros), which are complete operating system packages that include the Linux kernel along with a collection of software applications, libraries, and utilities. There are hundreds of Linux distributions available, each tailored to specific use cases and preferences.

Versatility : Linux is highly versatile and supports a diverse range of hardware architectures, including x86, ARM, and MIPS. It is used in a variety of computing devices, from smartphones and tablets to servers, supercomputers, and embedded systems.

Community : Linux has a vibrant and active community of developers, contributors, and users who collaborate to improve and enhance the operating system. The Linux community plays a crucial role in the development, support, and advocacy of Linux-based technologies.
On August 25, 1991, a Finnish computer science student named Linus Torvalds first released it. In fact, Linux is the result of the combined efforts of a large number of programmers from all over the world. Linux’s origins lie in the open-source and free software movements of the early 1990s.

Origins of Unix : The story of Linux starts with the development of the Unix operating system in the late 1960s and early 1970s at AT&T’s Bell Labs. Unix became widely popular in the academic and research communities due to its flexibility and portability.

GNU Project : In the early 1980s, Richard Stallman founded the Free Software Foundation (FSF) and initiated the GNU Project. The goal of the GNU Project was to create a free and open-source Unix-like operating system based on the Unix design principles. However, by the early 1990s, the GNU Project had made substantial progress in developing various components of the operating system, except for the kernel.

Linus Torvalds and Linux Kernel : In 1991, a Finnish computer science student named Linus Torvalds started working on his own operating system kernel as a hobby project. He aimed to create a Unix-like kernel that would run on the Intel 80386 processor in his personal computer. Linus released the first version of his kernel, called Linux, on August 25, 1991, and made the source code freely available under the GNU General Public License (GPL).

GNU/Linux Collaboration : Linus’s Linux kernel filled the gap in the GNU Project’s operating system, and soon the Linux kernel was combined with the GNU software to create a complete and functional operating system. This combination of the GNU software and the Linux kernel gave rise to what is commonly known as “GNU/Linux” or simply “Linux.” The name “Linux” is often used to refer to the entire operating system, although the kernel itself is technically just one component.

Rise of Open Source Movement : The open-source nature of Linux encouraged a global community of developers to contribute to its development. This collaboration led to rapid improvements and widespread adoption of Linux.

Commercial Success and Distributions : Throughout the 1990s and early 2000s, Linux gained popularity and became a viable option for servers and workstations. Many companies started providing commercial support for Linux, and various distributions (or distros) of Linux emerged, catering to different user needs. Some popular Linux distributions include Ubuntu, Fedora, Debian, CentOS, and Red Hat Enterprise Linux.

Linux Today : As of my last update in September 2021, Linux has become one of the most widely used operating systems in the world. It powers a vast array of devices, from servers, supercomputers, and smartphones to embedded systems and Internet of Things (IoT) devices. Linux’s open-source nature, stability, security, and versatility have contributed to its success and continued development by the global open-source community.

The success of Linux demonstrates the power of collaboration and the impact of the open-source philosophy on the world of technology. It serves as a prominent example of how a freely shared and community-driven project can become a fundamental part of modern computing.
The Linux kernel is the core component of the Linux operating system responsible for managing hardware resources, providing essential services, and facilitating communication between software and hardware components. It serves as the bridge between the hardware and the higher-level software layers, enabling applications to interact with the underlying hardware efficiently.

Here are some key characteristics and functions of the Linux kernel:

Hardware Abstraction : The kernel abstracts hardware complexities by providing a uniform interface for accessing hardware resources such as CPU, memory, storage devices, network interfaces, and input/output devices. This abstraction allows applications to be hardware-independent and simplifies the development of device drivers.

Process Management : The kernel manages processes, which are instances of running programs, by allocating CPU time, scheduling tasks, and providing mechanisms for inter-process communication and synchronization. It ensures fair and efficient utilization of system resources among competing processes.

Memory Management : The kernel is responsible for managing system memory, including allocating memory to processes, maintaining memory mappings, handling virtual memory, and implementing memory protection mechanisms such as paging and segmentation.

File System Support : The kernel provides support for various file systems, allowing applications to read from and write to storage devices in a standardized manner. It implements file system drivers and provides file system-related services such as file I/O operations, directory management, and file permission handling.

Device Drivers : The kernel includes device drivers that interface with hardware components, such as disk drives, network adapters, USB devices, and input/output devices (e.g., keyboards, mice). These drivers enable communication between the kernel and hardware devices, allowing applications to access and control hardware resources.

Networking : The kernel includes networking subsystems that enable networking functionality, such as network protocols, socket management, packet routing, and network device drivers. It provides support for various networking protocols, including TCP/IP, UDP, ICMP, and others.

Security : The kernel implements security features and mechanisms to protect system integrity and prevent unauthorized access. It enforces access control policies, implements user authentication and authorization, and provides facilities for process isolation, privilege separation, and auditing.

System Calls : The kernel exposes system calls, which are interface functions that allow user-space programs to interact with kernel services. System calls provide a standardized way for applications to perform tasks that require privileged access or access to system resources not directly accessible from user space.
Linux is a powerful and versatile operating system known for its stability, security, and flexibility. It offers a wide range of features that make it suitable for various computing environments, from personal computers to servers and embedded devices. Here are some basic features of the Linux operating system:

Open Source : Linux is distributed under open-source licenses such as the GNU General Public License (GPL), which allows users to access, modify, and distribute the source code freely. This fosters collaboration, innovation, and community-driven development.

Multiuser : Linux supports multiple users simultaneously, allowing multiple users to log in and use the system concurrently. Each user has their own account, files, and permissions, ensuring privacy and security.

Multitasking : Linux is a multitasking operating system, capable of running multiple processes simultaneously. It employs efficient process management mechanisms, such as scheduling, prioritization, and resource allocation, to ensure fair and efficient utilization of system resources.

Multithreading : Linux supports multithreading, allowing processes to create multiple threads of execution within a single process. Multithreading enables concurrent execution of tasks, improves responsiveness, and enhances system performance.

Networking : Linux provides comprehensive networking support, enabling connectivity with local and remote networks. It includes built-in networking protocols, such as TCP/IP, UDP, ICMP, and DNS, as well as networking services, such as DHCP, DNS, and FTP.

Security : Linux offers robust security features to protect system integrity and data confidentiality. It includes access control mechanisms, such as file permissions, user authentication, and role-based access control (RBAC). Additionally, Linux supports encryption, firewalls, intrusion detection, and other security tools to safeguard against threats.

File System : Linux supports a variety of file systems, including ext4, XFS, Btrfs, and NTFS, among others. It provides hierarchical file system organization, directory structure, and file permissions for managing data efficiently and securely.

Command-Line Interface (CLI) : Linux offers a powerful command-line interface (CLI), which allows users to interact with the system using text-based commands. The CLI provides access to a wide range of utilities, commands, and scripting capabilities, enabling automation, customization, and system administration tasks.

Graphical User Interface (GUI) : Linux also includes graphical user interface (GUI) environments, such as GNOME, KDE, and Xfce, for users who prefer a graphical desktop environment. GUIs provide intuitive interfaces for performing tasks, managing files, and running applications.

Package Management : Linux distributions come with package management systems, such as apt, yum, and pacman, that simplify software installation, updates, and removal. Package managers handle dependencies, package repositories, and software distribution, making it easy to manage software packages and libraries.
There are various Linux distros but the following are the most commonly used :

* Ubuntu

* Debian

* CentOS

* Fedora

* RedHat
LILO (Linux Loader) is a boot loader for Linux. It is used to load Linux into memory and start the operating system. LILO can be configured to boot other operating systems as well. LILO is customizable, i.e., if the default configuration is not correct, it can be changed. lilo.conf is the configuration file for LILO. LILO is also a code snippet that loads PC BIOS into the main memory at the time of starting the computer system.

It handles the following tasks :

* Locating Linux kernel

* Identifying other supporting programs and loading them in memory

* Starting the kernel

The selection of various Kernel images and boot routines is supported by LILO. For this reason, it is known as the boot manager.
7 .
What are 10 Linux commands you can use every day?
The 10 most common commands I use when working with Linux are the cd command, mv command, Is command, cp command, rm command, rmdir command, mkdir command, chown command, locate command, reboot command and halt command. In my last role as a system administrator, I worked with these commands daily.
LVM, which stands for Logical Volume Manager, is a storage management technology that provides a layer of abstraction between physical storage devices (such as hard drives or SSDs) and the file systems that reside on them. LVM allows for flexible management of storage resources, including resizing volumes, adding or removing storage devices, and creating snapshots, without disrupting the existing data.

Here's an explanation of the key components and concepts of LVM and its use in a Linux OS setup:

1. Physical Volumes (PVs) : Physical volumes are the underlying storage devices, such as hard drives, SSDs, or partitions, that are used by LVM. These devices are initialized with the LVM metadata, making them recognizable to the LVM system.

2. Volume Groups (VGs) :
Volume groups are logical containers that consist of one or more physical volumes. Volume groups are created by combining multiple physical volumes into a single storage pool. This allows for aggregating storage capacity and managing it as a unified entity.

3. Logical Volumes (LVs) : Logical volumes are virtual storage volumes created within volume groups. They serve as the logical equivalents of traditional partitions and can be formatted with file systems and mounted like regular partitions. Logical volumes can be resized dynamically, allowing for flexible allocation of storage space.

4. LVM Utilities :

LVM provides a set of command-line utilities for managing storage resources. Common LVM commands include pvcreate (to initialize physical volumes), vgcreate (to create volume groups), lvcreate (to create logical volumes), lvresize (to resize logical volumes), and lvremove (to remove logical volumes).

Use of LVM in a Linux OS Setup :

LVM is commonly used in Linux OS setups for its flexibility and ease of management. Here's how LVM can be used in a typical Linux OS setup:

* Flexibility in Partitioning : Instead of traditional fixed-size partitions, LVM allows for creating logical volumes that can be resized dynamically as storage needs change. This flexibility simplifies storage management and reduces the risk of running out of disk space.

* Volume Management : LVM enables the creation of volume groups consisting of multiple physical volumes, providing a unified storage pool that can be managed as a single entity. This simplifies storage management tasks such as adding or removing storage devices and redistributing storage capacity.

* Snapshotting : LVM supports snapshotting, allowing for the creation of point-in-time copies (snapshots) of logical volumes. Snapshots can be used for backup, data recovery, and testing purposes without affecting the original data.

* RAID-like Features : LVM supports features similar to RAID (Redundant Array of Independent Disks), such as mirroring (RAID 1) and striping (RAID 0), by combining multiple physical volumes into volume groups and configuring logical volumes with different RAID levels.
Linux and Unix are both operating systems that share many similarities but also have some key differences. Here are some of the main differences between Linux and Unix:

1. Origins :

* Unix : Unix is one of the oldest operating systems, originally developed at Bell Labs in the late 1960s and early 1970s. It has various flavors, including AT&T Unix, BSD Unix, and System V Unix.
* Linux : Linux is a Unix-like operating system kernel developed by Linus Torvalds in 1991. Unlike Unix, which has multiple proprietary versions, Linux is open source and has many distributions (distros) based on it, such as Ubuntu, Fedora, and Debian.


2. Licensing :

* Unix : Most Unix variants are proprietary and require licensing fees for commercial use. However, some Unix-like operating systems, such as BSD Unix, are open source.
* Linux : Linux is open source and distributed under various free software licenses, such as the GNU General Public License (GPL). This allows anyone to use, modify, and distribute Linux freely.


3. Development Model :

* Unix : Development of Unix variants is typically controlled by a single organization or vendor, such as AT&T, Sun Microsystems (Solaris), or IBM (AIX).
* Linux : Linux development follows a distributed model, with contributions from thousands of developers worldwide. There is no single organization or vendor controlling Linux development, which allows for rapid innovation and adaptation to diverse use cases.


4. Kernel :

* Unix : Unix operating systems are based on the original Unix kernel, which varies depending on the Unix variant (e.g., BSD Unix, System V Unix).
* Linux : Linux is based on the Linux kernel, which was developed independently of the original Unix kernel. While Linux is Unix-like and shares many design principles with Unix, it is not derived from the original Unix codebase.


5. Market Share :

* Unix : Unix has a relatively small market share compared to Linux, particularly in the desktop and consumer markets. It is commonly used in enterprise environments, particularly for mission-critical applications and high-performance computing.
* Linux : Linux has a large and growing market share, particularly in server and cloud computing environments. It is also widely used in embedded systems, mobile devices (Android), and desktop computing (e.g., Ubuntu, Fedora).


6. Community and Ecosystem :

* Unix : Unix has a smaller and more fragmented community compared to Linux, with fewer resources and support available for users and developers.
* Linux : Linux has a large and active community of developers, users, and enthusiasts. There are extensive documentation, forums, and online resources available for Linux users, making it easier to get help and support.
The BASH (Bourne Again SHell) command-line interpreter and scripting language runs on Linux and macOS, among other Unix-based platforms.

It has advanced scripting capabilities and a user-friendly command line interface, with support for things like variables, control structures, and tab completion.

On Unix and Linux systems, BASH is commonly used for a variety of automation, administration, and interactive purposes.
In Linux, there are two primary user modes, known as User Mode and Kernel Mode.

* User Mode : User Mode is the default mode in which user-level applications, processes, and programs run. In this mode, applications have restricted access to the system’s hardware and resources. They interact with the kernel through system calls to request services or perform privileged operations. User Mode provides a level of isolation and protection, preventing user-level processes from interfering with critical system operations.

* Kernel Mode : Kernel Mode, also known as Supervisor Mode or Privileged Mode, is the mode in which the operating system’s kernel executes. In this mode, the kernel has access to the full range of hardware and system resources, and it can execute privileged instructions and perform critical tasks, such as managing memory, handling interrupts, and controlling hardware devices. Kernel Mode is more privileged than User Mode and is responsible for managing the system and providing services to user-level processes.

The transition between User Mode and Kernel Mode occurs through system calls. When a user-level process needs to perform a privileged operation or access hardware resources, it requests the kernel’s assistance through a system call. The kernel then switches to Kernel Mode to fulfill the request, and after completing the operation, it returns control to User Mode.

The separation of User Mode and Kernel Mode helps ensure system stability, security, and protection, as the kernel controls and manages critical operations while user-level processes operate in a more restricted environment.
The Linux Shell, also known as a command-line shell or simply a shell, is a program that provides a command-line interface for interacting with the Linux operating system. It acts as an intermediary between the user and the operating system, allowing users to execute commands, run programs, and perform various tasks through the terminal.

The shell interprets user input (commands) and converts them into system calls that the Linux kernel can understand. It also provides features like command history, tab completion, scripting capabilities, and environment variable management.

There are several types of shells available in Linux, including :

1. Bash (Bourne Again SHell) : Bash is the default and most widely used shell in Linux. It is a powerful and versatile shell with extensive scripting capabilities. Bash is backward-compatible with the original Bourne shell and is known for its ease of use and rich set of features.

2. Sh (Bourne Shell) : The Bourne shell is one of the earliest Unix shells and served as the inspiration for many modern shells, including Bash. Though less feature-rich than Bash, it remains available in many Unix and Linux systems.

3. Csh (C Shell) : The C Shell provides a C-like syntax and additional features, such as command-line history and job control. Some users frequently use it for interactive tasks.

4. Ksh (Korn Shell) : The Korn shell is an improved version of the Bourne shell, providing more features and better scripting capabilities. It is particularly popular among Unix and Linux system administrators.

5. Zsh (Z Shell) : Zsh is an extended version of Bash with additional features, including improved tab completion, powerful globbing, and advanced customization options.

6. Fish (Friendly Interactive SHell) : Fish is designed to be user-friendly with a focus on providing a better interactive experience. It offers features like autosuggestions, syntax highlighting, and a simplified scripting language.

Each shell has its unique features, syntax, and advantages, making them suitable for different user preferences and specific tasks. The choice of shell depends on individual needs and familiarity with their respective features. Bash remains the default shell for most Linux distributions due to its widespread usage, extensive support, and compatibility with scripts written for the Bourne shell.
There are three types of file permissions in Linux :

* Read : Users open and read files with this permission.

* Write : Users can open and modify the files.

* Execute : Users can run the file.
14 .
What is a swap space?
Swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently. This happens when RAM does not have enough memory to hold all programs that are executing.
15 .
What is the advantage of open source?
Open source allows you to distribute your software, including source codes freely to anyone who is interested. People would then be able to add features and even debug and correct errors that are in the source code. They can even make it run better and then redistribute these enhanced source code freely again. This eventually benefits everyone in the community.
16 .
What is the disadvantage of Open Source?
Disadvantages of Open Source Operating System mentioned below

* Difficulty of use
* Compatibility Issues
* Liabilities and warranties
* Hidden costs
17 .
Suppose, you wish to print a file 'draft' with 60 lines on a page. What command would you use?
The command used for this purpose would be as follows:
pr -l60 draft?

Note : The default page length when using pr is 66 lines. The -l option specifies a different length.
LD_LIBRARY_PATH is an environment variable used for debugging a new library or a non-standard library. It is also used to identify the directories that need to be searched for; in order to do this, the path to search for the directories needs to be specified.

The variable can be set using the following :
setenv—LD_LIBRARY_PATH--$PATH?

It is used to search for the shared objects/dynamic libraries by the operating system for extendable functionality at the runtime.
Here is the table that shows the difference between soft links and hard links :

Hard Links Soft Links
It includes original content. It includes the original file location.
Hard links are faster as compared to soft links. Soft links are slower.
It shares similar inode numbers. It shares different inode numbers.
There is no relative path for hard links. Relative paths are used for soft links.
It didn’t link the directories. It links the directories.
Any change in this link reflects other files directly. Every change in this link reflects its hard link and the actual file directly.
It uses less memory. It uses more memory.
The key differences between the BASH and DOS console lie in 3 areas :

* BASH commands are case sensitive while DOS commands are not;

* Under BASH, / character is a directory separator and \ acts as an escape character. Under DOS, / serves as a command argument delimiter and \ is the directory separator

* DOS follows a convention in naming files, which is 8 character file name followed by a dot and 3 characters for the extension. BASH follows no such convention.
21 .
Name a service that you should disable (which acts both as web and FTP servers) on a Linux server.
The finger service should be disabled on a Linux server because a remote user can get important information about the system by using this command.

To disable this service use command: sudo systemctl disable vsftpd
The sar command in Linux is a valuable tool for collecting and analyzing system activity information. It reports various aspects of system performance, such as CPU usage, memory utilization, disk activity, network traffic, and more.

When troubleshooting performance issues, sar enables you to review historical data and identify the causes of high load on specific system components.

When the CPU utilization is close to 100 percent, it indicates that the processing workload primarily demands the CPU. This information helps determine if the system is experiencing a CPU-bound situation.

By default, sar saves its log files in the /var/log/sa/sadd directory, where “dd” represents the current day. These log files are valuable for retrospective analysis and tracking system activity over time.
23 .
How do users create a symbolic link in Linux?
Symbolic links, symlink, or soft links are shortcuts to files and directories. Users can create the symbolic link in Linux through the’ ln’ command. The general command to create a symbolic link is as follows :
ln -s <existing_source file> <optional_symbolic link>?
Output and input in Linux OS are divided into three standard streams :

* Stdin (standard input)
* stdout(standard output)
* stderr (standard error)

Under Linux, these standard streams channel communication of output and input between programs and their environment.
In this case, you can use the ‘mount’ and ‘umount’ commands.

For mounting :

* First, identify the partition through the fdisk -l command. You can also use the lsblk command for it.
* After identifying the partition, create the directory which will work as the mount point. For example, running the mkdir /mnt/mountpnt will create the mountpnt directory as the mount point.
* Finally, you can run sudo mount <partition> <mount_point_directory> to complete the mounting.


For Unmounting :

* Once you check if the specific filesystem is in use, you can run the `sudo umount <mount_point_directory>` for unmounting. If you want to learn more about the mount command in Linux
There are multiple ways to troubleshoot the network connectivity and find the issue correctly:

Check the Internet Connectivity :

* First of all, please check if the internet connection option is on and also check the cables to find if there is any issue with it.


Verify the Network Configuration :

* Please check that your network is configured correctly and the network interface has your IP address. You can check it by running the ip addr or ifconfig commands.
* You can also run the ip route command to check if the default gateway is set properly.
* Finally, verify the DNS server configuration in the /etc/resolv.conf file.


Check the Firewall :

* Sometimes, firewall rules block the internet connection for the system’s security. Hence, you can run the ufw or iptables command to modify the firewall rules.


Network Interface :

* You can restart your network interface through the ifup and ifdown commands. Once you restart the network interface, please reboot the system to make changes successful.
Visual Editor or VI editor is a default text editor that comes with almost every Linux operating system.

There are three different types of modes utilized in the VI editor, as mentioned below :

* Regular Mode or Command Mode : For the VI editor, it's the default mode. It's used for typing commands that perform specific or particular vi functions. To input this mode from other modes, one must click [esc]. It lets us see the content.

* Edit Mode or Insertion Mode : It permits us to type text in a file or perform text editing. To input this mode from other modes, one must click [esc]. It lets us insert or delete content or text.

* Replacement Mode or Ex Mode : It is used to store the files and implementation of the commands. It runs files with distinct parameters. To input this mode, one must click [:]. It lets us overwrite text or content.
The process management system calls in Linux:

* fork() : Used to create a new process.
* exec() : Execute new process.
* wait() : wait until process execution.
* exit() : exit from the process.


System calls to get the Process id :

* getpid() : to find the unique process id.
* getppid() : to find the unique parent process id.
29 .
What command would you use to check how much memory is being used by Linux?
You can use any of the following commands :

* free -m
* vmstat
* top
* htop
In Linux, the maximum length for a filename depends on the filesystem being used. Different filesystems have different limitations on filename length. Here are some common Linux filesystems and their maximum filename lengths:

1. ext2/ext3/ext4 (Linux Standard Filesystems) : The maximum filename length for ext2, ext3, and ext4 filesystems is typically 255 characters. However, this length may be reduced due to other factors like the pathname length or directory structure.

2. XFS (XFS Filesystem) : XFS supports filenames up to 255 bytes (not characters) in length.

3. Btrfs (Btrfs Filesystem) : Btrfs allows filenames up to 255 bytes in length.

4. NTFS (Windows NT File System) : If you have a dual-boot system with Linux and Windows, and the filesystem is NTFS, the maximum filename length is 255 characters.

It’s important to note that the maximum filename length includes the full pathname, including the directory names and separators. Long filenames can be convenient, but it’s essential to ensure compatibility with different filesystems and operating systems when dealing with file and directory names. It’s a good practice to keep filenames reasonably short and avoid using special characters or spaces to enhance cross-platform compatibility and readability.
LVM, or Logical Volume Manager, is a storage management technology available in Linux that allows users to manage disk space more flexibly and efficiently. It provides a layer of abstraction between physical storage devices (such as hard drives, SSDs, or partitions) and the file systems that reside on them. LVM allows for dynamic allocation, resizing, and management of storage volumes without the need to repartition disks, which can be particularly useful in environments where storage needs are expected to change over time.

Here's a brief overview of the key components and concepts of LVM :

Physical Volumes (PVs) : Physical volumes are the underlying storage devices or partitions that are initialized for use with LVM. These devices can be entire hard drives, partitions, or even RAID arrays. PVs are typically initialized using the pvcreate command.

Volume Groups (VGs) : Volume groups are logical containers that consist of one or more physical volumes. Volume groups aggregate the storage capacity of multiple physical volumes into a single pool of storage. VGs are created using the vgcreate command.

Logical Volumes (LVs) : Logical volumes are virtual storage volumes created within volume groups. LVs are analogous to traditional partitions but offer more flexibility in terms of resizing and management. Logical volumes can be formatted with file systems and mounted like regular partitions. They are created using the lvcreate command.

LVM Utilities : LVM provides a set of command-line utilities for managing storage resources. Common LVM commands include pvcreate (to initialize physical volumes), vgcreate (to create volume groups), lvcreate (to create logical volumes), lvresize (to resize logical volumes), and lvremove (to remove logical volumes).

Snapshotting : LVM supports snapshotting, allowing users to create point-in-time copies (snapshots) of logical volumes. Snapshots can be used for backup, data recovery, and testing purposes without affecting the original data.

Striping and Mirroring : LVM allows for advanced storage configurations such as striping (RAID 0) and mirroring (RAID 1) by combining multiple physical volumes into volume groups and configuring logical volumes with different RAID levels.
32 .
What are inode and process id?
INODE : It's a unique name provided to all files by the operating system. All inodes have a unique inode number in a file system. INODE stores many details about files, including the number of links, access mode, file type, file size, ownership, etc.

Process Id : It's a unique Id provided to all processes. It is used to identify a running process uniquely throughout the computer until the process ends.
33 .
What is umask?
unmask stands for user file creation mode. When the user creates any file, it has default file permissions. So unmask will specify few restrictions to the newly created file (it controls the file permissions).
umask [-S] [mask]?
There are 5 main Directory Commands in Linux :

* pwd : Displays the path of the present working directory.

Syntax : $ pwd


* ls : Lists all the files and directories in the present working directory.

Syntax: $ ls


* cd : Used to change the present working directory.

Syntax : $ cd <path to new directory>


* mkdir : Creates a new directory

Syntax: $ mkdir <name (and path if required) of new directory>


* rmdir : Deletes a directory

Syntax : $ rmdir <name (and path if required) of directory>
35 .
What is the importance of the GNU project?
This so-called Free software movement allows several advantages, such as the freedom to run programs for any purpose and freedom to study and modify a program to your needs. It also allows you to redistribute copies of software to other people, as well as the freedom to improve software and have it released for the public.
Virtual Desktop is a feature that allows users to use the desktop beyond the physical limits of the screen. Basically, Virtual Desktop creates a virtual screen to expand the limitation of the normal screen.

There are two ways Virtual Desktop can be implemented :

* Switching Desktops
* Oversized Desktops

Switching Desktops : In the case of Switching Desktops, you can create discrete virtual desktops to run programs. Here, each virtual desktop will behave as an individual desktop and the programs running on each of these desktops is accessible only to the users who are using that particular desktop.

Oversized Desktops : Oversized Desktops do not offer a discrete virtual desktop but it allows the user to pan and scroll around the desktop that is larger in size than the physical screen.
37 .
What are daemons?
A daemon is a computer program that runs as a background process to provide functions that might not be available in the base Operating System. Daemons are usually used to run services in the background without directly being in control of interactive users. The purpose of Daemons are to handle periodic requests and then forward the requests to appropriate programs for execution.
CLI is short for Command Line Interface. This interface allows the user to type declarative commands to instruct the computer to perform operations. CLI offers greater flexibility. However, other users who are already accustomed to using GUI find it difficult to remember commands including attributes that come with it.

GUI, or Graphical User Interface, make use of images and icons that users click and manipulate as a way of communicating with the computer. Instead of having to remember and type commands, the use of graphical elements makes it easier to interact with the system, as well as adding more attraction through images, icons, and colors.
Below are the logical steps to reduce the size of the LVM partition :

* Unmount the file system using the unmount command

* Use the resize2fs command as follows:
resize2fs /dev/mapper/myvg-mylv 10G?


* Then, use the lvreduce command as follows:
lvreduce -L 10G /dev/mapper/myvg-mylv?


This way, we can reduce the size of the LVM partition and fix the size of the file system to 10 GB.
In Linux, network bonding (also known as NIC bonding or channel bonding) allows multiple network interfaces to be aggregated together to form a single logical interface, providing fault tolerance and increased network bandwidth. There are several modes of network bonding available in Linux, each offering different features and characteristics. Here are the different modes of network bonding:

Mode 0 - Round Robin (balance-rr) : In this mode, outgoing network packets are distributed sequentially across the bonded network interfaces in a round-robin fashion. This mode provides load balancing and increased outbound bandwidth but does not provide fault tolerance for incoming traffic.

Mode 1 - Active-Backup (active-backup) : In active-backup mode, one network interface (the active interface) is actively used for network traffic, while the other interfaces (the backup interfaces) remain in standby mode. If the active interface fails, traffic is automatically switched to one of the backup interfaces, providing fault tolerance with minimal network interruption.

Mode 2 - XOR (balance-xor) : XOR mode balances outgoing network traffic based on the MAC address of the transmitting device and the slave interface's MAC address. This mode provides load balancing and fault tolerance but requires specific network configurations to be effective.

Mode 3 - Broadcast (broadcast) : Broadcast mode sends all outgoing network traffic over all bonded interfaces simultaneously. This mode is primarily used for redundancy and does not provide load balancing or increased bandwidth.

Mode 4 - IEEE 802.3ad Dynamic Link Aggregation (802.3ad) : Also known as Dynamic Link Aggregation (LACP), this mode uses the Link Aggregation Control Protocol (LACP) to negotiate and dynamically manage the aggregation of network interfaces. It provides load balancing and fault tolerance while allowing for dynamic reconfiguration of the bonded interfaces.

Mode 5 - Adaptive Load Balancing (balance-tlb) : Adaptive Load Balancing mode balances outgoing network traffic based on the current load of each bonded interface. Outgoing traffic is distributed based on the current traffic load, providing increased bandwidth utilization without requiring special switch configuration. However, incoming traffic is not load-balanced.

Mode 6 - Adaptive Load Balancing with Fault Tolerance (balance-alb) : Adaptive Load Balancing with Fault Tolerance mode combines the features of active-backup mode and adaptive load balancing. It dynamically balances outgoing traffic based on the current load of each bonded interface while providing fault tolerance for incoming traffic by dynamically reassigning IP addresses.


Each bonding mode has its advantages and limitations, and the choice of mode depends on the specific requirements of the network environment, such as the desired level of fault tolerance, load balancing, and compatibility with network infrastructure.
You can use the chmod command to change the file permissions of the directories. It offers a simple way to control the read and write permissions. For instance, if you want to change the permission of the ABC.sh script and give it the write and executable permission, you can run the below command:
chmod u+wx ABC.sh?

The chmod command is not limited to the write (w), read (r), and executable (x) permissions because there are symbolic modes and numeric modes.
You can use the following command to find the Process ID or PID of the currently running process :

pgrep Command : The pgrep command shows the PID of a process through its name or other different attributes. For example, you can find the PID of process_1 using the below command:
pgrep <process_1>?


ps Command : ps command not only displays the currently running process but also shows the process’s PID. However, if you want to check the PID of a specific process, you can combine the ps with the grep command:
ps -e | grep -i <process_1> ?
The rsync command is used to synchronize and transfer the files in Linux. It synchronizes files between two local systems, directories, or a network. The basic rsync command contains the following :
rsync <options> <source> <destination>?

For example, let’s synchronize between Documents and the Downloads directory. For this, you need to run the following command :
rsync -av ~/Documents ~/Downloads?

If you want to go one step further, then you can use the below command :
rsync -avz --delete ~/Documents ~/Downloads?


In the above command :

* The -a option preserves all the permissions and other attributes

* The -v option displays the detailed output of the synchronization

* The -z allows compression that decreases the bandwidth use.

* The –delete option removes the file in the Downloads that do not exist in the Documents directory.
You can use adduser and useradd commands to create a user for the system.

useradd Command : Let’s create a username, “Ron,” and provide a password for accessing the system:
useradd Ron
passwd Ron ?

You can also explore the useradd command’s additional options to modify the new user’s permissions and privileges.

adduser Command : The adduser command is similar to the useradd command, so let’s create a username “Shawn”:
adduser Shawn
passwd Shawn?
The ps command displays the current process status of the system. And it displays the processes id’s with some other related data also.

Syntax :
Ps [options]?


Output :
[root@rhe17~]# ps

PID TTY    TIME CMD

12330 pts/0  00:00:00 bash

21621 pts/0  00:00:00 ps?
We have so many Linux Distributors, among them, we discuss a few important ones.

Linux Mint : It is stable and robust. Linux Mint uses mate desktop and cinnamon.

Debian : It stands for robustness, stability, and a well-oiled release cycle. It is user-friendly. Debian version 8 will be replaced by version 9.

Ubuntu : It is available for both desktop and server editions and is based on Debian.  

openSUSE : It is a good choice for new users and existing users.

Manjaro : It gives a pleasant experience for new and experienced users.
In Linux, the redirection operator is a special character used to control the input and output streams of commands and shell scripts. It allows users to redirect input from and output to files, devices, or other commands. The redirection operator is primarily used in the command line interface (CLI) and shell scripts to manipulate input and output streams efficiently.

Here are the common redirection operators used in Linux :

Standard Output Redirection (>) : The > operator is used to redirect the standard output (stdout) of a command to a file or device. If the specified file already exists, it will be overwritten. If it does not exist, a new file will be created.
command > output.txt?

Append Output Redirection (>>) :  The >> operator is similar to >, but it appends the output of a command to the specified file instead of overwriting it. If the file does not exist, a new file will be created.
command >> output.txt?

Standard Input Redirection (<) : The < operator is used to redirect the standard input (stdin) of a command from a file. It allows the command to read input from the specified file instead of from the keyboard.
command < input.txt?
Here Document (<<) : The << operator is used to create a temporary input stream for a command. It allows multiple lines of input to be provided directly within the shell script without the need for an external file.
command << EOF
This is line 1
This is line 2
EOF?

Here String (<<<) : The <<< operator is used to redirect a string as input to a command. It allows a string to be passed as input to a command without the need for an external file or here document.
command <<< "input string"?

Pipe (|) : The | operator is used to redirect the standard output (stdout) of one command as the standard input (stdin) of another command. It allows the output of one command to be passed as input to another command.
command1 | command2?

These redirection operators provide powerful capabilities for manipulating input and output streams in Linux, allowing users to efficiently manage data flow in command line operations and shell scripts.
The “/proc” file system is a virtual file system in Linux that provides real-time information about running processes and kernel configurations. It is a dynamic interface, representing data in memory rather than physical files on disk. It is valuable for monitoring, debugging, and accessing system information.

For example, to view information about the current CPU utilization, you can read the “/proc/stat” file. To see the memory usage of a specific process with PID 12345, you can check the “/proc/12345/status” file.

Overall, the “/proc” file system is a powerful and dynamic interface that provides valuable system information and insights for system administrators, developers, and monitoring tools in Linux-based systems.
The main difference between cron and anacron lies in how they schedule and run tasks on a Unix-like operating system, such as Linux.

cron :

* `cron` is a time-based job scheduler in Unix-like systems. It allows users to schedule recurring tasks or jobs at specific intervals using a configuration file called the “crontab.”

* Tasks scheduled with `cron` run at specified times or intervals (e.g., every hour, daily, weekly) and require the system to be continuously running. If the system is powered off during the scheduled time, the task is not executed until the next scheduled interval.

* `cron` is suitable for tasks that need to run regularly and predictably on a system that is always powered on, such as system maintenance, log rotation, and backups.


anacron :

* `anacron` is also a time-based job scheduler like `cron`, but it is designed to handle tasks that are meant to be executed on systems that may not be continuously running, such as laptops or desktop computers that are regularly powered off or in sleep mode.

*
Tasks scheduled with `anacron` have more flexibility in execution time and do not depend on specific intervals. Instead, they have a defined delay before execution, typically measured in days. When the system is powered on, `anacron` checks if the specified delay has passed since the last execution, and if so, it runs the task.

* Unlike `cron`, `anacron` ensures that tasks are executed regardless of whether the system was powered off during the scheduled time. It is designed to prevent tasks from being missed due to system downtime.
While Linux is known for its robust security features and relatively low susceptibility to malware compared to other operating systems like Windows, it is not completely immune to viruses or other forms of malicious software.

Here are some key points to consider :

* Security Architecture : Linux has a strong security architecture with features such as user permissions, file system permissions (like chmod), firewall capabilities (like iptables), and package management systems (like apt or yum) that help mitigate security risks.

* Open Source Community : Linux benefits from a large and active open-source community that continuously reviews, audits, and improves the codebase, making it more resilient to security vulnerabilities.

* Market Share : Linux's lower market share on desktop systems compared to Windows may make it less of a target for malware developers. However, Linux is widely used in server environments, where security is a critical concern.

* Targeted Attacks : While Linux may have fewer malware threats targeting it compared to other operating systems, it is not immune to targeted attacks or vulnerabilities in specific software components or configurations.

* User Awareness : Linux users, particularly system administrators and power users, tend to have a higher level of awareness about security best practices, such as keeping software up to date, using strong passwords, and practicing safe browsing habits.

* Third-Party Software : Like any operating system, Linux can be vulnerable to malware introduced through third-party software repositories, packages, or untrusted sources. It is essential to use reputable sources and exercise caution when installing software.

* Security Updates : Linux distributions regularly release security updates and patches to address known vulnerabilities and issues. Staying up to date with these updates is crucial for maintaining a secure Linux system.
51 .
How to exit from vi editors?
The following commands are used to exit from vi editors.

:wq saves the current work and exits the VI.

:q! exits the VI without saving current work.
52 .
How to delete information from a file in vi?
The following commands are used to delete information from vi editors.

x deletes a current character.
dd deletes the current line.
In Linux, a Zombie Process is also known as a dead or defunct process. It is a process that has completed the execution, but its access remains inside the process table. Usually, it happens because of insufficient correspondence between child and parent processes.

This process appears for the child process due to the parent process requires reading the child process's status. This process is deleted from the process table once it is finished with the wait system call.
54 .
Define the ping command.
Packet Internet Groper aur ping command checks the connection status between the destination and source. In other words, this command checks whether a network is present and if the host is attainable. We can use the ping command to check both the IP address and name of the system.
In Linux, Hard links can be defined as another name for an already existing file. For each file, we can generate an unlimited number of hard links. They have the ability to generate links for other hard connections. We can use the `Is-I` command to find out the total number of hard links in a file. And we can create Hard links using the following command:
$ ln [original filename] [link name]?


Soft link is also known as a symbolic link. Soft links are files that, in most cases, lead to another file. It just links to another entry somewhere in the file system and does not include any data in the destination file. These kinds of connections can be utilized across several file systems. The following command can be used to create soft links :
$ ln -s [original filename] [link name]?
Linux has become more popular in the technology industry in terms of security. There are several reasons why Linux is more secure than other operating systems.

* On Linux, only a few people have access to the system. As a result, the virus cannot infect the entire system but it may affect only a few files.

* Before opening the files, Linux users must first complete the tasks, so that they can protect their systems against flaws.

* The Linux operating system includes a variety of working environments, including Linux Mint, Debian, Arch, and others, all of which include virus protection.

* It keeps a log history so that it may quickly see the specifics of the system files afterward.

* Iptables is a Linux feature that examines the system’s security circle.

* As Linux users are comparatively fewer in number as compared to other operating systems, security will be enhanced.
It is in the test file named ‘/etc/passwd’ that Linux usually keeps its user account details, including the one-way encrypted passwords. However, this file can be accessed with the help of different tools, which might throw security issues.

To minimize this risk, we will make use of the shadow password format that saves the account details in a regular file /etc/passwd as in the traditional method but with the password stored as a single ‘x’ character, i.e., it is not the original password that is actually stored in this file.

Meanwhile, a second file /etc/shadow will have the encrypted password, along with the other relevant information, such as the account/password expiration date, etc. Most importantly, the latter file is readable only by the root account, and thus it minimizes the security risk.

To enable shadow password use the command: pwconv
A Linux Administrator assigns a POP3 mail-only account to the /bin/false shell. However, assigning a bash shell to a POP3 mail-only account gives the user the login access, which is usually avoided. The /bin/nologin shell can also be used. This shell is provided to the user when we don’t want to give shell access to the user. The user cannot access the shell, and it rejects shell login on the server as in Telnet. It is mainly meant for the security of the shells.

POP3 is basically used for downloading mail-to-mail programs. So for the illegal downloading of emails on the shell, this account is assigned to the /bin/false shell or the /bin/nologin shell. Both shells are the same as they do the same work of rejecting the user login to the shell.

The main difference between these two shells is that the false shell shows the incorrect code and any unusual coding when a user logs in to it, whereas the nologin shell simply tells us that no such account is available. Therefore, the nologin shell is used often in Linux.
59 .
What is YUM?
YUM stands for Yellowdog Updater Modified because it is based on YUP, the Yellowdog Updater. Yellowdog is a version of Linux for the Power Architecture hardware and is RPM-based, just like Red Hat Enterprise Linux and Fedora. YUP, and later YUM, were written by the Linux community as a way to maintain an RPM-based system.
Kudzu is used to detect new hardware. Red Hat Linux runs a hardware discoverer, called Kudzu. When attempting to identify a serial port, Kudzu resets the serial port. This stops the serial console. Kudzu is configured from the following file:
/etc/sysconfig/kudzu?

Kudzu can be prevented from resetting hardware, by setting the configuration parameter SAFE to ‘yes.’
* The ext3 file system is an enhanced version of the ext2 file system.

* The most important difference between ext2 and ext3 is that ext3 supports journaling.

* After an unexpected power failure or system crash (also called an unclean system shutdown), each ext2 file system must be checked for consistency by the e2fsck program. This is a time-consuming process and during this time, any data on the volumes is unreachable.

* The journaling provided by the ext3 file system means that this sort of a file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs while using ext3 is in certain rare hardware failure cases, such as hard drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or on the number of files. Rather, it depends on the size of the journal used to maintain consistency. The default journal size takes almost a second to recover, depending on the speed of the hardware.
In Linux, processes are the independent program, while a thread is the unit of execution. So here are the complete differences between process and thread :

Comparison Factors Process Thread
Creation time Creation time is higher Creation time is less.
Dependency It is independent because it does not share memory. It depends on other threads because they share some memory with other threads.
Resource Resource use is higher Requires lesser resources
Termination time The termination time is higher The termination time is less.
63 .
What is the ulimit command, and how do you use it?
The ulimit command controls the resource limit for the user process. You can use the ulimit command to set the limit on the system resource to prevent consuming the higher resources. This command contains multiple options to set the limit. For example, you can use the u option to set a maximum number of processes to 50:
ulimit -u 50 ?
The find command searches for files based on different factors such as name, size, permissions, etc. Here is the basic command :
find <directory> <file>?

For example, let’s find a Linux.txt file located in the Downloads directory through the below command :
find ~/Downloads -name Linux.txt?

Once you run the above command, the find command will start finding the Linux.txt in the Downloads directory and subdirectories.
The strace command is the diagnostic utility by which you can trace and monitor the system calls generated by the process. It allows you to find how programs interact with Kernel and can be used for debugging and troubleshooting. For example, let’s find the system calls generated by the ls command :
strace ls?

Once you run the above command, the system will start tracing the list command and show the system calls generated by it. Output from the above command includes information like call name, argument, and return values.
You can optimize the Linux performance through various strategies to improve resource usage and efficiency. So some of the strategies are :

* Updates the system as per the latest one available.

* Optimize the disk, enable the caching, and optimize the access pattern.

* Manage memory and CPU usage.

* Disable the necessary services and use lightweight alternatives of the tools.

* Monitor the system resources regularly.

* Perform the Kernel parameter tune-up.

* Use tools like Performance Co-Pilot (PCP) to monitor system-level performance.
67 .
How do you switch from one desktop environment to another, such as switching from KDE to Gnome?
Assuming you have these two environments installed, just log out from the graphical interface. Then at the login screen, type your login ID and password and choose which session type you wish to load. This choice will remain your default until you change it to something else.
68 .
Explain how you can find a file using Terminal?
To find a file you have to use a command, find . –name "process.txt". It will look for the current directory for a file called process.txt.
The iptables command configures Netfilter firewall rules providing the network address translation, packet filtering, etc. iptables inspects the network packet and then manages them according to the defined rules. Here is how you can use the iptables command for network filtering:

Run the below command to display the current iptables rules, including policies, chains, and other actions for the network:
iptables -L?

The iptables configuration uses the predefined set of chains to process the network packages at different stages. So you can define rules to these chains for manipulating the network packets:
iptables -A <chain> <options> -j <target>?

In the above command :

* <chain> : Specifies the chain where you want to define a new rule.

* <options> : Defines the conditions for the rule, like ports, protocols, etc.

* -j <target> : Defines the target action when the packet matches the rule.


By default, iptables rules get automatically removed after the system reboot, but you can use the following command to make the rules persistent:
iptables-save > /etc/iptables/rules.v4?
To compress files in Linux, you can use the tar command along with gzip compression.

For example : If we want to create a file name “shivaji” with gzip compression. We use the following command.
tar -czvf shivaji.tar.gz files?

This command will create a compressed archive file containg the specified “files

To decompress the same, we use the following command.
tar -xzvf shivaji.tar.gz?
71 .
What is the purpose of the netstat command in Linux, and how do you view network connections and listening ports?
The netstat command in Linux is used to display active network connections, routing tables, and listening ports. To view network connections and listening ports, use the netstat command with appropriate options.

For example : If we want to display all listening TCP ports, we can use the following command.
netstat -tuln?
To set up a static IP address in Linux using the command-line interface, you need to modify the network configuration file. The location and name of the file may vary depending on the Linux distribution, but commonly it is /etc/network/interfaces. Open the file with a text editor and modify the configuration to set a static IP address, subnet mask, gateway, and DNS servers.

For example :
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4?
The sudoers file in Linux controls the sudo access permissions for users. It determines which users are allowed to run commands with superuser (root) privileges. To configure sudo access, you can edit the sudoers file using the visudo command.

For example :
sudo visudo?

Now add this line anywhere in the file. For instance, if we want to grant a user full sudo access.
user_name ALL=(ALL) ALL?