Thursday, 2 May 2024

Linux Interview Questions&Answres

 

Q1. What is Linux?

Ans. Linux is an Open-Source Operating System first introduced by Linus Torvalds.  It is based on UNIX and it is available freely. It can be executed on different hardware platforms such as Intel, HP, MIPS, Motorola, SPARC, IBM, etc. 

Q2. What are the main components of LINUX?

Ans. Major components in the Linux operating system are:

  • Kernel: It is the primary component that manages hardware and basic operations in the Linux operating system.
  • Shell: It is an interpreter that executes commands for different functions in Linux.
  • GUI: Graphical User Interface (GUI) is an interface through which users interact with the system. It comprises images, text boxes, buttons, checkboxes, etc.
  • System Utilities: It includes software functions that help the user to manage the basic functioning of a computer.
  • Application Programs: These are a set of software programs intended to complete certain tasks

Q3. How to check and verify the status of the bond interface?

Ans. Using the command ‘cat /proc/net/bonding/bond0,’ we can check what mode is enabled and what LAN cards are used in this bond. In this example, we have one bond interface. However, we can have multiple bond interfaces like bond1, bond2, and so on.

Q4. What do you understand by Linux Kernal? Is it legal to edit it?

Ans. Kernal essentially refers to that core component of the PC working framework that gives fundamental administrations to alternate parts and in addition connects with client summons. With regards to 'Linux Kernal, it is referred to as low-level system software providing an interface for user-level interactions.

Linux Kernal is considered as free and open-source programming which is fit for managing hardware resources for the clients. As it is released under General Public License (GPL), it winds up legal for anybody to alter it.

Q5. How can we use LINUX?

Ans. LINUX is used widely because it is completely different from other operating systems with something extra i.e. some additional features

  • It is an open-source operating system where programmers get the advantage of designing their own custom OS.
  • Software and the server licensing required to install Linux is completely free and can be installed on many computers as required.
  • It has low or minimum but controllable issues with viruses, malware, etc
  • It is highly secured and supports multiple file systems.

Q6. Define GUI?

Ans. GUI stands for the Graphical user interface. GUI is considered as the most attractive and user-friendly because it consists of the usage of images and icons.

Q7. Define CLI?

Ans. CLI stands for Command Line Interface. It is a way for humans to interact with computers and is also known as a Command-line user interface.

Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training

Q8. What is the maximum length for any file name under LINUX?

Ans. The maximum length for any filename under Linux is 255 characters.

Q9. How to Enable ACLs for /home partition?

Ans. Add following entry in /etc/fstab LABEL=/home /home ext3 acl 1 2 Now remount /home partition with acl option. mount -t ext3 -o acl /dev/sda3 /home

Q10.  How do you create an ext4 file system?

Ans. # mke2fs -t ext4 /dev/DEV

Q11. What is the name and path of the main system log?

Ans. By default, the main system log is ‘/var/log/messages’. This file contains all the messages and the script written by the user. By default, all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to ‘dmesg’. dmesg is a system file that is written upon system boot.

Q12. What is partial backup?

Ans. When you select only a portion of your file hierarchy or a single partition to back up, it is called partial backup.

Q13. Differentiate between LINUX and UNIX?

Ans.

LINUXUNIX
LINUX is an open-source free operating system used in the functioning of computer hardware & software, system application, game development etc.UNIX is also an operating system mostly used in internet servers, HP, intel etc.
LINUX is available in both the versions- freely downloaded and distributed as well as priced minimally.UNIX comes in different versions with different price structures.
Linux can be easily used by anyone such as web developers, software engineers, home users, etc.UNIX is developed to be generally used for servers, mainframes, and workstations.
The file support system in LINUX comprises Ext2 to Ext4, Xfs, Jfs, FAT, Btrfs, etc.The file support system in UNIX consists of gpfs, jfs hfs, etc.
In LINUX, BASH (Bourne Again Shell) serves as the Linux default shell i.e. text-mode interface that can be executed on multiple command-line interpreters.Bourne shell acts as the text mode interface that is compatible with multiple other interfaces including BASH.
LINUX comprises two GUIs, Gnome and KDE.In UNIX, the Common desktop environment serves as a GUI.
Examples: Fedora, Red Hat, Debian, Ubuntu, etc.Examples: Linux, Solaris

Q14. What are LINUX's basic commands?

Ans. In Linux, commands are case-sensitive, and more often than not they are entirely in lowercase. Items that are surrounded by brackets ([]) are optional. You will more than likely use at least some of these commands every time you log into a Linux system. Become familiar with these commands because they can get you pretty far in a short amount of time.

  • ls - Lists directory contents. You will use ls to display information about files and directories.
  • cd [dir] - Changes the current directory to dir. If you execute cd without specifying a directory, cd changes the current directory to your home directory. This is how you navigate around the system.
  • pwd - Displays the present working directory name. If you don't know what directory you are in, pwd will tell you.
  • cat [file] - Concatenates and displays files. This is the command you run to view the contents of a file.
  • echo [argument] - Displays arguments to the screen.
  • man command - Displays the online manual for command. Type q to quit viewing the manual page. The documentation provided by the man command is commonly called "man pages." exit, logout,
  • or Ctrl-d - Exits the shell or your current session.
  • clear - Clears the screen
Checkout our new blog on Linux Tutorial

Q15. Define Automatic processes?

Ans. Automatic or batch processes are not connected to a terminal. Rather, these are tasks that can be queued into a spooler area, where they wait to be executed on a FIFO (first-in, first-out) basis. Such tasks can be executed using one of two criteria:

  • At a certain date and time: done using the at command.
  • At times when the total system load is low enough to accept extra jobs: done using the batch command. By default, tasks are put in a queue where they wait to be executed until the system load is lower than 0.8. In large environments, the system administrator may prefer batch processing when large amounts of data have to be processed or when tasks demanding a lot of system resources have to be executed on an already loaded system. Batch processing is also used for optimizing system performance.

