Showing posts with label Unix Interview Questions. Show all posts
Showing posts with label Unix Interview Questions. Show all posts

Saturday, October 19, 2013

The Fundamentals of Unix


This chapter focuses on understanding the Unix architecture, the features of Unix operating systems and other aspects about Unix.


Unix Architecture

To explain the concepts in the most simplified way, let's take an example of your personal computer running Windows operating system. 

Your personal computer monitor, keyboard, processor, HDD, Memory, Optical drive, USB drive etc constitutes the Hardware. You just can't have only the hardware for functioning. You need a Software too. This software is your operating system ( Windows). The operating system comprises of Kernel, Command interpreter, applications, databases etc.  The kernel is the core of any operating system. The command prompt ( Non GUI) or a Mouse Click ( GUI) is where you give the input. This can be imagined to be a Interpreter for the user to give inputs. These inputs are passed on to the Operating system kernel for the actual processing. The output is finally given back to the hardware ( monitor or speaker or printer) mainly by the kernel.

With above the above example, I'd like to illustrate the Unix architecture in almost the similar fashion. Every Unix architecture consists of 
1) Hardware
2) Kernel
3) Shell
4) Applications
5) End user.

The schematic representation is illustrated below

Hardware 
This is the Physical component of your computer. It consists of Monitor, Mouse,Keyboard, Network Card, Memory, Processor.

Kernel.
The kernel is the core of the operating system. The kernel interacts with the machine hardware. It also interacts with the Software. Example : Linux Kernel.   The kernel consists of C language written sub-routines which makes it possible for it to communicate with the Hardware and Software. When you boot your machine, the kernel component gets loaded first.
Applications uses the services of kernel. These applications (software's) access kernel through system calls.
Kernel manages the machine's memory, it schedules system processes.

Shell
The Shell is a command line interpreter. It's an interface between the user and kernel. Any command you type in will be forwarded to the kernel for execution.

System calls
These are programs ( functions ) used by user program to access the kernel services to interact with hardware. Example : Open system call, Write system call.
When a user opens a new file. ie he clicks on the mouse and creates a new file, the input is read by shell which then passes to the kernel which calls the "Read system call" function. This read system call function gets executed which ultimately allows a new file to be created. The final output is visible on your hardware ( monitor)



Features of UNIX


1) Files and Process 
       Unix treats everything in the system as files. The hardware is also treated as a file. A directory is also treated as a file. 


2) Multiuser system
Unix allows multiprocessing or multiusers to access the system (CPU).


3) Multitasking system

UNIX is a multitasking system which allows a user to run multiple tasks concurrently. You can edit a file, print a file, e-mail a file and browse the internet simultaneously. 


4) Building Block architecture.

UNIX doesn't have a single command that can do a job at one shot. Instead it has thousand of commands which when combined can do any tasks with ease and perfection. Example ls and wc commands are combined using pipes to get the files listing and line count. 
In simple words, small commands are combined together to get your task done. 


5) UNIX tools

UNIX has beautiful structure of applications and toolkit. It has general purpose tools, text manipulation tools, filters, compilers, interpreters, networked applications, system administration tools and many more.


6) Pattern matching

UNIX has simple expression or characters called as meta characters which are used to match lengthy patterns and long listing of files. The metacharacter (*) is mostly used in pattern matching techniques.

7)  Documentation

UNIX has extensively written documentation about every single command, tools, and it's system. If you need any help or information on a command, you can easily refer to its documentation. 

Essentials of Unix



This chapter focuses on the pre-requisites to learn Unix, Hardware & Software requirements and Outcomes of mastering Unix.

First things you need prior to start learning Unix


1) A Basic Unix book that covers most of the topics. Your RHCE, Solaris Administration, Unix System Programming are advanced books. Keep them later after you master the basics.

2) A X-86 architecture machine on which you should have Linux ( Red Hat, Fedora Core or Ubuntu) installed. If you have a Windows Operating system, have any Virtual machine software installed like VMware workstation and on it, install any Linux, Solaris flavours.  For HP-UX and AIX, you should preferably use their own properietary hardwares. 
You can easily learn the Unix basics and master it through Linux Kernel. 

Tips : Google VMware Workstation and learn about it.
          Unix Executable can be downloaded here on the below link
          Eduunix.ccut.edu.cn

3) Linux doesn't require powerful hardware. You can install a Linux version on a Pentium machine with 128 MB RAM and 500 MB hard disk space.

Tips : 

To Install Linux, UNIX on your computer/machine, refer to the installation manual that came with the Linux executable. Search for easy installation reference guides on the internet and use video tutorials from any video sharing site on the internet.  Installation of Linux is easy.


Do I need to know any programming languages to learn Linux/Unix ?

An understanding of Computers is enough to learn the basics of Unix commands. To learn Unix Shell Scripting ( Programming ), you should have a basic knowledge of C language.

What can I gain by learning Unix ?

Unix will enable you to choose varied career roles. You can be a Unix technician, System Administrator, Network Engineer, Unix Developer, Red Hat Certified Engineer, Solaris Administrator, Perl language expert. One can choose a career in Unix Research and academics. There are endless possibilities.  You can develop your own Kernel and Operating system too. There are many certification course you can take up to master your skills. The courses are Junior Linux Administration, Red Hat Certified Technician ( RHCT), Red Hat Certified Engineer ( RHCE).
Unix is Simple. Unix is Powerful and Unix is beautiful. 




