Linux basics Interview Questions And Answers


Just like Windows, iOS and Mac OS, Linux is an operating system that manages all the hardware resources associated with your desktop or laptop. Linus Torvalds released it on 17-sep-1991. To put it in simple words, Linux manages the communication between your software and your hardware.

Linux is distributed under open source licence meaning the users have the freedom to run, study, distribute, modify and redistribute modified versions to others.

Linux has a number of different versions to suit any type of user and match his needs. These versions (also known as distributions or distros) can be downloaded for free and burnt onto disk/ USB thumb drives, and installed on as many machines as you like. 

Versions

Popular versions include:

  • LINUX MINT
  • MANJARO
  • DEBIAN
  • UBUNTU
  • ANTERGOS
  • SOLUS
  • FEDORA
  • ELEMENTARY OS
  • OPENSUSE

Each distribution has a different take on the system. For example, you may opt for modern user interfaces such as GNOME, whereas others may prefer traditional ones like openSUSE uses KDE. The freedom to use and the variety of versions (to choose from) make Linux one of the most popular OS. 

Components of Linux OS 

The Linux OS consists of the following parts:

  • Bootloader: It is software that manages the boot process of your computer. 
  • Kernel: It is the core of Linux that manages the system and manages the CPU, memory, and peripheral devices. You can say that the kernel is the lowest level of the OS.
  • Init system: It is a sub-system that bootstraps the user space and controls daemons. The Init system manages the boot process once initial booting is handed over by the Bootloader.
  • Daemons: These are the background services like scheduling that either start during boot or after you log into the desktop. 
  • Graphical server: This is the sub-system that displays graphics on the monitor, usually referred to as X or X server.
  • Desktop environment: Users interact with Desktop environments. He may choose from a variety of Desktop environments like GNOME, Cinnamon and more as per his needs. Each Desktop environment includes built-in applications like file managers, configuration tools, web browsers and games. 
  • Applications: The desktop environment doesn’t offer an array of apps, but you can easily find and install thousands of high-quality software titles.

Linux OS is your solution if you are looking for reliable, secure, and dependable platforms for both the desktop and the server. Here are some top-searched Linux interview questions and answers that you may be interested in! 

1 . What is Linux?

Linux is an operating system or a kernel distributed under an open-source licence. 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.

2 . What is the difference between UNIX and LINUX?

Unix originally began as a proprietary 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-proprietary operating system for the masses.

3 . What is BASH?

BASH is short for Bourne Again SHell. It was written by Steve Bourne as a replacement to the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. Also, it has since been adapted as the default shell for most systems running Linux.

4 . What is Linux Kernel?

The Linux Kernel is a low-level systems software whose main role is to manage hardware resources for the user. It is also provides an interface for user-level interaction.

5 . What is LILO?

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

6 . What is a swap space?

Swap space is a certain amount of space that Linux uses 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.

7 . What is the advantage of open source?

Open source allows you to distribute your software, including source codes freely to anyone who shows interest. 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.

8 . What are the basic components of Linux?

Just like any other typical operating system, Linux has all of these components: kernel, shells and GUIs, system utilities, and an application program. What makes Linux advantageous over other operating systems is that every aspect comes with additional features and all codes for these are downloadable for free.

9 . Does it help for a Linux system to have multiple desktop environments installed?

In general, one desktop environment, like KDE or Gnome, is good enough to operate without issues. It’s all a matter of preference for the user, although the system allows switching from one environment to another. Some programs will work in one environment and not work in the other, so it could also be considered a factor in selecting which environment to use.

10 . What is the basic difference between BASH and DOS?

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 that you should follow by a dot and 3 characters for the extension. BASH follows no such convention.

11 . 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.

12 . Describe the root account.

The root account is like a systems administrator account and allows you full control of the system. Here you can create and maintain user accounts, assigning different permissions for each account. It is the default account every time you install Linux.

13 . What is CLI?

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.

14 . What is GUI?

GUI, or Graphical User Interface, makes 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.

15 . How do you open a command prompt when issuing a command?

To open the default shell, press Ctrl-Alt-F1. This will provide a command line interface (CLI) from which you can run commands as needed.

16 . How can you find out how much memory Linux is using?

From a command shell, use the “concatenate” command: cat /proc/meminfo for memory usage information. You should see a line starting something like Mem: 64655360, etc. This is the total memory Linux thinks it has available to use.

You can also use commands

  • free – m
  • vmstat
  • top
  • htop

to find current memory usage

17 . What is a typical size for a swap partition under a Linux system?

The preferred size for a swap partition is twice the amount of physical memory available on the system. If this is not possible, then the minimum size should be the same as the amount of memory installed.

18 . What are symbolic links?

Symbolic links act similarly to shortcuts in Windows. Such links point to programs, files or directories. It also allows you instant access to it without having to go directly to the entire pathname.

19 . Does the Ctrl+Alt+Del key combination work on Linux?

Yes, it does. Just like Windows, you can use this key combination to perform a system restart. One difference is that you won’t be getting any confirmation message and therefore, a reboot is immediate.

20 . How do you refer to the parallel port where you connect devices such as printers?

Whereas under Windows you refer to the parallel port as the LPT port, under Linux you refer to it as /dev/lp . LPT1, LPT2 and LPT3 would therefore be popular as /dev/lp0, /dev/lp1, or /dev/lp2 under Linux.

