Showing posts with label pipes. Show all posts
Showing posts with label pipes. Show all posts

February 11, 2021

Top 20 Linux Interview Questions and Answers

 
Ques. 1): How can Linux be differentiated from other Operating Systems?
Answer: 
Linux is somewhat like other operating systems you might have used before, such as OS X, iOS or the Windows. Like other operating systems, Linux too has a graphical user interface. The types of software just like other operating systems have, such as the word processing applications.
 But Linux is different from other operating systems in many ways. First and foremost, Linux is open source software. The code used to create the OS is always free and available to the public to view, contribute and edit. Secondly, although the core pieces of the Linux OS are generally common, there are quite many distributions of Linux, which include different software options, which implies Linux is incredibly customizable. Linux users can also choose core components, such as the system displays graphics and other UI components.

 
Ques. 2): What is the basic difference between UNIX and Linux Operating System.
Answer: 
Linux Operating System is Free and Open Source Software, the kernel of which is created by Linus Torvalds and community. Well you cannot say UNIX Operating System doesn’t comes under the category of Free and Open Source Software, BSD, is a variant of UNIX which comes under the category of FOSS. Moreover Big companies like Apple, IBM, Oracle, HP, etc. are contributing to UNIX Kernel.
 

Ques. 3): What Is Shell Script?
Answer: 
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.
 

Ques. 4): What Are Pipes?
Answer: 
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)
 

Ques. 5): What Stateless Linux Server? What Feature It Offers?
Answer: 
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 partilcuar 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 those system.

Uses LDAP containing information of all systems to assist in finding out which snapshot (of state) should be running on which system.
 

Ques. 6): What Is Bash Shell?
Answer: 
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.
 

Ques. 7): What Is A Zombie?
Answer: 
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.
 

Ques. 8): Explain Each System Calls Used For Process Management In Linux.
Answer: 
System calls used for Process management:
·       Fork () :- Used to create a new process
·       Exec() :- Execute a new program
·       Wait():- wait until the process finishes execution
·       Exit():- Exit from the process
·       Getpid():- get the unique process id of the process
·       Getppid():- get the parent process unique id
·       Nice():- to bias the existing property of process
 

Ques. 9): How Do You Kill A Process?
Answer: 
kill -9 8 (process_id 8) or kill -9 %7 (job number 7)
kill -9 -1 (Kill all processes you can kill.)
killall - kill processes by name most (useful - killall java)
 

Ques. 10): What Is A Filesystem?
Answer: 
Sum of all directories called file system. A file system is the primary means of file storage in UNIX. File systems are made of inodes and superblocks.
 

Ques. 11): What Are Two Subtle Differences In Using The More And The Pg Commands?
Answer: 
With the more command you display another screenful by pressing the spacebar, with pg you press the return key. The more command returns you automatically to the UNIX shell when completed, while pg waits until you press return.
 

Ques. 12): We Saw the Mention On The Linux Bios Website About One Million Devices Shipped With Linux Bios. Could You Tell Us More About These Devices?
Answer: 
Yes, these are internet terminals that were built in India, based on the [x86 system-on-chip] STPC chip, I am told; also, there evidently is a Turkish-built digital TV that runs Linux BIOS. I have also heard that there are routers and many other embedded devices running Linux BIOS. I think at this point that 1 million is a low number. I am in contact with other set-top box vendors that are talking about numbers in the lOs of millions for their products. These numbers actually make the OLPC numbers seem small, which is in it amazing.
 

Ques. 13): What's Your Goal For Your Talk At Fosdem?
Answer: 
I’d like to communicate the basic ideas — that Linux is a good BIOS, and why; why Linux BIOS is built the way it is; where we are going; and how people can help. Most importantly, why it all matters — and it really matters a lot. We’re on the verge of losing control of the systems we buy, and we need to make a conscious effort, as a community, to ensure this loss of control does not happen. That effort will not be without some sacrifice, but if we are to maintain our ability to use and program our machines, and have fun with them, we have to act now. Because, if the computing business stops being fun, what’s the point$
 

Ques. 14): What Command Would You Use To Create An Empty File Without Opening It To Edit It?
Answer: 
You use the touch command to create an empty file without needing to open it. Answers a and e point to invalid commands, though either of these might actually be aliased to point to a real command. Answers b and c utilize editors, and so do not satisfy the requirements of the question. actually touch is used to change the timestamps of a file if its exits, otherwise a new file with current timestamps will be created.
 

Ques. 15): What Do You Type To Stop A Hung Process That Resists The Standard Attempts To Shut It Down?
Answer: 
The kill command by itself tries to allow a process to exit cleanly. You type kill -9 PID, on the other hand, to abruptly stop a process that will not quit by any other means. Also, pressing CtrI+C works for many programs. Answers b and d are only valid in some contexts, and even in those contexts will not work on a hung process.
 

Ques. 16): What Are The Techniques That You Use To Handle The Collisions In Hash Tables?
Answer: 
We can use two major techniques to handle the collisions. They are open addressing and separate chaining. In open addressing, data items that hash to a full array cell are placed in another cell in the array. In separate chaining, each array element consists of a linked list. All data items hashing to a given array index are inserted in that list.
 

Ques. 17): Why You Shouldn't Use The Root Login?
Answer: 
The root login does not restrict you in any way. When you log in as root, you become the system. The root login is also sometimes called the super user login. With one simple command, issued either on purpose or by accident, you can destroy your entire Linux installation. For this reason, use the root login only when necessary. Avoid experimenting with commands when you do log in as root.
 

Ques. 18): What Can You Type At A Command Line To Determine Which Shell You Are Using?
Answer: 
echo $SHELL-The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable’s name with $. Therefore, typing echo $SHELL will display the name of your shell.
 

Ques. 19): Is Linux Operating system Virus free?
Answer: 
No! There doesn’t exist any Operating System on this earth that is virus free. However Linux is known to have least number of Viruses, till date, yes even less than UNIX OS. Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.
 

Ques. 20): How do you change permissions under Linux?
Answer: 
Assuming you are the system administrator or the owner of a file or directory, you can grant permission using the chmod command. Use + symbol to add permission or – symbol to deny permission, along with any of the following letters: u (user), g (group), o (others), a (all), r (read), w (write) and x (execute). For example, the command chmod go+rw FILE1.TXT grants read and write access to the file FILE1.TXT, which is assigned to groups and others.