Linux Interview Questions

Best Technical Answers for Linux Interview Questions by Linux Developers, Advanced Technical questions for freshers and experience Persons. Get Free Practical Tests

1. What is Linux?

Ans: Linux is a popular operating system, which is designed on the base of Linux Kernel. This operating system is an open-source system and which can run on multiple hardware platforms. The importance of using the Linux operating system is to provide free and less expensive operating services for users. This operating system is also considered as a user-friendly work nature which can be modified easily and also enables the user to create variations in the source code.

2. Who first invented Linux and explain briefly about its history?

Ans: Linus Torvalds created the Linux operating system. Linux Torvalds was a student at Helsinki University, Finland in 1991. During the time of his academic project, he started writing codes on his own to get the easier version of the UNIX for free. Later on, we started calling it Linux Kernel.

3. What is the difference between Linux and UNIX?

Ans: The following are the important differences between Linux and UNIX;

Linux UNIX
In Linux in both paid and free distributors available Unix is available on different paid structures for unique levels of Unix
Linux operating system uses the GUI which includes an optional command-line interface. Unix included only command-line interface
Linux operating system is portable to use which can be executed in different hard drives Whereas UNIX is not portable to use
Linux is designed by the worldwide Linux social community Whereas UNIX is developed by the AT&T developer community
Linux is a free open source system and the user can download it from the internet using GNU licenses Most of the Unix operating systems are not free
Linux can be operated at home-based personal computers, phones, tabs, etc. UNIX is mainly used in server systems.

4. What is the Core of the Linux operating system?

Ans: The kernel is the core source of the Linux operating system.

5. Explain permission types in Linux.

Ans: Each file or directory has three permissions in Linux.

  1. Read: It refers only to read the file.
  2. Write: It refers to write the file or can modify the file of a directory.
  3. Execute: It affects the user’s capability to execute the file or to view the file of a directory. 

6. What is CLI?

Ans: The CLI is nothing but a Command-line interpreter. This interpreter interacts with different computer programs, and it can be used in the form of text lines. The CLI interpreter also interacts with the computer terminals, and it enables users to add text lines and later they will be converted into user-defined commands.

7. What is BASH?

Ans: BASH is a type of UNIX shell and the command lines are written by Brian Fox to work on GNU projects. It is free software and sometimes we can use it as a replacement for Bourne shell. This is also interpreted and cannot able to compile it. BASH shell can also be run on any terminal windows. So users can write commands and perform related actions. BASH shell is also used to read the commands which are written using shell scripts.

8. Explain the process management system calls in Linux.

Ans: The process management system calls in Linux implements the following methods.

  • fork(): This method creates a new process.
  • exec(): This method executes a new process.
  • wait(): This method is used to wait until process execution.
  • exit(): This method is used to get exit from the process.

The commands which are used in System calls to get the Process id are.

  • getpid(): It is used to find the unique process id. 
  • getppid(): It is used to find the unique parent process id. 

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

Ans: It is more secure because of the following reasons.

  • Linux provides limited default privileges for users which are restricted to the lower levels. So when the virus attack, it will reach only local files and folders where the system-wide damage is saved.
  • It has a powerful auditing system that includes detailed logs.
  • A greater level of security for the Linux machine is implemented by using the enhanced features of IPtables.
  • The permissions in Linux contains the tough program before installing anything on your machine.

10. What is the Linux kernel?

Ans: As I said earlier, the kernel is the heart of the Linux operating system. It acts as a bridge between both hardware and software. For example, if software requests any hardware requirement, then the kernel transfers the data between software and hardware. Most of the Android mobile devices use the Linux kernel.

11. What is LILO?

Ans: LILO can be abbreviated as a Linux Loader, this is a boot loader used for the Linux operating system. Most of the recent Linux versions use LILO, to boot up the operating system into RAM to start the operation.

12. What is grep command in Linux?

Ans: The grep searches file patterns. The grep searches the relevant lines for a specific pattern in the output of another command.

Example:

$ cat tomcat.log | grep org.apache.catalina.startup.Catalina.start

12-Jan-2018 17:08:35.542 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 681 ms

13. What are the commands used in creating, modifying an existing file and deleting information from vi editor?

Ans: The commands are.

vi filename: This command is used in creating a new file as well as modifying an existing file.

View filename: This command opens an existing file in read-only mode.

X: This command deletes the character which is under the cursor or before the cursor location.

dd: This command is used to delete the current line.

14. Explain the Linux directory commands.

Ans: 

