Mindtree Frequently Asked Linux Interview Questions

How To Unset Or De-assign Variables?

‘unset’ command is used to de-assign or unset a variable.

Syntax is shown below

# unset <Name_of_Variable>

How To Perform Arithmetic Operation?

There are two ways to perform arithmetic operations

Using expr command (# expr 5 + 2).
Using a dollar sign and square brackets ( $[ operation ] ) Example : test=$[16 + 4] ; test=$[16 + 4].

Explain What Is Semaphore?

A semaphore is an abstract datatype or variable that is used for controlling access, by multiple processes to a common resource in a concurrent system such as multiprogramming operating system.  Semaphores are commonly used for two purposes

• To share a common memory space
• To share access to files

When One Must Use Recursion Function? Mention What Happens When Recursion Functions Are Declared Inline?

Recursion function can be used when you are aware of the number of recursive calls is not excessive. Inline functions property says whenever it will called, it will copy the complete definition of that function. Recursive function declared as inline creates the burden on the compilers execution.

Explain Whether We Can Use Semaphore Or Mutex Or Spinlock In Interrupt Context In Linux Kernel?

Semaphore or Mutex cannot be used for interrupt context in Linux Kernel. While spinlocks can be used for locking in interrupt context.

What Is The Need For An Infinite Loop In Embedded Systems?

Infinite Loops are those program constructs where in there is no break statement so as to get out of the loop, it just keeps looping over the statements within the block defined.

Example

While(Boolean True) OR for(;;);
{
//Code
}

Embedded systems need infinite loops for repeatedly processing/monitoring the state of the program. One example could be the case of a program state continuously being checked for any exceptional errors that might just occur during run time such as memory outage or divide by zero etc.,
Mindtree Frequently Asked Linux Interview Questions Answers
Mindtree Frequently Asked Linux Interview Questions Answers

A Vast Majority Of High Performance Embedded Systems Today Use Risc Architecture Why?

•According to the instruction sets used, computers are normally classified into RISC and CISC. RISC stands for 'Reduced Instruction Set Computing' . The design philosophy of RISC architecture is such that only one instruction is performed on each machine cycle thus taking very less time and speeding up when compared to their CISC counterparts.
•Here the use of registers is optimised as most of the memory access operations are limited to store and load operations.
•Fewer and simple addressing modes, and simple instruction formats leads to greater efficiency, optimisation of compilers, re-organisation of code for better throughput in terms of space and time complexities. All these features make it the choice of architecture in majority of the Embedded systems.
•CISC again have their own advantages and they are preferred whenever the performance and compiler simplification are the issues to be taken care of.

Why Do We Need Virtual Device Drivers When We Have Physical Device Drivers?

Device drivers are basically a set of modules/routines so as to handle a device for which a direct way of communication is not possible through the user's application program and these can be thought of as an interface thus keeping the system small providing for minimalistic of additions of code, if any.

Physical device drivers can’t perform all the logical operations needed in a system in cases like IPC, Signals and so on...

The main reason for having virtual device drivers is to mimic the behaviour of certain hardware devices without it actually being present and these could be attributed to the high cost of the devices or the unavailability of such devices.

These basically create an illusion for the users as if they are using the actual hardware and enable them to carryout their simulation results.

Examples could be the use of virtual drivers in case of Network simulators,also the support of virtual device drivers in case a user runs an additional OS in a virtual box kind of a software.

What Does Nslookup Do? Explain Its Two Modes.

Nslookup is used to find details related to a Domain name server. Details like IP addresses of a machine, MX records, servers etc. It sends a domain name query packet to the corresponding DNS.

Nslookup has two modes. Interactive and non interactive. Interactive mode allows the user to interact by querying information about different hosts and domains.

Non interactive mode is used to fetch information about the specified host or domain.

Interactive mode
Nslookup [options] [server]

What Is Bash Shell?

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.

What Are Two Functions The Move Mv Command Can Carry Out?

The mv command moves files and can also be used to rename a file or directory.

What Does The Top Command Display?

Top provides an ongoing look at processor activity in real time.It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive inter¬ face for manipulating processes. (q is to quit)

How To Find Difference In Two Configuration Files On The Same Server?

Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf

What Is The Best Way To See The End Of A Logfile.log File?

Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)

Please Write A Loop For Removing All Files In The Current Directory That Contains A Word 'log'?

for i in *log*; do rm $i; done

How To Switch To A Previously Used Directory?

cd -

What Are The Process States In Linux?

Process states in Linux
Running: Process is either running or ready to run.

Interruptible: a Blocked state of a process and waiting for an event or signal from another process.

Uninterruptible:- a blocked state. Process waits for a hardware condition and cannot handle any signal.

Stopped: Process is stopped or halted and can be restarted by some other process.

Zombie: process terminated, but information is still there in the process table.

What Is A Zombie?

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.

Explain Each System Calls Used For Process Management In Linux.

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

How Do You List Files In A Directory?

ls - list directory contents
ls -l (-l use a long listing format)

How Do You List All Files In A Directory, Including The Hidden Files?

ls -a (-a, do not hide entries starting with .)

How Do You Find Out All Processes That Are Currently Running?

ps -f (-f does full-format listing.)

How Do You Find Out The Processes That Are Currently Running Or A Particular User?

ps -au Myname (-u by effective user ID (supports names)) (a - all users)

How Do You Kill A Process?

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)

What Would You Use To Edit Contents Of The File?

vi screen editor or jedit, nedit or ex line editor

What Would You Use To View Contents Of A Large Error Log File?

tail -10 file_name ( last 10 rows)

How Do You Log In To A Remote Unix Box?

Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))

How Do You Get Help On A Unix Terminal?

man command_name
info command_name (more information)

Post a Comment

Previous Post Next Post