The History of Unix Operating System


First Things You should know about UNIX


What is Unix ?

Unix is a Operating Environment. It can also be called as a Operating System.  It's Origin is the "Unix system" developed by AT&T Bell labs.
Unix is a powerful Operating system which is more than 40 years since it was developed. It was developed before the advent of DOS and Windows operating system.
The Present day Unix system has many contributions made by IT industry and the student community worldwide. The open source movement is mainly due to Unix.


Give us a history on how Unix was developed ?

Unix was developed by Ken Thompson and Dennis Ritchie. In 1965, Bell Telephone Labs, General Electric, MIT (Project Mac) worked on  MULTICS project. It also had a team of AT&T Engineers. The Project didn't materialize giving the intended results. This made AT&T back out of this project in 1969 and it resulted in Dennis and Thompson design and develop a system having it's own file system, utilities and command line interpreter. This however wasn't machine independent system and wasn't capable to run on different hardware.

Dennis who is the founder of C language rewrote this system in C language in 1973. This resulted in the Unix system become portable on different hardware. The different versions of this system was known to be 
Editions, Systems, Systems III, Systems V Release 3.0, Systems V Release 3.2. The Final version was called as Unix System.


What does Unix Translate to ?

According to Dennis Ritchie in his 1974 CACM's ( Communications of the ACM) paper, UNIX ( All - Caps) meant "The Unix-Time Sharing System".  Dennis Ritchie believed that it should be used in Small caps letter as "Unix" since it doesn't have any Acronym. Hence the right usage of the word should be "Unix" and not "UNIX". 


Tell us more on what happened to AT&T and it's Unix system?

AT&T had plans to sell it's Systems V Release 3.2 commercially. This idea didn't get approval from the U.S government and this made AT&T distribute the software to Academic and research institutes. This resulted in the birth of BSD Unix.


BSD Unix

BSD Unix is Berkeley Software Distribution developed by "The University of California, Berkeley (UCB). They developed this system from the System V Release 3.2 version developed by AT&T. The BSD gathered worldwide attention and attracted universities and the students.
Further developments resulted in Berkeley rewrite their BSD Unix in their way. This resulted in developments of standard vi editor, c shell, TCP/IP, better file system, mail features and linking of files (symbolic links).
BSD Unix is the foundation of Solaris. Sun Micro systems used BSD as a foundation for the development of their own UNIX ( Sun OS). Sun Micro systems has now been acquired by Oracle and the Sun OS is called as "Oracle Solaris"


What are the Main Unix Flavors of BSD Unix ?

FreeBSD, NetBSD and OpenBSD.

What is System V Release 4 ( SVR4) ?

As different vendors created their own version of Unix, BSD release had incompatibilities and differed very much from the AT&T version.  Hence AT&T reworked on the BSD product, System V 3.2, Sun OS and Microsoft's Unix version namely XENIX. They made the final version called as the System V Release 4 SVR4.


What happened later with AT&T after System V Release 4 (SVR4) ?


AT&T sold Unix to Novell. Novell then sold the rights to X/OPEN.  X/Open merged with The Open Group.

Name the Different Flavors of Unix ?

Solaris by Oracle Solaris, AIX by IBM, HP-UX by Hewlett Packard, Tru64 UNIX (Discontinued) by Digital Equipment Corporation and lastly owned by HP, Linux by Red Hat, SUSE by Novell, CentOS, Fedora, Ubuntu, Debian.


POSIX and SINGLE UNIX SPECIFICATION.


These are two different Standard bodies in the Unix world. During the earlier years of development of Unix, it wasn't completely portable and this affected the development of applications that can be easily ported on various flavors of Unix and their hardware. 

AT&T had their own standard mechanism called as System V interface definition. The X/Open ( The open Group) had their own. There was a standard called as POSIX ( Portable Operating System Interface for Computing Environments) developed by IEEE ( Institute of Electrical and Electronics Engineers). POSIX standards were based on Unix and they had two versions called POSIX.1 and POSIX.2.   

Later, The Open Group and IEEE worked together to bring a common standard by unifying the X/Open and POSIX. This is known as "The Single  UNIX specification". It was later approved by ISO ( International Organisation of Standardization). Today UNIX is owned by the The Open Group and most of the UNIX flavors are POSIX compliant.


Open Source and Free Software Foundation


Open source and free software foundation are almost identical except that fact that "Free Software" doesn't really mean that the software can be purchased free of cost. In most cases, the Free software is indeed free of cost, but only in few cases, you may be charged a fee for support or Royality

Both Open source and free software foundation preaches the usage of software freely, modify the source code and share the software to any number of people freely.

The free software comes with a GNU pronounced "guh-noo" ( GNU Not Unix !) license. Linux is one such Unix flavor which comes with a GNU license.



What is Linux ?

Linux is a Kernel. It's inappropriate to term it as a "Operating system". Linux was developed by Linus Torvalds, a student of the Helsinki University.

Linux is a Kernel because most of the applications in Linux are due to the outcome of GNU project. Hence if Linux has to be known as a operating system, it should be called as GNU/Linux.



What are the different GNU/Linux flavors ?

Red Hat, Calder, SuSE Linux, Debian, Mandrake, Fedora. There are Ubuntu and CentOS too.