July 27, 2024

Part-10: Basic 10 Linux Interview Questions and Answers

In this article, we’ve included 10th set of 10 basic Linux Interview Questions and detailed answers that will help candidates prepare for the Linux interview and get the best job in the IT industry.

These Linux interview questions and answers will be useful for both freshers and experienced professionals at any level.

Some of the questions are for advanced Linux professionals, however, beginners or fresher can easily understand the answers and explanations described below.

Q.1) What is Interactive Mode in Linux

In interactive mode, the shell expects input from the user to execute commands. This is a common behavior that every Linux administrator is familiar with. This is called interactive mode because the shell interacts with the user to execute any commands in the shell.

Q.2) What is Non-Interactive Mode in Linux

A great example of a non-interactive mode in Linux is the shell script, which in most cases does not require user input, so running the shell script is always a non-interactive shell.

Q.3) What is the basic difference between BASH and DOS?

The below table describes the basic difference between Bash and Dos.

S.NoBASHDOS
1BASH commands are case sensitive so make sure that you have to input the commands with care.DOS commands are not case sensitive.
2In BASH ‘/’ character is a directory separator and ‘\’ is an escape character.In DOS, ‘/’ is a command argument delimiter and ‘\’ is a directory separator.
3BASH follows no convention in naming files.DOS follows a convention in naming files, which is 8 character file name followed by a dot and 3 character for the extension.

Q.4) How can we connect to a remote server from terminal?

SSH, or Secure Shell, is a protocol used to securely log into remote systems over an insecure network. This is the most common method that are used now a days to access remote Linux servers.

When you connect to a Linux system for the first time, SSH prompts you to accept the fingerprint of the machines to successfully establish the connection.

Basic Syntax:

ssh [remote_host or IP]

To connect a remote system with a specific username use the following format.

ssh remote_username@remote_host

Q.5) What is user space in Linux?

Linux user space refers to all kinds of utilities, programming languages, and graphical tools that are installed in an operating system and lives outside of the kernel.

These are user space applications where normal user processes run and processes running under the user space have access only to a limited part of memory whereas kernel has access to all of the memory.

Linux User Space

Q.6) What is kernel space in Linux?

Kernel space is strictly reserved for running a privileged operating system kernel and their codes, kernel extensions, and most device drivers.

The role of the kernel is to manage applications running in the user space from messing with each other, and the system. Kernel space can be accessed by user processes only through the use of system calls.

System calls are requests in a Unix-like operating system by an active process for a service performed by the kernel, such as input/output (I/O) or process creation.

Linux Kernel Space

Q.7) What are the different types of system calls in Linux?

A system call is a procedure that provides the interface between a process and the operating system to perform varies operation in the system.

  • fork() – Create a new process
  • exec() – Execute a new process
  • wait() – Wait until process execution
  • exit() – Terminate the process
  • open() – To open a file.
  • read() – To open a file in reading mode
  • write() – To open a file in writing mode
  • close() – To close the opened file
  • getpid() – To find the unique process id
  • getppid() – To find the parent process id
  • nice() – To modify the currently running process property
  • sleep() – To suspend the running process for some interval of time

Q.8) What are the different process states in Linux?

A process in Linux can be in one of the following states:

  • Running (R): The process is being executed and using the CPU at present.
  • Runnable (R): A runnable process is a process that is just waiting for the CPU to process it.
  • Sleeping: A sleeping process is a process waiting for a resource to be available like waiting on I/O, etc,. There are two types of sleeping processes such as Interruptible Sleep (S) and Uninterruptible Sleep (D).
  • Interruptible Sleep (S): When a process is in Interruptible sleep it wakes up from the middle of sleep and process the new signals sent to it.
  • Uninterruptible Sleep (D): When a process is in uninterruptible sleep it does not wake up from the middle of sleep even though new signals are sent.
  • Terminated/Stopped (T): A process has been stopped, usually by receiving a signal.
  • Defunct or Zombie (Z): The process is terminated, but still has an entry in the process table.

Q.9) How can you find the status of a process?

You can use the ps command or the top command to find information about process status in Linux. The status of a process tells you what the process is currently doing on the system.

ps command output:

Check Process status in Linux

top command output:

top -c

top - 17:24:03 up  5:59,  2 users,  load average: 0.53, 1.01, 1.06
Tasks: 330 total,   3 running, 327 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.1 us,  1.6 sy,  0.0 ni, 92.5 id,  0.0 wa,  0.0 hi,  0.8 si,  0.0 st
MiB Mem : 15831.25+total, 4015.715 free, 5254.238 used, 6561.301 buff/cache
MiB Swap: 2048.332 total, 2048.332 free,    0.000 used. 8100.496 avail Mem 

 PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                  
3760 linuxge+  20   0 4169776 874676 360116 R 22.77 5.396  15:42.15 /usr/lib64/firefox/firefox                                                                                               
6255 linuxge+  20   0 3196856 362176 170376 R 19.14 2.234   2:24.17 /usr/lib64/firefox/firefox -contentproc -childID 12 -isForBrowser -prefsLen 9691 -prefMapSize 221954 -parentBuildID 202+ 
8296 linuxge+  20   0 3390672 588472 324076 S 2.640 3.630   1:01.03 /usr/lib64/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 9901 -prefMapSize 221954 -parentBuildID 202+ 
2520 linuxge+   9 -11 2202496  14992  10564 S 1.980 0.092   1:42.66 /usr/bin/pulseaudio --daemonize=no --log-target=journal                                                                  
4706 linuxge+  20   0 3206380 320800 160560 S 1.320 1.979   1:44.72 /usr/lib64/firefox/firefox -contentproc -childID 8 -isForBrowser -prefsLen 8946 -prefMapSize 221954 -parentBuildID 2021+ 
5683 linuxge+  20   0 3516176 718524 146340 S 1.320 4.432  13:12.17 /usr/lib64/firefox/firefox -contentproc -childID 10 -isForBrowser -prefsLen 9230 -prefMapSize 221954 -parentBuildID 202+ 
8734 linuxge+  20   0  585412  80948  68452 S 1.320 0.499   0:06.72 /usr/lib/gnome-terminal-server                                                                                           
2536 linuxge+  20   0 4145196 442040 265444 S 0.990 2.727   5:26.96 /usr/bin/gnome-shell      

Q.10) What is load average in Linux?

The load average is the average system load on a Linux system for a defined period of time. It is calculated based on the compute resources usage such as CPU, Memory, disk, and other resources.

You can find the load average of your Linux system using the top or the uptime command. It shows the system load over a period of one, five, and 15 minutes.

top command output:

Check Linux system load average

uptime command output:

uptime
17:54:10 up 6:29, 2 users, load average: 0.94, 1.01, 1.08

Conclusion

In this guide, we’ve included the most frequently asked 10th set of 10 basic Linux Interview Questions and detailed answers for your reference purpose and we hope it will be very useful.

If you have any questions or feedback, feel free to comment below.

Leave a Reply

%d bloggers like this: