Red Hat Linux Interview Q & A

Red Hat Linux Interview Q & A

Red Hat Linux   /   Mar 21st, 2023   /  A+ | a-
Theoretical + Scenario based Questions
Q1.What is Linux?
  • Linux is an operating system or a kernel distributed under an open-source license. Its functionality list is quite like UNIX.
  • The kernel is a program at the heart of the Linux operating system that takes care of fundamental stuff, like letting hardware communicate with software.

Q2.What is the difference between Linux and UNIX?
  • UNIX originally began as a propriety operating system from Bell Laboratories, which later on spawned into different commercial versions.
  • On the other hand, Linux is free, open source and intended as a non-propriety operating system for the masses.
Q3. What is Linux Kernel? Is it legal to edit Linux Kernel?
  • Def: The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also used to provide an interface for user-level interaction.
  • Reason: Yes, it is completely legal to edit the Linux kernel since it is under General Public License – GNU. Linux kernel is an open-source project; it encourages people to edit, fix, and report.
Q4. What are the basic components of Linux?
Components of Linux System
Linux Operating System has primarily three components
  • Kernel − Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs.
  • System Library − System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating system and do not requires kernel module's code access rights.
  • System Utility − System Utility programs are responsible to do specialized, individual level tasks.
  • Kernel Mode vs User Mode
  • Kernel component code executes in a special privileged mode called kernel mode with full access to all resources of the computer. This code represents a single process, executes in single address space and do not require any context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to processes, provides protected access to hardware to processes.
  • Support code which is not required to run in kernel mode is in System Library. User programs and other system programs works in User Mode which has no access to system hardware and kernel code. User programs/ utilities use System libraries to access Kernel functions to get system's low level tasks.
Q5. Which are the Shells used in Linux?
  • SHELL is a program which provides the interface between the user and an operating system.
  • When the user logs in OS starts a shell for user. Kernel controls all essential computer operations, and provides the restriction to hardware access, coordinates all executing utilities, and manages Resources between processes.
  • Using kernel only user can access utilities provided by operating system.
Types of Shell:
    1. The C Shell – Denoted as csh
Bill Joy created it at the University of California at Berkeley. It incorporated features such as aliases and command history. It includes helpful programming features like built-in arithmetic and C-like expression syntax.
Command full-path name is /bin/csh,
Non-root user default prompt is hostname %,
Root user default prompt is hostname #.
    1. The Bourne ShellDenoted as sh
It was written by Steve Bourne at AT&T Bell Labs. It is the original UNIX shell.
It is faster and more preferred. It lacks features for interactive use like the ability to recall previous commands.
It also lacks built-in arithmetic and logical expression handling. It is default shell for Solaris OS.
Command full-path name is /bin/sh and /sbin/sh,
Non-root user default prompt is $,
Root user default prompt is #.
 
    1. The Korn Shell - It is denoted as ksh
It was written by David Korn at AT&T Bell Labs. It is a superset of the Bourne shell. So it supports everything in the Bourne shell.
It has interactive features. It includes features like built-in arithmetic and C-like arrays, functions, and string-manipulation facilities.
It is faster than C shell. It is compatible with script written for C shell.
          Command full-path name is /bin/ksh,
Non-root user default prompt is $,
Root user default prompt is #.
    1. GNU Bourne-Again Shell - Denoted as bash
It is compatible to the Bourne shell. It includes features from Korn and Bourne shell.
Command full-path name is /bin/bash,
Default prompt for a non-root user is bash-g.gg$
(g.ggindicates the shell version number like bash-3.50$),
Root user default prompt is bash-g.gg#.
Q6. What is 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.
Q7. Explain file permission in Linux.
All the three owners (user owner, group, others) in the Linux system have three types of permissions defined. Nine characters denotes the three types of permissions.
  1. Read (r): The read permission allows you to open and read the content of a file. But you can't do any editing or modification in the file.
  2. Write (w): The write permission allows you to edit, remove or rename a file. For instance, if a file is present in a directory, and write permission is set on the file but not on the directory, then you can edit the content of the file but can't remove, or rename it.
  3. Execute (x): In UNIX type system, you can't run or execute a program unless execute permission is set. But in Windows, there is no such permission available.
Q8. What are inode and process id?
  • An Inode number is a uniquely existing number for all the files in Linux and all UNIX type systems.
  • When a file is created on a system, a file name and Inode number is assigned to it.
  • Generally, to access a file, a user uses the file name but internally file name is first mapped with respective Inode number stored in a table.
Note:
  • Inode doesn't contain the file name.
  • Reason for this is to maintain hard-links for the files.
  • When all the other information is separated from the file name then only we can have various file names pointing to the same Inode.
1. Inode Contents:
  • An Inode is a data structure containing metadata about the files.
Following contents are stored in the Inode from a file:
  • User ID of file
  • Group ID of file
  • Device ID
  • File size
  • Date of creation
  • Permission
  • Owner of the file
  • File protection flag
  • Link counter to determine number of hard links

Example:
    Command: ls –ld new1