Linux Basic Interview Questions

Q16. Explain Linux Kernel? Is it possible and legal to edit Linux Kernel?

Ans. The low-level system software is referred to as the Linux kernel. It is mainly used to allocate resources and to provide a medium for the user interface.

Yes, it is possible as well as legal to edit Linux Kernel. Since Linux comes under the General Public License (General Public License), it can be edited and modified by the end-users. 

Q17. What is BASH?

Ans. BASH refers to Bourne Again SHell. It is a replacement of the initial Bourne shell represented by/bin/sh. And it is created by Steve Bourne. It is the better version of the previous and original bourne shell as it contains unique additional features that are easy to use. Later it got adopted as a default shell script for most of the systems operating Linux.

Q18. What is LILO?

Ans. LILO is a term given to Linux LOader. It loads the Linux Operating System into the system’s main memory for execution. Mostly all the computers come with inbuilt boot loaders in some of the versions of Mac OS or windows. For using Linux OS, a special boot loader needs to be installed in the system and one such boot loader is LILO. One of the major advantages of using this boot loader is that it can boot Linux OS really fast. 

Q19. Which are the common Shells that are used in Linux?

Ans. Some of the common Shells that are used in Linux are

  • BASH: Bourne Again Shell-  default shell for almost all the Linux operating systems
  • KSH: Korn Shell- high-level programming language shell
  • CSH: C Shell- shell with C like syntax that offers job control and spell check and correction functions
  • ZSH: Z Shell- It offers unique features like filename generation, login/logout functions, startup files, closing comments etc.
  • FISH: Friendly Interactive Shell- It offers unique such as web-based configuration, scripting and auto-suggestions.

Q20. Define is a swap space?

Ans. It is a space that temporarily stores concurrent executing programs in Linux. When RAM has a shortage of enough space to store the programs that are executing in a system, then swap space comes into action.

Q21. What are the advantages of using LINUX?

Ans. There are many reasons why LINUX is preferred over other operating systems. Some of them are listed below.

  • Being an open-source operating system, it provides the opportunity for the programmers to customize their own operating system
  • Software programs and server licenses that are needed to install Linux are available for free and can be installed on multiple systems.
  • It is comparatively more secure than other operating systems etc.
  • It is highly robust and scalable as it is compatible with most of the hardware and software programs and supports many file systems.

Checkout: [Linux System Administrator]

Q22. What is the root account in Linux?

Ans. It is the primary account similar to a system administrator that controls all the functioning in the system. It is a default account that gets loaded whenever the Linux is set up. Some of the functions performed by the root account are:

  • user accounts creation
  • user accounts maintenance
  • Allocating permissions for the new accounts created.

Q23. What are the advantages of using an open-source operating system?

Ans. In open-source, software including the source code is distributed without any cost to the end-users. People can customize the source code to customize and add features of their choice. They can even debug the source code if any error creeps in. The whole community can be benefited with enhanced features as the people can again distribute it freely after customizing it.

Q24. Differentiate BASH and DOS?

Ans. 

Sl. no.BASHBASH
1.Commands used for different functions are case-sensitive.Commands used for different functions are not case-sensitive.
2.(‘/’ forward slash) in BASH is used to separate directories. (” backslash) is used as an escape character.(‘/’ forward slash) in DOS is used as a command argument delimiter. (” backslash) is used as a directory separator.
3.A naming convention is followed in which 8 characters are fixed for file name postfixed with 3 characters for the extension.A naming convention is not followed

Q25. What is the importance of the GNU project?

Ans. GNU being a free software movement provides several advantages as it gives the flexibility to modify the programs according to their use and convenience. It is also allowed to redistribute the modified copies of the software for free and release it for the public to use it.

Q26. How can a command prompt be opened while writing a command?

Ans. The command prompt is found in the default shell and to open it Ctrl-Alt-F1 is pressed. This will start the command-line interface (CLI) from which commands can be entered and executed.

Q27. What is the preferred size of a swap partition in Linux?

Ans. Generally, the size of the swap partition is twice the size of the physical memory present in the system. If it is not possible to have this size, then the minimum required size for a swap partition is the amount of memory present in the system

Q28. Define Virtual Desktop?

Ans. This is a special feature which is very useful for the users who enhance the physical boundaries of a screen to a larger extent. With a virtual desktop, a virtual screen is created that can expand the normal screen of the system. A virtual desktop can be implemented by using 2 ways

Switching Desktops

With switching desktops, distinct virtual desktops can be created to run programs. Each virtual desktop acts as a separate desktop and programs executing on these desktops can only be accessed by the users who are using that particular virtual desktop 

Oversized Desktops

It does not provide distant desktops but lets the user scroll over a desktop that is expanded and is larger in size than the desktop having a normal physical screen. 

Q29. What are symbolic links in Linux?

Ans. Symbolic links are the same as shortcuts in Windows and they point to files or directories and programs. It provides instant access to the desired directories or files without going to the full pathname.

Q30. Explain daemons in Linux?

Ans. Daemons are those computer programs that run as a background process to execute those functions that are not there in the base Operating System. They are used to run the services in the background so that they can not be directly controlled by the end-users. They are also used to handle periodic requests so that these requests can be sent to the appropriate programs for implementation. 

Linux Admin Interview Questions

Q31. What are the commands to change permissions in Linux?

Ans. Only system administrators or file owners can grant or change the access permissions in Linux. Permissions are granted using the chmod command. + symbol is used to add permission and – symbol is used to deny permission, followed by any of these letters: u (user), o (others), g (group), an (all), r (read), w (write) and x (execute). For instance, the command chmod u+rw FILE23.TXT is used to grant read and write access to the file FILE23.TXT, which is assigned to users.

