February 13, 2019

Srikaanth

Mphasis Frequently Asked Linux Interview Questions Answers

What Utility Would You Use To Replace A String '2001' For '2002' In A Text File?

Grep, Kde( works on Linux and Unix)

What Utility Would You Use To Cut Off The First Column In A Text File?

awk, kde

How To Copy File Into Directory?

cp /tmp/file_name . (dot mean in the current directory)

How To Remove Directory With Files?

rm -rf directory_name

What Is Linux Shell?

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.

What Is Shell Script?

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.
Mphasis Frequently Asked Linux Interview Questions Answers
Mphasis Frequently Asked Linux Interview Questions Answers

What Is Kernel? Explain The Task It Performs.

Kernel is used in UNIX like systems and is considered to be the heart of the operating system. It is responsible for communication between hardware and software components. It is primarily used for managing the systems resources as well.

Kernel Activities

The Kernel task manager allows tasks to run concurrently.

Managing the computer resources: Kernel allows the other programs to run and use the resources.

Resources include i/o devices, CPU, memory.

Kernel is responsible for Process management. It allows multiple processes to run simultaneously allowing user to multitask.

Kernel has an access to the systems memory and allows the processes to access the memory when required.

Processes may also need to access the devices attached to the system. Kernel assists the processes in doing so.

For the processes to access and make use of these services, system calls are used.

What Are Pipes?

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)

Explain Trap Command; Shift Command, Getopts Command Of Linux

Trap command: controls the action to be taken by the shell when a signal is received.
Trap [OPTIONS] [ [arg] signspec..]
Arg is the action to be taken or executed on receiving a signal specified in signspec.
e.g. trap “rm $FILE; exit” // exit (signal) and remove file (action).

Shift Command: Using shift command, command line arguments can be accessed. The command causes the positional parameters shift to the left. Shift [n] where n defaults to 1. It is useful when several parameters need to be tested.

Getopts command: this command is used to parse arguments passed. It examines the next command line argument and determines whether it is a valid option.

Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if a letter is followed by a colon, an argument should be specified. E.g (whether the argument begins with a minus sign and is followed by any single letter contained inside options ) If not, diagnostic messages are shown. It is usually executed inside a loop.

Where Is Standard Output Usually Directed?

By default, your shell directs standard output to your screen or display.

What Is The Difference Between Ctrl-c And Ctrl-z?

When you have a process in progress which handle your prompt, there are some signals (orders) that we can send to theses process to indicate what we need

Control+C sends SIGINT which will interrupt the application. Usually causing it to abort, but a process is able to intercept this signal and do whatever it likes: for instance, from your Bash prompt, try hitting Ctrl-C. In Bash, it just cancels whatever you've typed and gives you a blank prompt (as opposed to quitting Bash)

Control+Z sends SIGTSTP to a foreground application, effectively putting it in the background on suspended mode. This is very useful when you want the application to continue its process while you are doing another job in the current shell. When you finish the job, you can go back into the application by running fg (or %x where x is the job number as shown in jobs).

I Want To Troubleshoot My Network But I Don’t Know How Does The Traceroute Command Work Exactly?

Traceroute is a program that shows you the route taken by packets through a network. It traces the route of packets from source to destination. It is commonly used when your network doesn’t work as well and you want to examine where can be the problem. Traceroute sends a UDP packet to the destination taking advantage of ICMP’s messages. ICMP has two types of messages: error-reporting messages and query messages. Query messages are generally used to diagnose network problems (the ping tool uses ICMP’s query messages). The error-reporting messages as the name suggest report errors if any in the IP packet; it uses Destination unreachable and Time exceeded errors message. It works by theses steps

Traceroute creates a UDP packet from the source to destination with a TTL(Time-to-live) = 1
The UDP packet reaches the first router where the router decrements the value of TTL by 1, thus making our UDP packet’s TTL = 0 and hence the packet gets dropped.
Noticing that the packet got dropped, it sends an ICMP message (Time exceeded) back to the source.
Traceroute makes a note of the router’s address and the time taken for the round-trip.
It sends two more packets in the same way to get an average value of the round-trip time. Usually, the first round-trip takes longer than the other two due to the delay in ARP finding the physical address, the address stays in the ARP cache during the second and the third time and hence the process speeds up.

The steps that have occurred up til now, occur again and again until the destination has been reached. The only change that happens is that the TTL is incremented by 1 when the UDP packet is to be sent to next router/host.
Once the destination is reached, Time exceeded ICMP message is NOT sent back this time because the destination has already been reached.
But, the UDP packet used by Traceroute specifies the destination port number to be one that is not usually used for UDP. Hence, when the destination computer verifies the headers of the UDP packet, the packet gets dropped due to the improper port being used and an ICMP message (this time – Destination Unreachable) is sent back to the source.
When Traceroute encounters this message, it understands that the destination has been reached. Even the destination is reached 3 times to get the average of the round-trip time.

What Stateless Linux Server? What Feature It Offers?

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.

What Is The Difference Between Internal And External Commands?

Internal commands are stored in the; same level as the operating system while external commands are stored on the hard disk among the other utility programs.

List The Three Main Parts Of An Operating System Command

The three main parts are the command, options and arguments.

What Is The Difference Between An Argument And An Option (or Switch)?

An argument is what the command should act on: it could be a filename, directory or name. An option is specified when you want to request additional information over and above the basic information each command supplies.

What Is The Purpose Of Online Help?

Online help provides information on each operating system command, the syntax, the options, the arguments with descriptive information.

Name Two Forms Of Security.

Two forms of security are Passwords and File Security with permissions specified.

What Command Do You Type To Find Help About The Command Who?

$ man who

What Is The Difference Between Home Directory And Working Directory?

Home directory is the directory you begin at when you log into the system. Working directory can be anywhere on the system and it is where you are currently working.

Which Directory Is Closer To The Top Of The File System Tree, Parent Directory Or Current Directory?

The parent directory is above the current directory, so it is closer to the root or top of the file system.

What Are Two Subtle Differences In Using The More And The Pg Commands?

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.

When Is It Better To Use The More Command Rather Than Cat Command?

It is sometimes better to use the more command when you are viewing a file that will display over one screen.

Subscribe to get more Posts :