pwd: The command stands for “print working directory”. It is a built-in command which displays the current working location, working path that starts with / and directory of the user. It displays the full path of the current directory. 

ls: The command is used for listing all the files in the directed folder.

cd: The command stands for “change directory”. It is used for changing the directory on which you want to work from the present directory. To access a particular directory type cd followed by the directory name.

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

rmdir: The command is used for removing a directory from the system.

15. Explain the purpose of using the “cd” command and its options.

Ans: The ‘cd’ stands for change directory and is used in changing the current directory on which the user is working.

Syntax: $ cd {directory}

The purpose of using the “cd” command is as follows.

  • To change from current to a new directory.
  • To change the directory by using the absolute path.
  • To change the directory by using the relative path.

The options in change directory are.

cd~: This command brings you to the home directory.

cd-: This command brings you to the previous directory.

. : This command brings you to the parent directory.

cd/: This command takes you to the entire system’s root directory.

16. What are the features of the Linux Operating System?

Ans: The features of the Linux operating system include.

  • Portable: The software in Linux can work on different types of hardware. The data is portable to carry in pen drives and memory cards.
  • Open Source: The Linux Operating System is available for free which is a community-based development project. 
  • Multi-User: The applications can be used by multiple users. Multiple users can use ram and run programs at the same time.
  • Multi-Programming: Users can run multiple programs or applications at the same time.
  • Shell: It has a special interpreter program which executes programs and commands of a system.
  • Security: Linux provides data security by authentication, authorization, and encryption.

17. What is cat command in Linux?

Ans:  The cat command in Linux is used for concatenating and printing the files. Users apply cat command to check the contents of the dependencies file or to confirm the version of an application which is already built locally.

Example:

$ cat requirements.txt

flask

flask_pymongo

18. What is meant by PIPE in Linux?

Ans: A pipe is a form of redirection used in Linux. It is used in combining more than two commands and the output of one command can take as input to the next command.

Syntax:

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

19. Explain about chmod command?

Ans: The chmod command is used for changing the permissions of files and directories. There are three types of permissions, read, write and execute and are represented by numbers as shown below.

  • 4 - read permission
  • 2 - write permission
  • 1- execute permission

Syntax:

$ chmod options permissions file name 

$ chmod [OPTION]... MODE[,MODE]... FILE…

$ chmod [OPTION]... OCTAL-MODE FILE…

$ chmod [OPTION]... --reference=RFILE FILE…

 

Linux Certification Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

 

20. How to exit from vi editors?

Ans: There are two commands used for getting exit from vi editors.

  • wq: The wq command exits from the vi editor by saving the current work.
  • q!: The q! command exits from the vi editor without saving the current work.

21. How permissions are granted under Linux?

Ans: A system administrator grants the file permission using the “chmod” command. Following are the symbols used in writing the permissions.

  • ‘+’ is used for adding permission.
  • ‘-‘ is used for denying permission.

It also includes the single letter permissions which denote.

  • u: user; 
  • g: group; 
  • o: other; 
  • a: all; 
  • r: read; 
  • w: write;
  • x: execute.

22. What are the different modes when using the vi editor?

Ans: The three different modes of vi editor are.

  • Command Mode/ Regular Mode.
  • Insertion Mode/ Edit Mode.
  • Ex Mode/ Replacement Mode.

23. Differentiate between Cron and Anacron?

Ans: 

Cron:

  • It allows the user in scheduling the tasks that have to be executed every minute.
  • A normal user can schedule the task and it is basically used when tasks must be completed/executed at a particular hour or minute.
  • Cron is ideal for servers.
  • Cron expects the system to run 24x7.

Anacron:

  • It allows the user to schedule the task to run on a specific date or the first available cycle after the date.
  • Only the superusers can use the anacron and is used when a task has to be executed irrespective of an hour or minute.
  • Anacron is ideal for desktops and servers.
  • Anacron doesn’t expect the system to run 24x7.

24. What is env command in Linux?

Ans: It is a shell command that is used for printing a list of current environmental variables which can run another process in another environment without any modification of the current environment.

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

Options:

  • -i, --ignore-environment: These tags describe starting with an empty environment.
  • -0, --null: The output line End with a 0 (null) byte rather than a newline.
  • -u, --unset=NAME: These tags remove variable NAME from the environment.
  • --help: It displays a help message and will exit.

25. How can you append one file to another in Linux?

Ans: One file can be appended to another file by using the command cat file 2 >> file 1. The operator “>>” appends the output of the named file or creates the file if it is not created. There is another command cat file 1 file 2 > file 3 which appends two or more files to one.

26. Explain Redirection.