Q32. Write down the process states in Linux?

Ans. The process states in Linux are:

  • Ready: The process is ready for execution
  • Running: The process is in the execution state
  • Blocked or wait: Process is waiting for input or is blocked for execution from the user
  • Terminated or Completed: Process is successfully completed or was terminated due to some error by the Operating System
  • Zombie: The process is terminated by the system, but the information is still there in the process table.

Q33. What are the ways to access partitions under Linux?

Ans. In Linux, numbers are assigned as a suffix to the drive identifier. For instance, the first IDE hard drive had three primary partitions, will be written as name/number just like /dev/hda1, /dev/hda2, and /dev/hda3.

Q34. What is the use of the grep command in Linux?

Ans. Grep is the term used for Global Regular Expression Print. It is used to search for a text expression in a file by matching the patterns based on a regular expression.

It follows the following syntax

Syntax: grep [text options] pattern [filename]

For Example:

$ grep -c "shell script" inlinux.txt

This command will print the count of the word “shell script” in the “inlinux.txt” file.

Q35. What do hard links refer to in Linux?

Ans. Hard links are the links that point directly to the file and not to the pathname. It means even if the file is renamed or moved from one location to the other, the link will remain the same as the link is for the file and not for the path where the file is located.

Q36. What is Process Management System Calls in Linux?

Ans. Process management system calls are:

  • fork () – It is used for the creation of a new process
  • exec(): It is used for the execution of a new program
  • wait(): It is used to direct the system to wait until the process execution is finished
  • exit(): It is used to exit from the current process
  • System Calls that are used to get Process ID are:
  • getpid():- It is used to get the unique process id (pid) of the process
  • getppid():- It is used to get the unique id of the parent process

Q37. What is the role of the ‘ls’ command in Linux?

Ans. The ls command lists down all the files in a particular directory. The syntax for using this command is:

$ ls  

For instance: The command to list all the files in the tutorial directory will be as follows:

$ ls tutorial/

Different options can be used with the ls command to provide extra information about the file/folder from where information needs to be fetched. The options are:

  • l  Lists long format(displays the access permissions of the file)
  • a  lists all the files including hidden files
  • i  lists all the files along with their inode number
  • s  lists all the files along with their size
  • S  Lists all files with their respective size and sorts the list by the size of a file
  • t   sorts all the listed files by their date and time

Q38. What are filenames that are preceded by a dot?

Ans. Generally, all the hidden files are preceded by a dot. These files hold important or setup info as they can be configuration files. Keeping these files as hidden makes them secure from being accidentally deleted.

Also read: Features of UNIX/LINUX

Q39. What is the use of a redirection operator in Linux?

Ans. The redirection operator is used when there is a need to use the output of one command as an input to the other command or file. It is generally used in 2 ways

‘>’ – this operator overwrites the existing data in the file or makes a new file.

‘>>’ appends the new data at the end of the file or makes a new file. 

So in simple words, in this ‘>’ redirection operator, the data in the file is overwritten and in this ‘>>’ redirection operator, the data is appended.

Q40. Is it possible to execute more than 1 command from a single command line entry? If yes, how?

Ans. Yes, it is possible to execute several commands from a single command line entry by separating them using a semicolon symbol. For instance: Consider the example below in which a series of commands are issued from a single entry.

ls –l cd .. ls –an EXAMPLE of having 3 commands from the single line: ls -l cd.. ls -an EXAMPLE

Q41. What is the use of the tar command in Linux?

Ans. An archived file can be created or extracted by using the tar command in Linux. For instance: to extract all the files from the archive ‘example.tar.gz’, the following command will be used:

$ tar -xvzf example.tar.gz

To create an archive of all the file stored in /home/linux/, the following command can be used:

$ tar -xvzf filename.tar.gz

where c refers to create an archive, x refers to extract, v refers to verbose and f refers to file

Q42. How programs can be shared across different virtual desktops in Linux?

Ans. For sharing the programs across different virtual desktops, press the button in the upper left-hand corner of a window which appears to be a pushpin. It will "pin" that application thus making it visible at the same position on the physical screen in all virtual desktops.

Q43. What does Latch mean in Linux?

Ans. A Latch is a binary storage device that stores the file temporarily and is controlled by a timing signal with the value being either 0 or 1. It has two stable states. The high output state denotes 1 and a low output state denotes 0. If the power is on, it can store 1 bit of data. 

Q44. What does a nameless or empty directory signify in Linux?

Ans. In Linux, an empty directory acts as the nameless base of the file system. It serves as an attachment for all other files, directories, devices, and drives.

Q45. What is a Microprocessor?

Ans. It is a single-chip device that is used to execute commands. It fetches, decodes, and then decodes the instructions from the memory. The basic functions carried out by microprocessor are:

basic mathematical operations such as add, subtract, multiply, and divide

moving data from one place to another

decision making based on the conditions and then moving on to new instructions based on those decisions. 

Linux Interview Questions for Experienced

Q46. What does the pwd command do?

Ans. The pwd command refers to the print working directory. It displays the pathname of the directory which is currently in use.

For instance: If we will write the below command

Pwd

The following output will be generated:

/home/ajay12/myDir 

Q47. Explain Regular Expressions in Linux

Ans. Regular Expressions in Linux are used to search for options with specified patterns. Some commands used with regular expressions are sed, tr,vi and grep.

Some symbols used with Regular Expressions are:

.To match any character
$To match the end of the String 
^To match the beginning of the String
 It is used to depict special characters
*To match zero or more than one characters
? It is used to match exactly one character

Q48. How switching from one desktop environment to another can be done such as KDE to Gnome?