2. Inode Table:
  • The Inode table contains all the Inodes and is created when file system is created. The df –I command can be used to check how many inodes are free and left unused in the filesystem.
  • Look at the above snapshot, the command “df –I” shows the usage of several file systems.
3. Inode Number:
  • Each Inode has a unique number and Inode number can be seen with the help of ls -li command.
  • Look at the above snapshot, Directory Disk1 has the three files and each file has a different Inode number.
Q9. What is Virtual Desktop?
  • A virtual desktop allows users to access their desktop and applications from anywhere on any kind of endpoint device, while IT organizations can deploy and manage these desktops from a centrally located data centre.
  • Another example of virtual desktop technology is Microsoft Remote Desktop Services (RDS), which allows multiple users to share a single Windows Server operating system instance.
Q10. Which are the different modes of vi editor?
  • The default editor that comes with the UNIX operating system is called vi (visual editor).
  • Using vi editor, we can edit an existing file or create a new file from scratch. We can also use this editor to just read a text file.
Modes of Operation in vi editor: There are three modes of operation in vi:
  • Command Mode: When vi starts up, it is in Command Mode. This mode is where vi interprets any characters we type as commands and thus does not display them in the window. This mode allows us to move through a file, and to delete, copy, or paste a piece of text. To enter into Command Mode from any other mode, it requires pressing the [Esc] key. If we press [Esc] when we are already in Command Mode, then vi will beep or flash the screen.
 
  • Insert mode: This mode enables you to insert text into the file. Everything that’s typed in this mode is interpreted as input and finally, it is put in the file. The vi always starts in command mode. To enter text, you must be in insert mode. To come in insert mode you simply type i. To get out of insert mode, press the Esc key, which will put you back into command mode.
 
  • Last Line Mode (Escape Mode): Line Mode is invoked by typing a colon [:], while vi is in Command Mode. The cursor will jump to the last line of the screen and vi will wait for a command. This mode enables you to perform tasks such as saving files, executing commands.
Q11. What are the process states in Linux?
Def of Process: A process is an instance of a program in execution. A set of processes combined together make a complete program.
There are two categories of processes in UNIX, namely
  • User processes: They are operated in user mode.
  • Kernel processes: They are operated in kernel mode.
Process States:
The states that a Process enters in working from start till end are known as Process states. These are listed below as:
  • Created-Process is newly created by system call, is not ready to run
  • User running-Process is running in user mode which means it is a user process.
  • Kernel Running-Indicates process is a kernel process running in kernel mode.
  • Zombie- Process does not exist/ is terminated.
  • Pre-empted- When process runs from kernel to user mode, it is said to be pre-empted.
  • Ready to run in memory- It indicated that process has reached a state where it is ready to run in memory and is waiting for kernel to schedule it.
  • Ready to run, swapped– Process is ready to run but no empty main memory is present
  • Sleep, swapped- Process has been swapped to secondary storage and is at a blocked state.
  • Asleep in memory- Process is in memory (not swapped to secondary storage) but is in blocked state.
Q12. Explain grep command.
  • The 'grep' command stands for "global regular expression print". grep command filters the content of a file which makes our search easy.
  • It is a command-line utility to search plain-text data groups for lines that are the same as a regular expression
  • The name "grep" comes from the command, i.e., ed, which contains the same effect. Originally, grep was designed for the UNIX operating system, but it became available for every Unix-like system later and a few others like OS 9.
  • The grep filter finds a file for a specific character pattern and shows every line that includes that pattern. Characters should be in quotation marks if they occur in the pattern parameter with a special meaning for the shell.
Implementations of grep
  • A range of grep implementations is present in several software development environments and operating systems.
  • Early versions included fgrep and egrep, introduced in the 7 version of Unix.
  • The egrep version supports syntax for an extended regular expression included by Alfred Aho after the original regular expression implementation of Ken Thompson.
  • The fgrep version finds any fixed string list with the Aho-Corasick string matching algorithm.
  • These version binaries are available in modern systems, connecting to grep or calling grep a shell script using the correct flag added while generally deployed on the POSIX systems.
  • Other commands include the "grep" word to represent they are finding tools, commonly ones that depend on regular expression matches.
  • For example, the utility, i.e., "pgrep", shows the processes whose titles are the same as provided regular expression.
  • Grep is the title of the built-in function that searches for the elements within a list that amuse a certain property in the Perl programming language.
  • Typically, this higher-order function is called "filter" or "where" in another language.
  • The command, i.e., pcregrep, is a grep implementation that utilizes the syntax for Perl regular expression. The same functionality can be added to the grep GNU version using the -P flag.
  • Also, grep ports (e.g., in GnuWin32 and Cygwin) execute upon Microsoft Windows. A few Windows versions provide the same findstr or qgrep command.
  • Also, the grep command is a part of the MSX-DOS2 Tools of ASCII for the 2 version of MSX-DOS.
  • The fgrep, egrep, and grep commands have been shipped to the IBM i OS.
  • The Adobe InDesign software has GREP functions (since CS3 edition) in the change/find "GREP" tab dialog box and specified using CS4 in the "GREP styles" paragraph styles.
Top