rh banner

Sunday, 4 January 2015

Unix / Linux - Tricky Interview Questions and Answers.

Unix / Linux - Tricky Interview Questions and Answers.

What is UNIX?

It is a portable operating system that is designed for both efficient multi-tasking and mult-user functions. Its portability allows it to run on different hardware platforms. It was written is C and lets user do processing and control under a shell.

Are Linux and UNIX are same ?

Linux kernel was built to work like UNIX but doesn’t use any of the UNIX code—this is why Linux is not UNIX. A kernel is the core of any operating system.

What is the core of Linux Operating System?

The core of the Linux operating system is Kernel. It is broken down into Shell, Command, Script, and Terminal. Shell is a command Line Interpreter, Command is user Instruction to Computer, Script is collection of commands stored in a file, and Terminal is a command Line Interface.

What is an MX record?

An MX record numerically ranks the mail servers you would prefer to receive email for a domain. The MX record with the lowest number is preferred over the others, but you can set multiple email servers with the same value for simple load balancing.

Please describe the Linux boot-up sequence.
There are seven steps to the boot-up sequence. 1) BIOS (basic input/output system) – executes the MBR where Boot Loader sits, 2) MBR- Master boot reads Kernel into memory, 3) GRUB (Grand Unified Bootloader) Kernel starts Init process, 4) Kernel – Kernel executes the /sbin/init program.  Init reads inittab, executes rc.sysinit, 5) Init – the rc script than starts services to reach the default run level and 6) Run level programs – these programs are executed from /etc/rc.d/rc*.dl/

What is a shell? What are their names?

The shell is the part of the system with which the user interacts. A Unix shell interprets commands such as “pwd”, “cd” or “traceroute” and sends the proper instructions to the actual operating system itself. The shells currently available areAns SH, BASH, CSH, TCSH, NOLOGIN, KSH. Other functions of a shell include scripting capability, path memory, multitasking, and file handling.

How do you search for a pattern and then replace it in an entire file?

You use Sed, or in Vi editor, the search uses character ‘s’ slash the pattern to be searched, slash the pattern to replace it with, slash ‘g’ which stands for entire file.

How do you list and flush all IPtables?

First you use the –L switch to view all the currently present rules and then –F to flush them.

What is a zombie?

Cheeky answers get bonus points for this one. But in the Linux world, a zombie process is the process  output of ‘ps’ by the presence of ‘Z’ in the STAT column. Zombies are essentially the premature processes whose mature parent processes died without reaping its children. Note that zombies can’t be killed with the usual ‘kill’ signal.

What are the differences among a system call, a library function, and a UNIX command?
A system call is part of the programming for the kernel. A library function is a program that is not part of the kernel but which is available to users of the system. UNIX commands, however, are stand-alone programs; they may incorporate both system calls and library functions in their programming.

Enumerate some of the most commonly used network commands in UNIX
– telnet – used for remote login
– ping – an echo request for testing connectivity
– su – user switching command
– ftp – file transfer protocol used for copying files
– finger – information gathering command

What are filters?

The term Filter is often used to refer to any program that can take input from standard input, perform some operation on that input, and write the results to standard output. A Filter is also any program that can be used between two other programs in a pipeline.

Is there a way to erase all files in the current directory, including all its sub-directories, using only one command?

Yes, that is possible. Use “rm –r *” for this purpose. The rm command is for deleting files. The –r option will erase directories and subdirectories, including files within. The asterisk represents all entries.

What is the chief difference between the –v and –x option s to set?

The –v option echoes each command before arguments and variables have been substituted for; the –x option echoes the commands after substitution has taken place.

What is Shell?

A shell acts as an interface between the user and the system. As a command interpreter, the shell takes commands and sets them up for execution.

Briefly describe the Shell’s responsibilities
– program execution
– variable and file name substitution
– I/O redirection
– pipeline hookup
– environment control
– interpreted programming language

19) What are shell variables?

Shell variables are a combination of a name ( identifier), and an assigned value, which exist within the shell. These variables may have default values, or whose values can be manually set using the appropriate assignment command. Examples of shell variable are PATH, TERM and HOME.

What is Kernel?

Kernel is the UNIX operating system. It is the master program that controls the computer’s resources, allotting them to different users and to different tasks. However, the kernel doesn’t deal directly with a user. Instead, it starts up a separate, interactive program, called a shell, for each user when he/she logs on.

What are the key features of the Korn Shell?

– history mechanism with built-in editor that simulates emacs or vi
– built-in integer arithmetic
– string manipulation capabilities
– command aliasing
– arrays
– job control

What are some common shells and what are their indicators?

sh – Bourne shell
csh – C SHell
bash – Bourne Again Shell
tcsh – enhanced C Shell
zsh – Z SHell
ksh – Korn SHell

What is command substitution?

Command substitution is one of the steps being performed every time commands are processed by the shell. Commands that are enclosed in backquotes are executed by the shell. This will then replace the standard output of the command and displayed on the command line.

Differentiate multiuser from multitask.
Multiuser means that more than one person can use the computer at the same time. Multitask means that even a single user can have the computer work on more than one task or program at the same time.

What is inode?

An inode is an entry created on a section of the disk set aside for a file system. The inode contains nearly all there is to know about a file, which includes the location on the disk where the file starts, the size of the file, when the file was last used, when the file was last changed, what the various read, write and execute permissions are, who owns the file, and other information.

Differentiate relative path from absolute path.
Relative path refers to the path relative to the current path. Absolute path, on the other hand, refers to the exact path as referenced from the root directory.

Explain the importance of directories in a UNIX system
Files in a directory can actually be a directory itself; it would be called a subdirectory of the original. This capability makes it possible to develop a tree-like structure of directories and files, which is crucial in maintaining an organizational scheme.

What is Bash Shell?

It is a free shell designed to work on the UNIX system. Being the default shell for most UNIX-based systems, it combines features that are available both in the C and Korn Shell.