Ans. Considering that these two desktop environments are already installed, just log out from the current session through the user interface. Then again login from the login screen by entering the ID and password and choose the session type you wish to continue with. This will remain the default desktop environment until you change it to some other environment.

Q49. What is the effect of case sensitivity while using the commands?

Ans. Linux being a case sensitive language, it can alter the output if every character is not encoded as it is including the uppercase and lowercase letters. For instance- CD, cd, and Cd will produce different outputs as these are three different commands. If a command is written in lowercase where it should be in uppercase, it will generate different results.

Q50. How many disk partitions are required to install Linux?

Ans. Minimum 2 partitions are required to install Linux. In one partition, all the local files are stored including configuration files of the OS, application files and services along with user files. The second partition is used as Swap Space which is an extended memory for RAM in Linux. 

Q51. Define environmental variables?

Ans. Environmental variables are also known as global shell variables. They are global settings responsible for controlling the shell’s function along with other Linux programs.

Q52. How shortcuts can be created for long path names?

Ans. Shortcuts can be created by using a feature called filename expansion in which the TAB key is used for this purpose. The condition is that the pathname should be unique and the shell which is in use should support this feature. For instance, pathname /home/shell/example directory, will be written as follows: /ho[tab]/she[tab]/exa[tab].

Q53. List down the modes that are used while using vi editor?

Ans. Vi editor uses 3 modes for its functioning

  • Command mode – This is the mode from where the commands are initiated
  • Edit mode – This is the mode from where text editing is done
  • Ex mode – This is the mode where instructions are given to interact with Vi to process a file.

Q54. What does the Ctrl+Alt+Del key combination do in Linux?

Ans. It works similarly as in windows to restart a system. The only difference is that the reboot starts immediately in Linux after striking this key combination without giving any notification or confirmation message.

Q55. What does /usr/local directory stores?

Ans. This directory holds locally installed files and is mainly used in the environments where files are generally stored in a network. They are used for those software packages that are installed from the source or software that are not official to use. Local files normally go to /usr/local/bin, /usr/local/lib etc. kinds of directories in Linux.

Q56. List down some of the Linux distributors with its usage?

Ans.  Linux distributors are often called Distros. Different parts of LINUX such as the kernel, graphical programs, system environment etc. are developed and distributed by different organizations. Distros assemble these parts and compile them in an operating system that is ready to be installed in a system for use. There are more than six hundred Linux distributors in the market but some of the well-known distributors are

  • UBuntu: It is the most common Linux Distribution that comes with many pre-installed apps and repositories in its library. It is extremely user-friendly, easy to use, and works similarly to a MAC operating system.
  • Debian: It is the fast, stable, and user-friendly Linux Distribution.
  • Linux Mint: It is mostly used by those who are not used to Linux as it works on windows.
  • Fedora: It provides the latest version of Linux but is less stable as compared to other distributions. By default, it has the GNOME3 desktop environment.
  • Arch Linux: This is not suggested for beginners as every package needs to be installed by the users according to their requirements.
  • Red Hat Enterprise: It is a stable and durable distribution from Linux that is mostly used for commercial purposes and therefore needs to be tested rigorously before releasing it.

Q57. How comments can be inserted in the command line prompt?

Ans. Comments are always followed by a # symbol in Linux. From this symbol, shell understands that this is a comment and not a command. Shell completely ignores the content which is followed by # symbol. For instance "# Comment is followed by this symbol and not the command."

Q58. How memory usage can be tracked in LINUX?

Ans. It is important to determine the total memory used by different programs in Linux in order to analyze whether the resources and the server is being used adequately by the users or not. Below are some of the methods to find out the memory in use. 

Free command: Memory usage can be checked by this simple command. For instance, ‘$ free –m’, in this command’ displays all the data in MBs.

Vmstat: With this command, the memory usage statistics can be known. For instance, ‘$ vmstat –s’

/proc/meminfo: Memory in use can also be known by reading the file /proc/meminfo file. For instance,  ‘$ cat /proc/meminfo’

Top command: Total memory which is in use along with the RAM usage can be determined by using this command.

Htop: Memory usage along with other useful details can be displayed by using this command.

Q59. How can an ongoing process be terminated?

Ans. Every process has a unique id known as pid in Linux. Kill command followed by pid is used to terminate a process. To terminate all the processes in one go, kill 0 is followed by pid.

Q60. How does command grouping work in Linux?

Ans. Parentheses can be used to group commands in Linux. For instance, To send the recent date and time along with a file named EXAMPLE to a second file named GROUPING, command grouping can be applied by using this command (date cat EXAMPLE) >GROUPING

Linux Commands Interview Questions

Q61. What do you know about LINUX and elucidate the differences between Unix and Linux? 

Ans: Linux is referred to as one of the most common and popular operating systems that are designed with the Linux Kernel. The Linux operating system is an open-source operating system that is capable of running on multiple platforms. The primary focus of this operating system is to provide the users with a less expensive operating system and free operating system to utilize while working within the organization for multiple projects. The Linux Operating system is also called a user-friendly operating system. It provides the flexibility to users to modify things easily and enables the user to perform the creation of variations within the source code. 

Below are the significant differences between Linux and Unix: LINUX operating system is portable while the Unix operating system is not portable. LINUX operating system is an open-source operating system that is free of cost, and the users from the internet can download it by making use of the GNU license. In contrast, the Unix operating system is not free of cost. LINUX operating system makes use of the which also includes a command-line interface which is an optional thing. The Unix operating system controls only the command-line interface.

Q62. Briefly explain the different permission types available in Linux? 

Ans: There are three permission types that are available in Linux for each file or directory. They are: 

Read: This file permission type is used for reading the file. 

Write: This file permission type is used for writing the fine or for performing any modification to the file of a directory. 

Execute: This file permission is used to execute the file, which will affect the user's capability and view the directory's file.

