Top 45+ Practice Linux Interview Questions [ANSWERED] in 2020
Linux Interview Questions and Answers

Top 45+ Practice Linux Interview Questions [ANSWERED]

Last updated on 28th May 2020, Blog, Interview Questions

About author

Kannan (Sr Linux Administrator, Mind Tree )

He is Possessing 8+ Years Of Experience in Linux. His Passion lies in Developing Entrepreneurs & Activities. Also, Rendered his intelligence to the Enthusiastic JOB Seekers.

(5.0) | 15876 Ratings 4544

Linux is best-known as a community-developed operating system that is freely distributable and is built around Linux Kernel for computers, servers, mainframes, mobile devices, and embedded devices. It is supported on almost every major computer platform, including x86, ARM, and SPARC, making it one of the most widely supported operating systems.

Here, we have compiled a list of top Linux interview questions that you must know if your potential job opportunity covers Linux in any way.

1. What are Linux and its basic components?

Ans:

  Linux is a free and open source Operating system that is based on the Linux kernel. It’s one of the widely used operating systems, especially in the server world and by developers. Its usage extends from hosting websites and applications to being the core operating system in smart devices like smartphones, tablets, and TVs.

Linux constitutes 4 basic components:

  • Kernel: This is the core of the Linux system. It’s responsible for interacting with the hardware components and ensuring the operating system communicates with hardware devices.
  • Shell: A shell is an interface between the Linux user and the kernel. It’s in the shell that commands are issued by the user and are thereafter executed by the operating system.
  • System libraries: These are special programs or functions which are responsible for implementing a majority of the functionalities of the operating system without relying on the kernel modules’ code access rights.
  • System Utilities: These are specific programs that executed certain tasks. e.g LibreOffice, Brasero, Gparted.

2. What is the Linux Kernel?

Ans:

A Linux kernel is the core of the Linux system. It interfaces the underlying hardware with the operating system.

3. What is the difference between Linux and Unix?  

Ans:

Linux is a clone of the UNIX system from which Linux is derived from. While Linux is open source and free to use, UNIX is a proprietary operating system.

4. What are inodes in Linux? 

Ans:

The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. When a file is created, it is assigned both a name and an inode number, which is an integer that is unique within the file system.

5. Explain ‘swap space’.

Ans:

 “Swap space” is just a temporary amount of memory space on Linux that is created to allow a certain program to run smoothly. Once the program has finished running, the swap space is also no more.

6. Please explain the various modes when using the vi editor.

Ans:

The vi editor offers 3 modes:

  •  Command Mode: This is the mode where the user starts.
  • Edit Mode: This mode allows the text editing.
  • Ex Mode: This mode allows interacting with vi, allowing executing instructions to process a file.

7. What Are Pipes?

Ans:

A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX shell has a special syntax for creation of pipelines. The commands are written in sequence separated by |. Different filters are used for Pipes like AWK, GREP.

e.g. sort file | lpr ( sort the file and send it to the printer).

8. What Is Bash Shell?

Ans:

 Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and Korn shell features. Bash shell is not portable. any Bash-specific feature will not function on a system using the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script begins with #!/bin/bash. It supports regular and expressions. When bash script starts, it executes commands of different scripts.

9. Can we terminate an ongoing process in LINUX?

Ans:

Yes, we can terminate an ongoing process in LINUX by using the Kill command, which is followed by the pid to terminate the particular process. The use of Kill 0 can be made to terminate all processes.

10. What do you mean by hard links in Linux?

Ans:

Hard links in Linux point directly to the physical file present on the disk. It doesn’t concern the pathname. It simply means that in case the file is renamed or moved to some other location, the link will not break and will still function like before.

11. Please explain how you will run a Linux program in the background together with starting the Linux Server.

Ans:

You need to use the nohup command first. It will stop the process receiving the NOHUP signal. The termination will log you out of the program that was invoked. Then start the Linux server, and enter the name of the Linux program followed by the & symbol to run the process in the background.

12. What is LILO in LINUX?

Ans:

  LILO is a name given to the boot load in the LINUX. Its function is to load the LINUX operating system into the main memory so that the operating system can be initiated.

13. What are the advantages of an open-source?

Ans:

There are various advantages of an open-source which includes:

  • It helps in distributing the software carrying its source codes freely to the users.
  • It supports the users to add new features, debug, and correct errors in the  source  code.
  • It helps in redistributing the new, improved source code back again free of cost to other users.

    Subscribe For Free Demo

    14. What are the differences between the BASH and DOS commands?

    Ans:

    There are several differences between the BASH and DOS commands, which include the following:

    15. What are the advantages of the GNU project?

    Ans:

    The GNU project is a free software that offers various advantages as follows.

    • It offers the freedom to run the programs for any purpose.
    • It helps in studying and modifying the program as per the user needs.
    • It allows the redistribution of copies of the software to people.
    • It helps in improving the software.
    • It supports the release of the software to the public.

    16. What is a Root Account?

    Ans:

     A Root Account is a system administrator account which helps in applying complete control over the system. It helps in creating and maintaining various user accounts and thereby assign them different kinds of permissions as per each account. It occurs by default whenever LINUX is installed.

    17. Explain CLI?

    Ans:

     CLI is an interface that allows the users to type various kinds of declarative commands which are meant to instruct the computer so that it could perform its particular functions. It offers greater flexibility to the users.

    18. How can we open a command prompt in LINUX?

    Ans:

    We can open the command prompt when issuing a command by pressing Ctrl+Alt+F1. It will help in providing a Command Line Interface (CLI) where the commands can be run as per the needs.

    19. Can we find how much memory LINUX is using?

    Ans:

    Yes, we can find how much memory LINUX is using. It can be done by applying a command shell, namely “Concatenate” command by applying cat/proc/meminfo. This will help in the display of memory usage. The outcome is in the form of Mem:12345678 etc. This outcome is the memory that LINUX has to offer you as available for usage.

    20. How does Ctrl+Alt+Del key combination work in LINUX?

    Ans:

     The Ctrl+Alt+Del key combination works in LINUX, just like it works in Windows. This key combination helps in restarting the system. However, in LINUX, there is no confirmation message displayed earlier to the restart, and the reboot occurs immediately.

    21. How can we refer to the parallel ports in LINUX?

    Ans:

    The parallel ports include the printers, scanners, and various other electronic devices attached to the computer system. In Linux, these parallel ports are referred to as /dev/lp0 for LPT1, /dev/lp1 for LPT2, and so on.

    22. Define Redirection in LINUX?

    Ans:

    The Redirection in LINUX is the process that directs the data from one output to another. It can be used as a direct input to another process to get the desired output.

    23. Can we uninstall the libraries in LINUX?

    Ans:

    Yes, we can uninstall the libraries in LINUX by using command sudo apt-get remove library_name.

    24. How will you setup Password Aging in Linux?

    Ans:

    The chage command allows the system administrators in Linux to enforce password aging. The command is used to change the number of days between mandatory password resets. The /etc/login.defs file is responsible for handling system-wide configuration.

    It can be edited for:

    • PASS_MAX_DAY: Defines the maximum number of days a password may be used.
    • PASS_MIN_DAYS: Defines the minimum number of days allowed between password changes.
    • PASS_WARN_AGE: Defines the number of days warning is given before a password expires.

    25. What is a pwd command in LINUX?

    Ans:

      pwd stands for print working directory. This command is used for printing the working directory.

    26. How many characters can a filename have?

    Ans:

    This is a great example of the more clever Linux interview questions. It seems super easy, but not many people bother checking it out – that’s why employers ask it.The maximum amount of characters that a file name in Linux may have is 255.

    27. What is “GREP”?

    Ans:

     “GREP” abbreviates as a “Global Regulation Expression Point”. It is used for searching a text file for commonly used expressions.

    Course Curriculum

    Get Advanced Practical Oriented Linux Certification Course

    Weekday / Weekend BatchesSee Batch Details

    28. What is a ‘whoami’ command?

    Ans:

    This is one of those Linux interview questions that you might be familiar with based on your experience with Windows. You see, this is a command used on both Windows and Linux.

    29. What is “comm” used for?

    Ans:

    “Comm” compares two files and searches for both common and exclusive features.

    30. What does ‘nuhup’ do?

    Ans:

    With the “nuhup” command, you can turn off a terminal’s warnings about an imminent logout.

    31. What is a Socket?

    Ans:

      A Socket is a form of Interprocess Communication and Synchronization that can be used to transfer data from one process to another, either on the same host computer or on different hosts connected by a network; Network sockets are identified by source IP address, source port and destination IP address and port.

    32. How do you debug a running process or a library that is being called?

    Ans:

     ‘ltrace’ is another Linux Utility similar to ‘strace’. However, ltrace lists all the library calls being called in an executable or a running process. Its name itself comes from library-call tracing. This tool is very useful for debugging user-space applications to determine which library call is failing. It is also capable of receiving signals for segmentation faults, etc.

    33. What is Huge Pages in Linux and what use is there for them?

    Ans:

    Huge pages is a mechanism that allows the Linux kernel to utilize the multiple page size capabilities of modern hardware architectures. Linux uses pages as the basic unit of memory, where physical memory is partitioned and accessed using the basic page unit. The default page size is 4096 Bytes in the x86 architecture. Huge pages allows large amounts of memory to be utilized with a reduced overhead.

    • To check: cat /proc/sys/vm/nr_hugepages.
    • To set: echo 5 > /proc/sys/vm/nr_hugepages

    34. How to check Memory stats and CPU stats as a Linux admin?

    Ans:

    Using ‘free’ & ‘vmstat’ command, we can display the physical and virtual memory statistics, respectively. With the help of ‘sar’ command, we can see the CPU utilization & other stats.

    35. What is a tail command in Linux?

    Ans:

    Tail command displays the last part of a file. Generally, users don’t need every logline to troubleshoot. Instead, you want to check what your logs say about the most recent request to your application.

    Tail Example:

    $ tail -n 100 /var/log/https/access_log

    36 What is the maximum length for a file name in Linux?

    Ans:

    255 characters.

    37. Enlist some Linux distributors (Distros) along with its usage?

    Ans:

    Different parts of LINUX say kernel, system environment, graphical programs, etc are developed by different organizations. LINUX Distributions (Distros) assemble all these different parts of Linux and give us a compiled operating system to be installed and used.

    There are around six hundred Linux distributors. Let us see some of the important ones:

    • UBuntu: It is a well known Linux Distribution with a lot of pre-installed apps and easy to use repositories libraries. It is very easy to use and works like a MAC operating system.
    • Linux Mint: It uses cinnamon and mates desktop. It works on Windows and should be used by newcomers.
    • Debian: It is the most stable, quicker and user-friendly Linux Distributors.
    • Fedora: It is less stable but provides the latest version of the software. It has a GNOME3 desktop environment by default.
    • Red Hat Enterprise: It is to be used commercially and to be well tested before release. It usually provides a stable platform for a long time.
    • Arch Linux: Every package is to be installed by you and is not suitable for the beginners.

    38. What is the core of the Linux Operating System?

    Ans:

    The kernel is the core of the Linux Operating System. Shell is a Command Line Interpreter, Command is user Instruction to Computer, Script is a collection of commands stored in a file and Terminal is a command Line Interface.

    39. How will you restrict IP so that the restricted IP’s may not use the FTP Server?

    Ans:

    We can block suspicious IP by integrating tcp_wrapper. We need to enable the parameter “tcp_wrapper=YES” in the configuration file at ‘/etc/vsftpd.conf’. And then add the suspicious IP in the ‘host.deny’ file at location ‘/etc/host.deny’. 

    40. What does Sar provide? Where are Sar logs stored?

    Ans:

    Sar collects, reports, or saves system activity information, sar serves to log and evaluate a variety of information regarding system activity. With performance problems, sar also permits retroactive analysis of the load values for various sub-systems (CPUs, memory, disks, interrupts, network interfaces and so forth) and limitation of problems in this manner. If CPU utilization is near 100 % (user + nice + system), the workload sampled is CPU-bound.

    By default, log files of Sar command are located at /var/log/sa/sadd file, where dd parameter indicates the current day.

    41. Why is Linux considered more secure than other operating systems?

    Ans:

    Linux is an open-source operating system and nowadays it is growing rapidly in the tech world/market. Although the entire code written in Linux can be read by anyone, then to it is considered as more secure because of the following reasons:

    • Linux provides its user with limited default privileges which are basically restricted to the lower levels .i.e. in the case of any virus attack, it will reach only local files and folders where the system-wide damage is saved.
    • It has a powerful auditing system which includes detailed logs.
    • Enhanced features of IPtables are used in order to implement a greater level of security for Linux machines.
    • Linux has tougher program permissions before installing anything on your machine. 

    42. What is df -h command?

    Ans:

    This command shows free space on mounted file systems.

    43. What is the difference between locating and locate command?

    Ans:

    The slocate looks for the files that users have access whereas locate will search for the file with the updated result.

    Course Curriculum

    Get Linux Administration Training for Beginners from Industry Experts

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    44.  Linux initially was developed for intel X86 architecture but has been ported to another hardware platform than any other Operating System. Do you agree?

    Ans:

      Yes, I do agree. Linux was written for x86 machines and has been ported to all kinds of platforms. Today’s more than 90% of supercomputers are using Linux. Linux made a very promising future in mobile phone, Tablets. In-fact we are surrounded by Linux in remote controls, space science, Research, Web, Desktop Computing. The list is endless.

    45.  Is it legal to edit Linux Kernel?

    Ans:

    Yes. You can edit Linux Kernel because it is released under General Public License (GPL) and anyone can edit it. It comes under the category of free and open source software.

    46. Why do we use LINUX?

    Ans:

    LINUX is used widely because it is completely different from other operating systems where every aspect comes with something extra i.e. some additional features. Some of the major reasons to use LINUX are listed below:

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

    47. Enlist the features of the Linux operating system?

    Ans:

    Following are some important features of the LINUX operating system:

    • Linux kernel and application programs can be installed on any kind of hardware platform and thus is considered portable.
    • It serves the purpose of multitasking by serving various functions simultaneously.
    • It provides the security services in three ways namely, Authentication, Authorization, and Encryption.
    • It supports multiple users to access the same system resource but by using different terminals for operation.
    • Linux provides a hierarchical file system and its code is freely available to all.
    • It has its own application support (to download and install applications) and customized keyboards.
    • Linux distros provide live CD/USB to their users for installation.

    48. What is cat command in Linux?

    Ans:

    In Linux cat command concatenates and prints files. Users might issue cat to check the contents of your dependencies file or to confirm the version of the application that you have already built locally.

    49. Which popular office suite is available free for both Microsoft and Linux?

    Ans:

    Open Office Suite is available free for both Microsoft and Linux. You can install it on both of them.

    50. What is SMTP?

    Ans:

    SMTP stands for Simple Mail Transfer Protocol. It is an internet standard for mail transmission.

    51. What is Samba? Why is it used?

    Ans:

    Samba service is used to connect Linux machines to Microsoft network resources by providing Microsoft SMB support.

    52. Explain the term CLI?

    Ans:

    CLI stands for Command Line Interface. It is a way for humans to interact with computers and is also known as the Command line user interface. It relies on textual request and response transaction processes where user types declarative commands to instruct the computer to perform operations.

    Advantages of CLI

    • Very flexible
    • Can easily access commands
    • Much faster and easier to use by expert
    • Does not use much CPU processing time.
    • Disadvantages of CLI
    • Learning and remembering type commands is hard.
    • Have to be typed precisely.
    • Can be very confusing.
    • Surfing web, graphics, etc are a few tasks which are hard or impossible to do on the command line.

    53. What does curl command do in Linux?

    Ans:

    In Linux, curl command is used to test an application’s endpoint or connectivity to an upstream service endpoint. curl command will be used to determine if the application can reach another service, like a database, or checking if your service is healthy.

    curl Example:

    • $ curl -I -s myapplication:5000
    • HTTP/1.0 500 INTERNAL SERVER ERROR
    • This example through an exception saying that your application can’t reach your server.
    • In the above command, the -I option shows the header information and the -s option silences the response body.

    54. Which daemon controls the print spooling process?

    Ans:

    The line printing daemon.

    55. How to reduce or shrink the size of the LVM partition?

    Ans:

    Below is the logical steps to reduce the size of the LVM partition :

    • Unmount the filesystem using unmount command,
    • Use resize2fs command , e.g resize2fs /dev/mapper/myvg-myself 10G
    • Now use the lvreduce command as reducing -L 10G /dev/mapper/myvg-mylv
    • The above command will shrink the size LVM partition and fixes the filesystem size to 10GB. Most in-depth, the industry-led curriculum in Linux.

    56. Which command is used to delete a group?

    Ans:

    The grouper command

    57. You need to search for the string “Tecmint” in all the “.txt” files in the current directory. How will you do it?

    Ans:

    We need to run the find command to search for the text “Tecmint” in the current directory, recursively.

    58. What is the role of case sensitivity in affecting the way commands are used?

    Ans:

    Linux is considered as case sensitive. Case sensitivity can sometimes serve as the reason for displaying different answers for the same command as you might enter the different format of commands each time. In terms of case sensitivity, the command is the same but the only difference occurs with regard to uppercase and lowercase letters.

    For example: cd, CD, Cd are different commands with different outputs.

    59. Torvalds, Wrote most of the Linux Kernel in C++ programming language, do you agree?

    Ans:

     No! Linux Kernel contains 12,020,528 Lines of codes out of which 2,151,595 lines are comments. So remaining 9,868,933 lines are codes and out of 9,868,933 Lines of codes 7,896,318 are written in C Programming Language. The remaining lines of code 1,972,615 are written in C++, Assembly, Perl, Shell Script, Python, Bash Script, HTML, awk, yacc, lex, sed, etc.

    Note: The Number of Lines of codes varies on a daily basis and an average of more than 3,509 lines are being added to Kernel.

    60. What is the root account in Linux?

    Ans:

    The root account is like a systems administrator account, and allows full control of the system.

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

    Ans:

    From a command shell, use the “concatenate” command: cat /proc/meminfo for memory usage information. The root account is like a systems administrator account and allows full control of the system.

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

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

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

    65. 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.
    Explore Linux Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    66 . Predict the output of the following program code

    main()

    {

    fork(); fork(); fork();

    printf(“Hello World!”);

    }

    Ans:

    • “Hello World” will be printed 8 times.
    • Explanation:
    • 2^n times where n is the number of calls to fork()

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free