21 . Which are the Shells that you use in Linux?

The most common Shells used in Linux are

  • bash: Bourne Again Shell is the default for most of the Linux distributions
  • ksh: Korn Shell is a high-level programming language shell
  • csh: C Shell follows C like syntax and provides spelling correction and Job Control
  • zsh: Z Shell provides some unique features such as filename generation, startup files, login/logout watching, closing comments etc.
  • fish: Friendly Interactive Shell provides some special features like web-based configuration, auto-suggestions, fully scriptable with clean scripts

22 . What are inode and process id?

inode is the unique name thatOS gives to each file. Similarly, process id is the unique id for each process.

23 . Which are the Linux Directory Commands?

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>

24 . What is Virtual Desktop?

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 through which you can implement Virtual Desktop:

  1. Switching Desktops
  2. 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.

25 . Which are the different modes of vi editor?

There are 3 modes of vi editor:

  1. Regular/Command mode: Lets you view the content
  2. Insertion/edit mode: Lets you delete or insert content
  3. Replacement mode: Lets you overwrite content

26 . 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 usually works to run services in the background without directly being in control of interactive users. The purpose of Daemons is to handle periodic requests and then forward the requests to appropriate programs for execution.

27 . What are the process states in Linux?

The process states are as follows:

  • Ready: The process is created and is ready to run
  • Running: The process executes
  • Blocked or wait: Process is waiting for input from the user
  • Terminated or Completed: Process completed execution, or was terminated by the Operating System
  • Zombie: Process terminated, but the information still exists in the process table.

28 . Explain grep command.

Grep stands for Global Regular Expression Print. The grep command works to search for a text in a file by pattern matching based on regular expression.

Syntax: grep [options] pattern [files]

Example:

$ grep -c "linux" interview.txt

This command will print the count of the word “linux” in the “interview.txt” file.

29 . Explain Process Management System Calls in Linux

The System Calls to manage the process are:

  • fork () : Used to create a new process
  • exec() : Execute a new program
  • wait() : Wait until the process finishes execution
  • exit() : Exit from the process

And the System Calls used to get Process ID are:

  • getpid():- get the unique process id of the process
  • getppid():- get the parent process unique id

30 . Why is the tar command used?

The tar command is used to extract or create an archived file.

Suppose you want to extract all the files from the archive named sample.tar.gz, then the command will be:

$ tar -xvzf sample.tar.gz

Suppose you want to create an archive of all the files stored in the path /home/linux/, then the command will be:

$ tar -cvzf filename.tar.gz

where c: create archive, x: extract, v: verbose, f: file

31 . What is a Latch?

Latch is a temporary storage device controlled by a timing signal which can either store 0 or 1. A Latch has two stable states (high-output or 1, and low-output or 0) and is mainly used to store state information. A Latch can store one bit of data as long as it is powered on.

32 . What is a Microprocessor?

A Microprocessor is a device that executes instructions. It is a single-chip device that fetches the instruction from the memory, decodes it and executes it. A Microprocessor can carry out 3 basic functions:

  1. Mathematical operations like addition, subtraction, multiplication, and division
  2. Move data from one memory location to another
  3. Make decisions based on conditions and jump to new different instructions based on the decision. 

33 . How do you create a new user without logging on as a root user?

Using the su command.

34 . What is the minimum number of partitions that you need to install Linux?

Minimum two partitions are needed for installing Linux.

35 . Which command would you use to create a file system on a new hard drive?

The mkfs command

36 . Which command is used to review boot messages?

The dmesg command is used for reviewing boot messages.

37 . Which file is used to automatically mount file systems?

Fstab file will automatically mount file systems.

38 . What is the difference between internal and external commands?

Internal commands are those that are already loaded in the system. External commands are those which can be executed at any time and are independent.

39 . What is the difference between the home directory and the working directory?

The home directory is the default working directory when a user logs in.

The working directory is the user’s current directory.

40 . How can you check the memory status?

free -m to display output in MegaByte

41 . Explain how to uninstall the libraries in Linux?

By using the command, sudo apt-get remove library_name

42 . Which command is used to delete a group?

The groupdel command deletes a group.

43 . How do you terminate an ongoing process?

Use the kill command followed by the pid in order to terminate that process. To terminate all processes at once, use kill 0.

44 . What are File Permission groups in Linux?

Following are three user based permission groups for each file and directory:

  • Owner
  • Group
  • All Users

45 . What is the procedure to set the umask permanently for a user?

If the umask command is used without any arguments, it means it will display the current mask. Ocotal representation and Symbolic representation. are two types to set the umask permanently.

46 . What is the procedure to convert the default run level in Linux?

To convert the default run level in Linux, we can use the init command.

47 . Does the Alt+Ctrl+Del key combination work in Linux?

Yes, it works like windows.

48 . What are the hard links?

A hard link is another name for an existing file on Linux. We can create so many numbers of hard links, for any file. They can create links for other hard links.

49 . What is redirection?

Redirection can be defined as changing the standard input and output devices. To redirect metacharacters are used, you can redirect the file or program.

50 . What is network bonding in Linux?

Network Bonding is a process of combining more than two network interfaces to form a single network interface. It offers performance improvement and redundancy by increasing network throughput and bandwidth.

No need to worry if one interface is down or unplugged because the other will work. The behavior of the bonded interface depends on the bonding method.