Q63. Can you explain why Linux is more secure than any other operating system? 

Ans: Linux is more secure because of the following reasons: 

  • Linux is flexible and incompatible with providing the Limited default privileges to the users that will help in the restriction to the lower levels. Just in case if there is any file attack, then it will only affect the local files and folders and will save from the system-wide damage. 
  • Linux is also referred to as a powerful auditing system that will maintain the logs. 
  • Linux has enhanced features of IPtables that will help in maintaining security at a greater level. 

Q64. What do you know about CLI and BASH? 

Ans:

CLI: CLI refers to a command-line interpreter used for interacting between the different computer programs. It is usually represented in the form of text format. It is also responsible for allowing the users to add the text lines, which can be further converted into user-defined commands. 

BASH: BASH  is referred to as a Unix command, which is written by Brian Fox. Bash is also referred to as free software that is also the replacement for The Bourne shell. BASH allows the users to write the command and perform the related actions, even allowing the users to read the commands that are written in the form of Shell Scripts.

Q65. Briefly explain the features of the Linux operating system? 

Ans: There are different features available in the Linux operating system. They are explained below: 

Portable: LINUX operating system is designed in such a way that it can work on multiple types of hardware. The data is allowed to be carried in the pen drives and memory cards, allowing it to be included in the probability feature. 

Open source: The Linux operating system is a free, open-source operating system that is based on the community development project. 

Multiprogramming: LINUX operating system provides the feature of multiprogramming, allowing users to run multiple programs at the same time. 

Multi-user: the applications are allowed to be created and used by multiple users. In Linux, various users can use their RAM and run the programs at the same time. 

Security: Linux is flexible to provide data security by using the different forms of security policies or security features like authorization, authentication, and encryption.

Q66. What is meant by Linux kernel? 

Ans: Linux Kernel is referred to as a low-level system software with the primary responsibility of managing the user's resources. Linux Kernel is also responsible for providing an interface or a bridge for user-level interaction.

Q67. What do you know about LILO? 

Ans: LILO refers to Linux loader. Linux loader is referred to as the bootloader for Linux. The bootloader's primary responsibility for Linux is to mainly load the Linux operating system into the main memory so that it can start working on the operations.

Q68. Explain briefly about GUI? 

Ans: GUI refers to a graphical user interface that uses the images and Icon so that users can click and navigate checkout to communicate with the machine or a computer. The graphical elements make it easier to interact with the system instead of using the different commands and type the commands, which is more challenging for a human to remember. GUI will also improve the attraction through the icons, color, and images bringing up a good view.

Linux Tutorials

Q69. Give a brief idea about the Linux directory commands? 

Ans: Below is the list of commands of the Linux directory. 

pwd: This command is used for a print working directory. It is referred to as a built-in command that displays the current working location and the working path along with the full path of the directory. 

Is: This command is used for listing the files in the directory folder. 

cd: command is used for change directory, which is used for changing the directory from the present directory to the directory that you want to work. 

mkdir: This command is used for creating a new directory. 

rmdir: This Command is used explicitly for removing the directory from the system.

Q70. Briefly explain the cat command in Linux? 

Ans: The cat command in Linux is used for concatenating and printing the files. Users use this command to check the contents of the dependencies file and confirm the version of the application that they are built already locally.

Q71. What do you know about PIPE in Linux? 

Ans: A pipe in Linux is referred to as a form of redirection in Linux. The PIPE is specifically used for combining more than two commands, and the output of one command will be taken as input for the next command. 

Syntax: 

command_1 | command_2 | command_3 |command_4 | .... | command_N

Q72. Give a brief idea about the Chmod command? 

Ans: The Chmod command is responsible for changing the file permissions and directory permissions. The Chmod consists of three different types of permissions called to read, write, and execute. They are represented in numbers as below: 

4- read permission 

2- write permission 

1- execute permission

Q73. What are the different commands that are used to exit from VI editors? 

Ans: Two different commands can be used for getting the exit from the VI editors. 

wq: This command is used for exiting from the VI editor by saving the current work that you have done. 

q! : This command is used to exiting from the VI editor without saving the work you have done.

Q74. List different types of modes that are available when you are using the vi editor? 

Ans: There are three different modes of vi editors. They are: 

  1. Insertion mode or edit mode 
  2. Command mode or regular mode 
  3. Ex mode or replacement mode 

Q75. Briefly give an idea about the env command in Linux? 

Ans: The env command is referred to as a shell command that is used explicitly for printing the list of environment variables that run another process in another environment without performing any modifications of changes to the current environment. 

Syntax: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

Linux System Administrator Interview Questions

Q76. Is there a possibility to append one file to another file in Linux? 

Ans: Yes, there is a possibility to append one file to another file in Linux. The command that is used to append from one file to another file is cat file 2 >> file 1. The operator >> in the command is used for appending the output of the named file and is also capable of creating the file if there is no file already created. The other command that is stated below is also used to append two or more files to one. Command: cat file 1 > file 2 > file 3

Q77. What are the different ports that are used for SMTP, FTP, DHCP, SSH, and Squid? What are the commands that are used to check the ports that are there listening in the Linux server?

Ans: Below are the port numbers that are used for these services. 

  1. DNS - 53 
  2. SMTP - 25 
  3. DHCP - 68 
  4. FTP - 20 
  5. SSH - 22 
  6. Squid - 3128

The two commands that are used for checking if the 4th and listening in the Linux server are: 

netstat -l 

netstat --listen

Q78. What are environment variables? 

Ans: Environment variables are referred to as the global settings that will help control the cell's function and the other Linux programs. The environment variables are also called the Global shell variables.

Q79. List out the basic components of the Linux architecture? 

Ans: Below is a list of the basic components of the light next architecture. 

Kernel: Kernel is referred to as one of the most essential core components in the Linux operating system. It is referred to as an interface or a bridge between the software and hardware components. 

