Friday, 26 April 2024

Linux Interview Questions & Answers for Beginners

 

1. What is Linux?

Ans: Linux is an operating system, which is based on Linux Kernel.  It is an open-source operating system where it can run on different hardware platforms. It provides a free and low-cost operating system for users. It is a user-friendly environment where they can easily modify and create variations in the source code.

Delve into the fascinating world of operating systems with enriching educational materials, including valuable insights into Linux Training and a diverse array of related topics.

2. Who invented Linux? Explain the history of Linux.

Ans: Linus Torvalds created Linux. Linus Torvalds was a student at the University of Helsinki, Finland in 1991. He started writing code on his own to get the academic version of Unix for free. Later on, it became popular as Linux Kernel.

Explore a rich array of educational content covering various operating systems, including an in-depth Linux tutorial designed to enhance your understanding of this powerful platform.

3. What is the difference between Linux and Unix?

Ans: Here is the difference between Linux and Unix - mentioned below

Linux
Unix
Both paid and free distributions are available.
Different paid structures for different levels of Unix.
Linux primarily uses GUI with an optional command-line interface
Unix uses the command-line interface
Linux OS is portable and can be executed on different hard drives
Unix OS is not portable.
Linux is developed by a worldwide Linux community.
Unix is developed by AT&T developers.
Linux is free. And it is download through the internet under GNU licenses.
Most Unix Like Operating Systems is not free.
Linux is used at home-based PC's, phones, etc.
Unix is used in server systems.

And some other differences.

Linux is a Unix clone. But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX.

  • Linux Is Just Kernal

All Linux distributions include GUI system, GNU utilities, installation & management tools, GNU c/c++ Compilers, Editors (vi), and various applications like OpenOffice, Firefox.

UNIX operating systems are considered a complete OS as everything come from a single vendor.

  • Security And Firewall

Linux comes with an open-source Netfilter and IPTables-based firewall tool to protect your server and desktop from crackers and hackers. UNIX operating systems come with their own firewall products. 

  • Backup And Recovery

UNIX and Linux come with their own set of tools for backing up data to tape and other backup media. However, both Linux and UNIX share some common tools such as tar, dump/restore, and cpio, etc.

Discover the nuanced differences between Linux Vs Unix through an insightful comparison, shedding light on the unique characteristics of each operating system.

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

Gain a deeper understanding of the Linux operating system with comprehensive educational resources that delve into its architecture, functionality, and versatility.

5. What is Linux Kernel?

Ans: Linux kernel is the heart of the operating system. It acts as a bridge between software and hardware. If Software requests the hardware, then the kernel delivers the data between software and hardware.

For example, if you want to play a song you should launch your default player, it requests the kernel to play a song, now the kernel will contact the hardware to seek the permissions or to seek the hardware components like if you plugged in any headset to the device. Most Android phones use Linux kernels. 

Yes, the kernel can edit, because it is released under General Public License.



6. What is BASH?

Ans: Bash is a Unix shell and command processor written by Brian Fox for the GNU project. It is free software and acts as a replacement for Bourne Shell. It is an interpreted and not compiled process which can also be run in the terminal window.

This allows users to write commands and cause actions. Bash is capable of reading commands from shell scripts.

7. What is LILO?

Ans: LILO means Linux Loader is a boot loader that is used for the Linux operating system. Most of the Linux Operating systems use LILO, to boot the operating system into main memory to start the operations.

8. What is CLI?

Ans: CLI means Command language Interpreter. It interacts with the computer program, where the user issues command in the form of text lines. It Interacts with the computer terminals also, the interface accepts the text lines and converts them as a command to the operating system. 

9. What is the advantage of Open Source?

Ans: Linux was one of the first open-source technologies, many programmers added software that completely open to the users, which means you can download the file and change the code as you like. It has a wide range of options for users and increased security.

10. What is the disadvantage of Open Source?

Ans: Disadvantages of Open Source Operating System mentioned below

  1. Difficulty of use 
  2. Compatibility Issues
  3. Liabilities and warranties
  4. Hidden costs

11. What is Shell?

Ans: Shell is a computer program that acts as an interface between the user and the kernel. Users can communicate with the kernel by writing programs, commands, and scripts on the shell. It accepts human-readable commands and converts them into kernel-understandable language.

12. How many types of Shells are there in Linux? 

Ans: They are five Shells in Linux:

  • C Shell (csh): It is like C syntax and provides spelling checking and job control.
  • Korn Shell (ksh): This is a high-level programming language shell.
  • Z Shell (Zsh): It provides some unique nature like it observes login/logout watching, file name generating, startup files, and closing comments. 
  • Bourne Again Shell (bash): It is the default to Linux distributions.
  • Friendly Interactive Shell (Fish): It provides web-based configuration,  auto-suggestions, etc. 