Ans: It is the process of directing the data from one output to another or the output serves as input data for another process. There are three streams available in which input and output of the Linux environment are distributed.

  1. Input Redirection: A ‘<’ symbol is used for input redirection that is numbered as (0). So it is denoted as STDIN(0).
  2. Output Redirection: A ‘>’ symbol is used for output redirection that is numbered as (1). So it is denoted as STDOUT(1).

      3. Error Redirection: It is denoted as STDERR(2).

Subscribe to our youtube channel to get new updates..!

 

27. What is Shell?

Ans: Shell in Linux operating system is a computer program this acts as an intermediate between the user and the kernel. Users can also communicate with the kernel with the help of programming codes, commands, and scripts on the shell. This shell accepts the human-readable commands and later converted them into the kernel understandable language.

28. What are the default ports used for SMTP, DNS, FTP, DHCP, SSH, and squid?

Ans: The port numbers used for these services are.

  • SMTP - 25
  • DNS - 53
  • FTP - 20(Data Transfer) 21(Connections Established)
  • DHCP - 68(dhcp client), 67(DHCP server)
  • SSH - 22
  • Squid - 3128

29. How to check which ports are listening in Linux Server?

Ans: There are two commands to check the ports listening in Linux Server.

  1. netstat --listen
  2. netstat -l

30. What Is Linux Shell?

Ans: Linux shell is a user interface used for executing the commands. Shell is a program the user uses for executing the commands. In UNIX, any program can be the users shell. Shell categories in Linux are:

Bourne shell compatible, C shell compatible, nontraditional, and historical.

31. What Is Shell Script?

Ans: A shell script, as the name suggests, is a script written for the shell. Script here means a programming language used to control the application. The shell script allows different commands entered in the shell to be executed. Shell script is easy to debug, quicker as compared to writing big programs. However the execution speed is slow because it launches a new process for every shell command executed. Examples of commands are cp, cn, cd.

32. What is the advantage and disadvantage of open source?

Ans: 

First, let me discuss the advantage of open-source;

  •       Linux is one of the first open-source technologies.
  •       This helps users to add software that is completely open to the users.
  •       This lets the user download any kind of file and also you can change the code
  •       Open source also provides various options for users and this increases the security.

Now it’s time to explain the disadvantage of open source:

  •       Sometime it’s very difficult to use
  •       Compatibility issues
  •       Warranties and liabilities
  •       Cost is expensive.

33. 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 printer)

34. How many types of shells are there in Linux?

Ans: There are 5 shells in Linux;

  1. C shell (csh): This is available in the form of C syntax and helps the user to check the spellings.
  2. Korn shell (Ksh):  this is a high-level programming language shell.
  3. Z shell: This shell offers unique nature like log in or logout features, the file system also generates, start-up files documents, and closing comments.
  4. Bourne again shell (bash): this shell is a default one in the Linux operating system.
  5. Friendly interactive shell (Fish): This shell provides a web-based system configuration, auto-suggestions.

35. What Stateless Linux Server? What Feature It Offers?

Ans: A stateless Linux server is a centralized server in which no state exists on the single workstations. There may be scenarios when a state of a particular system is meaningful (A snap shot is taken then) and the user wants all the other machines to be in that state. This is where the stateless Linux server comes into picture.

Features:

  • It stores the prototypes of every machine.
  • It stores snapshots taken for those systems.
  • It stores home directories for that system.
  • Uses LDAP containing information of all systems to assist in finding out which snapshot (of state) should be running on which system.

36. What are the basic components of Linux architecture?

Ans: The following are the important component which made a Linux operating system;

  •       Kernel: this is one of the core components in the Linux operating system; it acts as a bridge between hardware and software components.
  •       Shell: This acts as an interface between the system users and the kernel operating system.
  •       GUI: this is a graphical user interface which to interacts with the system.
  •       System utilities: this is a kind of software function, which allows users to manage the computer.
  •       Application programs: this is nothing but a set of tasks that are designed to perform a set of tasks.

Linux Certification Training

Weekday / Weekend Batches

 

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

38. What Is A Zombie?

Ans: Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table. Since this process is not alive, it cannot react to signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared by the kernel.

39. What is Swap space?

Ans: The swap space is used when we need to run the Physical memory. This also helps users to move the RAM inactive pages to the Swap space. The swap space is available in two forms such as swap partitions, and swap files.

40. What is the GUI?

Ans: GUI in Linux operating system is a Graphical user interface. It is also considered as a type of human-computer interface which uses the Windows, images, icons, and menu bars. Most of the recent computer applications in electronic devices communicate with users through GUI. A graphical user interface is a combination of a graphical and textual interaction that can be used in the form of buttons, menus, and message boxes.