Shell: Shell in Linux is also referred to as an interface between the parallel operating system and the users. 

GUI: GUI refers to the graphical user interface used to establish the interaction with the system. 

System Utilities: The system utilities are referred to as a software function responsible for allowing the users to manage the computer. 

Application programs: Application programs here refer to the set of tasks that are specifically designed to perform the set of tasks or operations. 

Q80. Give a brief idea about swap space? 

Ans: The swap space is referred to as a space that is allocated and used when we need actually to run the physical memory. Describe space is responsible for helping users move the inactive pages in their RAM to the swap space. The swap space is available in two different forms called partitions and swap files.

Q81. What do you know about Hard links? 

Ans: The hard links are used to directly point to the physical file on the desk but not on the pathname. Let us take an example and think that if you move the original file or remove the same, there will be no breaking of hard links as the link itself is used as a file, not the pathname, where the file will be stored in the directory.

Q82. Does the Control + alt + delete key combination work on Linux? 

Ans: Yes, the Control + alt + delete combination works on Linux, and it can be perfectly used to restart the system.

Q83. Briefly describe daemons? 

Ans: Daemons are usually referred to as a kind of service that will offer the different functionalities which we cannot find under the basic operating system. It includes the main tasks like listening for a service request and then performing an action on these requests. Once the service is completed, it will disconnect itself and wait for the next request that will be coming up.

Q84. Know about inode and process ID? 

Ans: The inode is referred to as a unique name given to any file or directory. The process ID is referred to as a unique name given to each process that is created.

Q85. Briefly give an idea about zombies? 

Ans: Zombie is referred to the process state in which the child dies before the parent process dies. In this situation or scenario, the process's structural information will still exist in the process table. As a Process is dead, it will not react to any signals. The kernel is responsible for clearing the resources of the Zombie state processes.

Q86. Briefly explain the differences between Bash and DOS? 

Ans:

BASH: The Bash command is referred to as a case-sensitive command. Bash command does not follow any convention. Under the dash command, the characters are the directory separator and acts as an escape character. 

DOS: DOS command is not Case sensitive command, and it follows a naming convention. Under those characters are referred to as the command argument delimiter.

Q87. Give a brief idea about symbolic links?

Ans: The symbolic links In Linux are referred to as the shortcuts used in windows. The symbolic link will be pointing to the codes, files, programs, or directories and will also allow direct instant access to the entire pathnames.

Q88. What do you mean by virtual desktop? 

Ans: A virtual Desktop usually refers to the alternative service used to minimize and maximize the multiple windows on the currently running desktop. The primary purpose of using the virtual desktop is for clearing and running one or more programs at one time. The virtual desktop will allow the users to perform the shifting between the desktop rather than minimizing; they are restoring the programs. 

Q89. List out the different process states in Linux? 

Ans: Below is a list of the different process states in Linux. 

  1. New or ready process 
  2. Running process 
  3. Blocked or wait for the process 
  4. terminated or completed the process 
  5. Zombie process 

Q90. Briefly explain the different file permission groups available in Linux? 

Ans: There are three types of file permission groups available based on each file or directory. They are: 

  1. Owner: The owner will generally have permission to access the file or directory; however, it will not impact any action of the Other groups. 
  2. Group: The Group file permission will be assigned to the groups that are assigned to the directory for a file. 
  3. All users: All user's file permission is applied to the users that are using this system.

Top 50 Linux Interview Questions and Answers

 1. What is Linux?

Linux is an open-source operating system kernel that acts as an interface between the hardware and user applications.

2. What is the root account in Linux?

The root account is the superuser account with administrative privileges that has control over all aspects of the system.

3. How do you change permissions in Linux?

The chmod command is used to change file permissions. For example, chmod 755 filename grants read, write, and execute permissions to the owner and read and execute permissions to others.

4. What is the purpose of the 'ls' command?

The ls command is used to list files and directories in a directory.

5. How do you search for a specific string in a file?

The grep command is used to search for a specific string in a file. For example, grep "pattern" filename.

6. Explain the difference between a process and a thread.

A process is an independent program with its own memory space, while a thread is a lightweight unit within a process that shares the same memory space.

7. How do you find out the IP address of a Linux system?

The ifconfig command can be used to find the IP address of a Linux system.

8. What is the purpose of the 'ps' command?

The ps command is used to display information about currently running processes.

9. How can you kill a process in Linux?

The kill command can be used to terminate a process. For example, kill PID where PID is the process ID.

10. Explain the role of the 'init' process.

The init process is the first process started by the Linux kernel during boot-up. It initializes the system and starts other processes.

11. What is the purpose of the 'df' command?

The df command displays information about the disk space usage of filesystems.

12. How do you archive files using the 'tar' command?

The tar command is used to create or extract archives. For example, to create an archive: tar -cvf archive.tar files.

13. What is a symbolic link in Linux?

A symbolic link, also known as a symlink, is a reference to another file or directory in the filesystem.

14. Explain the significance of the '/etc/passwd' file.

The /etc/passwd file stores user account information, including usernames, user IDs, home directories, and default shells.

15. How do you check the memory usage of a Linux system?

The free command displays information about the system's memory usage.

16. What is a shell in Linux? A shell is a command-line interface that allows users to interact with the operating system.

17. How do you change the default shell for a user?

The chsh command is used to change the default shell for a user. For example, chsh -s /bin/bash username.

18. Explain the use of the 'find' command.

The find command is used to search for files and directories based on various criteria.

19. What is SSH? How do you use it to connect to a remote server?

SSH (Secure Shell) is a cryptographic network protocol for secure remote access. To connect to a remote server: ssh username@hostname.

20. How can you check the status of a service in Linux?

The systemctl command is used to manage services. For example, to check the status of a service: systemctl status service_name.