Explore a diverse array of Linux monitoring tools designed to optimize system performance and enhance operational efficiency, offering invaluable insights into system health and resource utilization.

13. What are the basic components of Linux?

Ans: Basic components of Linux

  1. Kernel: It is the core component of Linux, it acts as an interface between software and hardware.  
  2. Shell: It acts as an interface between the user and the Kernel.
  3. GUI:  It stands for Graphic User Interface, which is another way for the user to interact with the system. But it is unlike images, buttons, text boxes for interaction.
  4. System Utilities: These are the software functions that allow users to manage the computer.
  5. Application Programs: A set of functions designed to perform a set of tasks.

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

Ans:

Launch your terminal by pressing CTRL+ALT+T or by giving terminal in the menu search bar.

15. What is a swap space?

Ans: Swap Space is used when the physical Ram memory is running out. It will move the Ram inactive pages to the swap space. It can consider in the form of a dedicated swap partition or swap files.

16. What is the GUI?

Ans: GUI means Graphical User Interface. It is a human-computer interface that uses windows, images, icons, and menus which can be manipulated by using a mouse. Most of the modern applications in electronic gadgets communicate with the user through GUI. GUI is a combination of graphical and textual interaction that uses buttons, menus, message boxes, etc.

17. Explain File Permissions types in Linux?

Ans: Linux file permissions - Each file or directory has 3 permissions

They are 

  1. Read: It refers to only they can read the file.
  2. Write: It refers that they can write the file or 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. 
Explore the intricacies of Linux file permissions, gaining a comprehensive understanding of how they regulate access to files and directories within the operating system's filesystem.

18. What are the environmental variables?

Ans: They are dynamic values that affect the process of programs on a computer. They exist in every operating system and their types may vary. They can be created, edited, saved, and deleted and they also give information about the system's behavior.

19. What are the symbolic links? 

Ans: It will be redirected to another file using its path. Target files do not contain any data. Symbolic links redirect to another entry somewhere in the file system. If the target file is deleted, the link to that file is removed, but not the file.

20. What are the hard links?

Ans: 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.

21. What is redirection?

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

22. What are Daemons?

Ans: A Daemons is a background process that accepts requests for service from other computers, most of operating systems use daemons in other forms. 

Discover opportunities to enroll in a Linux certification course in Hyderabad, equipping yourself with valuable skills and expertise in one of the most sought-after operating systems in the industry.

 23. Describe the root account?

Ans: The root is the user name, which default has access to all files and commands. The root user can do many things, but an ordinary user cannot do like installing software, changing file permissions, etc.

24. Explain the virtual desktop?

Ans: Virtual Desktop is a user interface when you are facing the problem of how to manage multiple windows on your desktop, virtual desktop serves as an alternative. Virtual desktop stores remote server and allow you to use one or more programs on a clean slate. 

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

Ans: There are three kinds of modes in vi editors. They are 

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

26. What are inode and process id?

Ans: The inode is a unique name given to each file and the process id is a unique name given to each process. 

27. What are the Process states in Linux?

Ans: Five process states in Linux. They are

  1. New/ Ready: A new process is created and ready to run.
  2. Running: The process is being executed.
  3. Blocked/ Wait: The process is waiting for input from the user. 
  4. Terminated/ Completed: The process completed the execution or terminated by the operating system. 
  5. Zombie: The process is deleted, but still the information regarding the process exists in the process table.



28. Explain Process Management System Calls in Linux?

Ans: The process management system calls in Linux:

  • fork(): Used to create a new process.
  • exec(): Execute new process.
  • wait(): wait until process execution.
  • exit(): exit from the process.

System calls to get the Process id :

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

29. Explain File Permission groups in Linux?

Ans: There are three user-based permission groups for each file and directory.

They are:

  1. Owner: Owners only will have to access the file or directory, they will not impact the actions of other users.
  2. Group: These permissions apply only to the group, that has been assigned to the file or directory. They will not impact the actions of other users.
  3. All Users: These permissions are applied to all users on the system.

30. What Is a File system in Linux?

Ans: Linux file system stores and handles the data. Without a file system, it cannot know where the file starts from and where the file ends.

31. Explain different file system types in Linux?

Ans: In Linux, there are many file systems:

Ext, Ext2, Ext3, Ext4, JFS, XFS, btrfs, ufs, autofs, devpts, ntfs and swap.

Linux Admin Interview Questions

32. Why LVM is required?

Ans: LVM stands for Large Volume Management, it is a storage management device. Users can create, resize, and delete LVM partitions. It increases abstraction, flexibility, and control. LVM is used to gather existing storage devices into the group and allocate logical units. 

33. What is umask?