41. Explain the file permissions types in Linux?

Ans: Each file or directory has 3 file permissions in Linux;

  1. Read -> this refers only when you read the file.
  2. Write -> this refers that when you write the file or modify the file.
  3. Execute -> this refers that when you execute the file or view any file of a directory.

42. What are the differences between BASH and DOS?

Ans: The main differences between BASH and DOS are as follows;

BASH DOS
BASH command is a case sensitive DOS command is not case sensitive
Under BASH the characters are directory separator and which acts as an escape character Under DOS the characters are the command argument delimiter and are the directory separator
BASH follows such no convention DOS follows a name convention

43. What are symbolic links?

Ans: Symbolic links are shortcuts in windows. These links point to programs, codes, files, or directory. This link allows direct instant access to the entire pathnames.

44. Does the CTRL+ALT+DELETE key combination work on Linux?

Ans: Yes, it works on Linux; we can use this key combination to restart the system.

45. What are hard links?

Ans: The hard links directly point to the physical file on a disk, and never on the pathname. Suppose if you remove or move the original file, the hard link will not break because the link itself is used a file, not the path where the file is stored in a directory.

46. What are daemons?

Ans: Daemons are a kind of service which offers different functions that you can’t find them under the base operating system. The main tasks included are listening for a service request and let them act on these requests. Once the service is finished, it is then disconnected and waits for any further requests.

47. What is a Virtual desktop?

Ans: This virtual desktop is an alternative service to minimize and maximize the multiple windows on the currently running desktop. The main purpose of using a virtual desktop is to clear the desktop when you run one or more programs at a time. This enables users to shuffle between the desktops rather than minimizing/ restoring the programs.

48. What are I node and process ID?

Ans: The inode is a unique name given to any file or directory whereas process id is a unique name given to each process.

49. What are the process states in Linux?

Ans: There are 5 process states in Linux;

  1. New / Ready process
  2. Running process
  3. Blocked or Wait for process
  4. Terminated or completed the process
  5. Zombie process.

50. Name the file permission groups in Linux?

Ans: The file permission groups are based on each file or directory, they are as follows;

Owner: The owner will have permission to access the file or directory; they will not impact any action of other groups.

Group: The file permission will be applied only to groups that are assigned to the file or directory

All users: This type of file permission will be applied to all the users on the system.

51. What is a file system in Linux?

Ans: The Linux file system is used to store and handle the data. Without a file system, it becomes a very difficult task to know where the file begins from and where the file ends.

52. Why LVM is required?

Ans: LVM means large volume management; it is nothing but a storage management device. With the help of LVM users can create, resize, or delete the partitions. LVM also increases the abstraction, flexibility, control, gather existing storage device, and allocates the logical units.

53. What is Umask?

Ans: Umask = users for file creation mode. When you create the file, this offers the default file access permissions. Umask also specify a new restriction to the newly created file type.

54. How to set the mask permanently for a user?

Ans: To set the Umask permanently we have two options such as,

  •       Ocotal representation
  •       Symbolic representation.

55. What are the different modes of network bonding in Linux?

Ans: There are six different modes of the network bonding in Linux;

  •       Mode -0 (Balance –rr)
  •       Mode -1 (active-backup)
  •       Mode -2 (balance –Xor)
  •       Mode -3 (broadcast)
  •       Mode -4 (802.3ad)
  •       Mode -5 (balance –tlb)

56. Where are kernel modules located?

Ans: The directory name is lib/modules/kernel-version/, this is the directory where we can see the Kernel module, this stores all the valuable information about the compiled drivers. Using lsmod command users can see the installed kernel modules.

57. What is the difference between Linux Vs Windows?

Ans: 

Linux

  • The Linux operating system is available for free.
  • An operating system is open-source.
  • Linux can be customized.
  • Provides high-level security.
  • Primary partitioning and logical partitioning are available to boot.

Windows: 

  • The Windows operating system is purchasable.
  • An operating system is not open-source.
  • Windows cannot be customized.
  • Cannot defend from virus and malware attacks.
  • Booting is available while primary partitioning only.

Submit an interview question

Categories

Request for more information

John
John
Cloud Technologies & Cyber Security
John is a Post Graduate in Computer Science from Andhra University .She is currently working as an IT developer at hkr trainings.com. And he has great experience includes both IT development and operational roles. Connect with him on LinkedIn and Twitter. Thank you

WhatsApp
To Top