21. Explain the purpose of the '/etc/fstab' file.

The /etc/fstab file is used to configure filesystems and partitions to be mounted at boot time.

22. How do you add a new user in Linux?

The useradd command is used to add a new user. For example, useradd newusername.

23. What is the purpose of the 'grep' command?

The grep command is used to search for specific patterns within text files.

24. How do you check the available disk space on a Linux system?

The df command is used to display information about filesystem disk space usage.

25. Explain the difference between soft links and hard links.

A soft link (symbolic link) is a reference to a file or directory by name. A hard link is a reference to the inode of a file, creating multiple directory entries for the same data.

26. How can you change file permissions in numeric mode?

In numeric mode, file permissions are represented as a three-digit number. For example, chmod 644 filename grants read and write permissions to the owner and read permissions to others.

27. What is the purpose of the 'crontab' command?

The crontab command is used to create, edit, or manage cron jobs, which are scheduled tasks that run at specified intervals.

28. How do you change the hostname of a Linux system?

To change the hostname temporarily, you can use the hostname command. To change it permanently, modify the /etc/hostname file.

29. Explain the use of the 'du' command.

The du command is used to estimate the space usage of directories and files.

30. What is a package manager in Linux?

A package manager is a tool that helps users install, update, and manage software packages.

31. How do you install software in Debian-based distributions?

In Debian-based distributions like Ubuntu, you can use the apt package manager. For example, sudo apt-get install package_name.

32. What is the purpose of the 'top' command?

The top command displays real-time information about running processes and system resource usage.

33. How do you kill a process that is not responding?

You can use the kill command with the -9 option to forcefully terminate a process. For example, kill -9 PID.

34. Explain the role of the 'cron' daemon.

The cron daemon is responsible for executing scheduled tasks (cron jobs) at specified times.

35. How do you list the contents of a directory in long format?

The ls command with the -l option displays the contents of a directory in long format, showing detailed information about files and directories.

36. What is the purpose of the 'umask' command?

The umask command sets the default permissions for newly created files and directories.

37. How can you find out the size of a directory?

You can use the du command with the -h option to display the size of a directory in a human-readable format.

38. What is the purpose of the 'mount' command?

The mount command is used to attach a filesystem to a specific directory, making its contents accessible.

39. How do you create a backup of a directory in Linux?

The tar command is commonly used to create backups. For example, to create a backup: tar -cvzf backup.tar.gz directory.

40. Explain the use of the 'sed' command.

The sed command is used for text stream processing, such as finding and replacing text within files.

41. How can you check the network connectivity using the 'ping' command?

The ping command sends ICMP echo requests to a host to check if it's reachable. For example, ping hostname.

42. What is the purpose of the 'usermod' command?

The usermod command is used to modify user account properties, such as username, group, and home directory.

43. How do you display the last few lines of a file using the 'tail' command?

The tail command displays the last few lines of a file. For example, tail -n 10 filename displays the last 10 lines.

44. Explain the use of the 'rsync' command.

The rsync command is used for efficient file synchronization and transfer between systems.

45. What is the role of the 'swap space' in Linux?

Swap space is a portion of the disk used as virtual memory when physical memory (RAM) is fully utilized.

46. How can you check the system's uptime using the 'uptime' command?

The uptime command displays the system's uptime, load average, and number of logged-in users.

47. What is the purpose of the 'chown' command?

The chown command is used to change the ownership of files and directories. For example, chown newowner filename.

48. How do you create an archive with compression using the 'tar' command?

You can use the tar command with compression options. For example, tar -cvzf archive.tar.gz files.

49. Explain the use of the 'ln' command.

The ln command is used to create hard or symbolic links between files.

50. How do you find information about a command using the 'man' command?

The man command displays the manual pages for a given command. For example, man ls shows the manual for the 'ls' command.

Top 30 Linux Interview Questions and Answers

Question 1. How many primary components does Linux system have?

Answer. Linux system primarily has three components namely Kernel, System Libraries, and System Utility.

 

Question 2. What service that acts as both an FTP and web server should be disabled on a Linux server?

Answer. The one service that should be disabled on a Linux server is finger service.

 

Question 3. Explain LILO.

Answer. LILO or Linus Loader is a Linux boot loader. Its purpose is to facilitate loading of Linux into the memory and starting the OS. It is customisable an is a code snippet.

 

Question 4. What tasks are handled by LILO?

Answer. LILO is in charge of handling many tasks including

  • Starting the kernel
  • Locating Linux kernel
  • Identifying & loading other supporting programs

 

Question 5. Explain LD_LIBRARY_PATH.

Answer. An environment variable, LD_LIBRARY_PATH is employed to debug a non-standard or a new library. You can also use it to search for new directories but the path needs to be specified.

 

Question 6. Where are the sar logs stored?

Answer. The sar logs are stored at /var/log/sa/sadd file by default.

 

Question 7. Can the size of the LVM partition reduced or shrunk?

Answer. Yes, LVM partition size can be reduced by following the below steps -

  • Use the ‘unmount’ command to unmount the file system
  • Use the ‘resize2fs’ command
  • Use the ‘Ivreduce’ command

 

Question 8. Name the modes used in Network Bonding.

Answer. Following are the modes used in Network Bonding –

  • Balance-rr or 0
  • Active-backup or 1
  • Balance-xor or 2
  • Broadcast or 3
  • 802.3ad or 4
  • Balance-tlb or 5
  • Balance-alb or 6

 

Question 9. How many different kinds of Linux user modes are present?

Answer. Linus user modes are of two types namely GUI (Graphical User Interface) and Command Line.

 

Question 10. What provides better security – Linux or Windows?

Answer. Linux provides better security than Windows.

 

Question 11. How will you install RPM packages in Linux?