Ans: unmask stands for user file creation mode. When the user creates any file, it has default file permissions. So unmask will specify few restrictions to the newly created file (it controls the file permissions).

umask [-S] [mask]

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

Ans: If the unmask command invoked without any arguments, it means it will display the current mask. 

To set the unmask permanently, we have two types.

They are:

  • Ocotal representation.
  • Symbolic representation.

35. What is network bonding in Linux?

Ans: 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 behaviour of the bonded interface depends on the bonding method. 

36. What are the different modes of Network bonding in Linux?

Ans: Different modes of Linux network bonding

  • Mode-0(balance-rr): It is a default mode and based on Round-Robin policy. It offers fault tolerance and load balancing features. It used round-robin fashion to transmit the packets.
  • Mode-1(active-backup): It is based on Active Backup policy and only one slave will act in the band and another one will act when the others fail in the band. It also provides fault tolerance.
  • Mode-2(balance-xor): It sets a xor mode between the source Mac address and destination Mac address to provide fault tolerance.
  • Mode-3(broadcast): It is based on broadcast policy and transmitted everything in the slave interface. It also provides fault tolerance and can be used only for a particular purpose.
  • Mode-4(802.3ad): It is a dynamic aggregation mode, it created aggregation groups which is having the same speed. It uses the transmit hashing method to select the slaves for outgoing traffic.
  • Mode-5(balance-tlb): The outgoing traffic is according to the current load on the slave, and the incoming traffic is received by the slave. It is called an adaptive transmit load balancing mode. 
  • Mode-6(balance-alb): It is an adaptive load balancing mode. It does not require any switch support. 

37. How to check the default route and routing table?

Ans: To display the default route and routing table, we use the following commands.

$ route-n

$ nestat-rn

$ ip 

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

Ans: We have two commands to check which ports are in listening in Linux Server. Following are the two commands 

# netstat --listen
# netstat -l

39. Where the kernel modules are located?

Ans: lib/modules/kernel-version/, this directory stores all the information about the compiled drives under the Linux system. Using lsmod command also we can see the installed kernel modules. 

40. How to change the default run level in Linux?

Ans: To change the default run level in Linux use the init command. 

41. How to share a directory using NFS?

Ans: To share a directory using NFS, first edit the configuration file and ‘/etc/exports’ and add an entry like directory name ‘/<directory-name>’. Now restart the NFS service.

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

Ans: Details mentioned below

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

43. How to lock a user account in Linux?

Ans: Locking user account is done for the security purpose so that unauthorized users cannot log in. So, we have a few ways to lock the user account. Some of them are below. 

  1. Lock or disable the password using passwd command.
  2. Expire the user account using usermod command or chage command.
  3. Changing the shell using nologin command ( /sbin/nologin ).

Linux Commands Interview Questions

44. What is the 'ls' command and what it does?

Ans: It is one of the basic commands in Linux. It is used to list all the files and directories in the file system.zom

Syntax: 

ls [OPTIONS] [FILES]

We can use it without passing the arguments, then it will list all the files in the current working directory. Files will be displayed in alphabetical order. 

Is

To list the specific directory files use the directory name in the syntax, follow as shown in the below syntax.

ls /etc
We can also pass multiple directories names in the syntax, but separated by space. 

ls /etc /var /etc/passwd

45. What is the tail command in Linux?

Ans: The Tail command print the last N number of lines of the given data, it prints 10 lines by default. 

Syntax: 

tail [OPTION]... [FILE]

Example: 

$ cat names.txt
Tableau
sql server
linux administration
Now, check the syntax without giving any option or input.
$ tail state.txt

46. What is grep command in Linux?

Ans: grep command is a filter that is used to the global search for regular expressions.

Syntax:

grep [options] pattern [files]

47. What is ps command in Linux? 

Ans: The ps command displays the current process status of the system. And it displays the processes id’s with some other related data also. 

Syntax: 

Ps [options]

Output:

[root@rhe17~]# ps

PID TTY    TIME CMD

12330 pts/0  00:00:00 bash

21621 pts/0  00:00:00 ps

Explore a comprehensive collection of Linux commands with practical examples, enabling you to deepen your understanding and proficiency in navigating and managing the Linux operating system efficiently.

48. What is the env command in Linux?

Ans: env is a shell command is used to print a list of current environmental variables and it can run another process in another environment without any modification of the current environment. 

env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
Options
Tag
Description
-i, --ignore-environment
Start with an empty environment.
-0, --null
output line End with a 0 (null) byte rather than a newline.
-u, --unset=NAME
removes variable NAME from the environment
--help
Display a help message and exit.

49. What is the top Command in Linux?

Ans: The top command is used to show the system process and it displays and updates the sorted process information. 

50. What is netstat command in Linux?

Ans: netstat command gives various information about the network and routing tables, interface statics and more about the system.