Answer. The ‘yum’ and ‘rpm’ command is used to install RPM packages in Linux?

 

Question 12. Can the IP address of a Lan Card be checked?

Answer. Yes, you can check the IP address of a Land Card by using ‘ip address’ and ‘ifconfig’ commands.

 

Question 13. Explain Initrd.

Answer. Short of Initial Ram Disk, Initrd is the storehouse for temporary root filesystem as well as important modules that facilitate in mounting the original root filesystem in read only mode.

 

Question 14. Tell us Soft Link is one line.

Answer. Soft link is a method employed for creating shortcuts in Linux. There are a few similarities between soft link and Window’s short cut feature.

 

Question 15. How can the password of a user be changed from the command line?

Answer. The password of a user can be changed from the command line with ‘passwrd ’.

 

Question 16. Tell us about SELinux.

Answer. Abbreviation for Security-enhanced Linux, it is a security and an access control implementation feature for Linux kernels. Its purpose is to save the server against compromised daemons and misconfigurations.

 

Question 17. How can the hostname of a Linux box be determined?

Answer. The hostname of a Linux box can be determined by typing the ‘hostname’ command on the terminal.

 

Question 18. Tell us about Bootloader.

Answer. It is a program used for booting the OS and helps in determining that from which kernel the OS will be booted.

 

Question 19. What are run levels and how many are there?

Answer. Run levels are a state of init as well as the whole system that explains the operating system services. These are identified by numbers and there are seven different run levels.

 

Question 20. How can we determine the version of the red hat?

Answer. The version of the red hat can be determined by using the ‘cat /etc/Redhat-release’ version.

 

Question 21. Tell us about the storage cluster.

Answer. When multiple computers are combined to perform certain tasks, it is referred to as storage cluster. Some of the major clusters include load balancing, storage, high performance and high availability, including others. It makes the servers better.

 

Question 22. Which web pages are used while serving web pages while installing Apache?

Answer. While installing Apache, by default the web server Port 80 and hence, it is the most commonly used web server as well. While another port can be used, it will have to be typed into a browser first.

 

Question 23. Explain the load balancing cluster?

Answer. As can be guessed from the name, a load balancing cluster is used in balancing the load across the cluster nodes. When a cluster dispatches a service request to another cluster node, it gets activated. The collapse of a node is not visible outside the cluster.

The load balancing cluster offers highly inexpensive scalability since many nodes can be configured simultaneously.

 

Question 24. What does LVM stand for?

Answer. LVM stands for Logical Volume Mangere. It gives way to PV (Physical Volume), which is then combined with VG (Volume Groups) that is then divided into LV (Logical Volumes).

 

Question 25. What is the ‘parted’ command?

Answer. The ‘parted’ command is used to manage clear and easy disk partitions in the hard disk. This helps highly in extending, shrinking, adding and deleting hard disk partitions as well as file systems.

 

Question 26. What are the Unix states?

Answer. The four states in Unix are waiting, running, stopped and zombie.

 

Question 27. What is umask?

Answer. Abbreviation for user file creation mask, it is used in determining the setting of a mask that further manages which file permissions for directories and files upon their creation.

 

Question 28. What is network bonding?

Answer. The aggregation of various Ian cards together into a single bonded interface for the purpose of providing high performance and fault tolerance is known as network bonding. It is also referred to as NIC Teaming.

 

Question 29. How can you permanently set the umask for a user?

Answer. In order to permanently set the umask for a user, we need to put in the right profile file that highly depends on the default shell of a particular user.

 

Question 30. How can default route and routing table be checked?

Answer. In order to check the default route and the routing table, commands such as ‘route-n’, ‘ip route show’ and ‘netstat-nr’ can be used.

Important Linux Interview Questions and Answers

 

1. Define Linux?

Linux is an operating system based on UNIX and Linux Kernel it can run on various hardware stage built by Intel, MIPS, HP, IBM, SPARC and Motorola. It was first established by Linus Torvalds and its Mark able element is its mascot, a penguin figure named Tux.

2. What is the Difference between Linux and UNIX?

The difference between Linux and UNIX are: UNIX began as a propriety operating system from Bell Laboratories, which later included into various commercial versions but Linux is free, open source and deliberate as a non-propriety operating system for the masses.

3. What is LILO?

LILO is a boot loader for Linux. It is specially used to load the Linux operating system into main memory so that it can begin its operations.

4. What are basic components of Linux?

The basic Linux components are: kernel, shells and GUIs, system utilities, and application program. What makes Linux advantageous over other operating system is that every aspect comes with additional features and all codes for these are downloadable for free.

5. In Linux, what names are assigned to the different serial port?

Serial ports are identified as /dev/ttyS0 to /dev/ttyS7. These are the equivalent names of COM1 to COM8 in Windows.

6. What are the contents in usr/local?

It contains locally installed files. This directory actually matters in environments where files are stored on the network. Specifically, locally-installed files go to /usr/local/bin, /usr/local/lib, etc.). Another application of this directory is that it is used for software packages installed from source, or software not officially shipped with the distribution.

7. What are the different Modes when using vi editor?

There are 3 modes under vi:
  • Command mode – the mode where you start in.
  • Edit mode – the mode that permit you to do text editing.
  • Ex mode – the mode wherein you interact with vi with instructions to process a file.

    8. What is redirection?

    Redirection is the procedure of directing data from one output to another. It can also be used to direct an output as an input to another process.

    9. What is grep command?

    Grep a search command that makes use of pattern-based searching. It makes use of options and parameters that is specified along the command line and applies this pattern into searching the required file output.

    10. How to enable ACLs foe /home partition?

    Add following entry in /etc/fstab
      LABEL=/home /home ext3 acl 1 2
      Now remount /home partition with acl option.
      mount -t ext3 -o acl /dev/sda3 /home