Anda di halaman 1dari 13

Q: History of UNIX

AT & T

Developed UNIX in 1969 by Ken Thompson and Dennis Ritchie.


Originally written in assembler, UNIX was rewritten in 1973 in C which
make it possible to maintained and move it to different hardware
platform.

BSD

University California, Berkeley recreates UNIX and named BSD UNIX


(Berkeley software distribution). It added most of the powerful feature
s like vi editor (by Bill joy), C shell, better file system, TCP/IP protocol.
All Berkeley feature incorporated in SVR4 (System V Release 4)

SCO
IBM
HP
DEC
Silicon Graphic

Sun used SVR4 and contributed NFS(Network file system) feature and
create sun solaris
Product is XENIX
XENIX sold off by Sana Cruz Operation and created most commercial
brand with different flavor SCO Unix, SCO open server release 5 and
SCO UnixWare 7
AIX
HP-UX
Digital Equipment Corporation created Digital Unix
IRIX

Novell
POSIX
MIT

AT & T sold off by novell and create standard for unix called X/OPEN
should be X/OPEN Compliant
Standard created by this name
Produce X Window a first GUI for UNIX

GNU

Ricard Stallman is the founder of Free software foundation (Formally


known as GNU)

Linux

Linus Torvalds is the father of Linux. Now different flavor is available


RedHat, Ubuntu, CentOs

SUN
Microsoft

UNIX Features

Portable
Open System
Multi user system
Multi tasking system
Patter matching
Tool kit
Shell programming
Windowing system
Background processing
Redirection tool
Hierarchical file system

What is Kernal and Shell?

Shell is responsible for analyzing and interpreting the command. Kernal responsible
for command execution. Kernal is the heart of the system. It is the part of the unix
system that is loaded into memory when the system is booted. It manages the
system resources, allocate time between user and processes, decide process
priorities etc.

What is system call?


A basic routine defined in the kernel which lets a user remain transparent to all
complex processes in a UNIX system. Such routine perform file handling, creating a
pipe or generating a process. All command and programs are written in terms of
system call.

Unix and linux


Unix was developed using C Language. Unix was the foundation on which Linux was
built.
Unix has Character based environment while Linux has Graphical as well as
Character based environment.
Unix has less numbers of utilities & Features as compare to Linux.Ex: Number of
shells and editors available in Linux is more than Unix.
Linux follows the Free Software Foundation's radical licensing model, which provides
a great deal of liberty to those that interact with Linux technology. This means that
vendor lock-in is less of an issue with Linux than it is with other UNIX offerings.
Although Linux runs on many kinds of equipment, it is best known for its support of
commodity IBM-Intel PC-based hardware.

Kernel and micro kernel


The kernel is the part of the Operating System(OS) that interacts directly with the
hardware of computer ,through device drivers that are built into the kernel. It
provides set of services that can be used by programs ,insulating these programs
from the underlying hardware. A micro-kernel is a minimal operating system that

performs only the essential functions of an operating system. All other operating
system functions are performed by system processes.

What is the difference between binaries in /bin, and /usr/bin?


Under Solaris, there is no difference. /bin is a symbolic link pointing to /usr/bin.
Under Linux (RHAS3) /bin is seemingly for standard unix programs like vi, cp, mv,
rm which you'd need in a single user environment where as /usr/bin contains
programs you'd want for a multiuser environment. Keep in mind that sometimes
/usr is a different disk partition and when you start up in single user mode you only
have / mounted.
The /sbin directories are *supposed to* contain statically linked programs. This mas
morphed into the idea of bin for user programs, sbin for admin programs.

Disadvantage of at command
There is no way you can find out the name of the program scheduled to be executed

Difference between at and batch


Batch scheduling is done in such a way that jobs are executed as soon as the
system load permits. Batch does not take any argument and uses the internal
algorithm to decide when the job will be executed.

Difference between head/tail and cut


head/tail slice a file horizontally and cut are used to slice a file vertically

Pros and cons of find command


It recursively examines a directory tree to look for files matching some criteria.
It doesn't return a non-zero exit status when it fails to find a file. Due to that tar or
cpio can't use its exit status to determine whether to proceed with a backup at all.

Limitation of uniq command


Uniq uses only one file at a time. If you provide two file then it process the first file
and overwrites the second with it's output and file need to be sorted before uniq
command.

What is internal and external command?


Program or file having an independent existence in the /bin directory is called
external command like ls.
Some built-in command which don't found anywhere called internal command like
echo.

What is environment or system variable?

The UNIX system is controlled by a number of shell variables that are separately set
by the system, some during the boot sequence and some after logging in. These
variables are called system variables.
HOME - when you log in, UNIX normally place you in a directory named after your
login name
IFS - word separator in command line can contain space, tab and newline
LOGNAME - shows your user name
MAIL - where all incoming mail addressed to the user is to be stored
PATH - instruct the shell about the route it should follow to locate any executable
command.
PS1 - set the primary prompt like $
PS2 - secondary prompt when multiline command make the shell respond like > in
case of echo
SHELL - determine the type of shell that a user sees on logging in. bash is standard
linux shell
TERM - terminal type being used.

What is a zombie process?


When a process finishes execution, it will have an exit status to report to its parent
process. Because of this last little bit of information, the process will remain in the
operating system's process table as a zombie process, indicating that it is not to be
scheduled for further execution, but that it cannot be completely removed (and its
process ID cannot be reused) until it has been determined that the exit status is no
longer needed. When a child exits, the parent process will receive a SIGCHLD signal
to indicate that one of its children has finished executing; the parent process will
typically call the wait()system call at this point. That call will provide the parent with
the child's exit status, and will cause the child to be reaped, or removed from the
process table. To see a Zombie process Run ps aux and look for a Z in the STAT
column.

How do I remove zombie processes from a system?


Well, first you can wait. It's possible that the parent process is intentionally leaving
the process in a zombie state to ensure that future children that it may create will
not receive the same pid. Or perhaps the parent is occupied, and will reap the child
process momentarily.
Secondly, you can send a SIGCHLD signal to the parent ("kill -s SIGCHLD <ppid>").
This will cause well-behaving parents to reap their zombie children.
Finally, you can kill the parent process of the zombie. At that point, all of the
parent's children will be adopted by the init process (pid 1), which periodically runs
wait() to reap any zombie children.

Buffering vs Caching
In general, buffering is the process of holding data in a region of the memory until
the data is transported from one place to another. Buffering is used when moving
data between processes in the computer and in telecommunication. Typically,
buffering is required when there is difference between the speeds in which the data

is received and data is processed. Caching is the process of storing data in a


separate place (called the cache) such that they could be accessed faster if the
same data is requested in the future. When some data is requested, the cache is
first checked to see whether it contains that data. If data is already in the cache, the
request can be satisfied faster.

Paging vs Swapping
Paging is a memory management method used by operating systems. Paging allows
the main memory to use data that is residing on a secondary storage device. These
data are stored in the secondary storage device as blocks of equal size called
pages. Paging allows the operating system to use data that will not fit in to the main
memory. Swapping is a term that is used to describe the act of moving all the
segments belonging to a process between the main memory and a secondary
storage device.

What is the difference between Paging and Swapping?


In paging, blocks of equal size (called pages) are transferred between the main
memory and a secondary storage device, while in swapping, all the segments
belonging to a process will be moved back and forth between the main memory and
a secondary storage device. Since paging allows moving pages (it could be a part of
the address space of a process), it is more flexible than swapping. Since, paging
only moves pages (unlike swapping, which move a whole process), paging would
allow more processes to reside on the main memory at the same time, when
compared with a swapping system. Swapping is more suitable when running heavier
workloads.

Q: Absolute and alternative pathname


Absolute pathname begin with / signify that the tree walking begins from root. This
use used if the file or directory is not present in current directory. And if file or
directory exist in current directory the use alternative pathname with dir/.

Q: What is Kernal and Shell?


Shell is responsible for analyzing and interpreting the command
Kernal responsible for command execution. Kernal is the heart of the system. It is
the part of the unix system that is loaded into memory when the system is booted.
It manages the system resources, allocate time between user and processes, decide
process priorities etc.

Q: Shell and Shell Script


A shell is an environment in which we can run our commands, programs, and shell
scripts. There are different flavors of shells

The basic concept of a shell script is a list of commands, which are listed in the
order of execution.
Shell scripts and functions are both interpreted.

Q: What is system call?


A basic routine defined in the kernel which lets a user remain transparent to all
complex processes in a UNIX system. Such routine perform file handling, creating a
pipe or generating a process. All command and programs are written in terms of
system call.

Q: What is Daemon?
It is a process that runs in a background. The parent process of daemon is often init
process(PID=1). A process is usually become daemon by forking a child process and
then having their parent process immediately exit, thus causing init to adopt the
child process.

Q: Permission on files

Q: What is
internal and
external
command?
Program or file
having an
independent existence in the /bin directory is called external command like ls.
Some built-in command which dont found anywhere called internal command like
echo.

. profile file detils?


This is the script executed during login time and created when a user is added to
the system by the system administrator. The .profile must be located in your home
directory and it is executed after /etc/profile, the universal profile for all users kept
by the system administrator.

Systme call ?
a system call is how a program requests a service from an operating system's
kernel.
Generally, systems provide a library or API that sits between normal programs and
the operating system. On Unix-like systems, that API is usually part of an
implementation of the C library (libc), such as glibc, that provides wrapper functions
for the system calls, often named the same as the system calls that they call.
For example, in Unix-like systems, "fork" and "execve" are C library functions that in
turn execute instructions that invoke the "fork" and "execve" system calls. Making
the system call directly in the application code is more complicated and may require
embedded assembly code to be used (in C and C++) as well as knowledge of the
low-level binary interface for the system call operation, which may be subject to
change over time and thus not be part of the application binary interface; the
library functions are meant to abstract this away.

Filesystem and Mount point


Filesystem refers to the actual device holding the data. Mount is a logical concept of
mapping of a filesystem device to a path.
A file system basically tells you how stuff is laid out on the underlying (physical)
medium, while the mount point gives the path to where the information from the file
system will be accessible later.
You can mount a physical file system (or part of it) to a different logical node, called
a 'mount point'. This means, your physical file system root / can be mounted to
your logical "directory" /my/logical/mount.
If your physical file system contains a file rootfile in its physical root directory, you
may access exactly that file by its logical name /my/logical/mount/rootfile.

Profile
Classically, ~/.profile is used by Bourne Shell, and is probably supported by Bash
as a legacy measureand it is read by "login" shells
The ~/.bash_profile would be used once, at login.
The ~/.bashrc script is read every time a shell is started.

Bash is a Bourne-like shell. It reads commands from ~/.bash_profile when it is


invoked as the login shell, and if that file doesn't exist, it tries reading ~/.profile
instead.

Therefore:
is the place to put stuff that applies to your whole session, such as programs
that you want to start when you log in (but not graphical programs, they go into a
different file), and environment variable definitions.

~/.profile

~/.bashrc

is the place to put stuff that applies only to bash itself, such as alias and
function definitions, shell options, and prompt settings. (You could also put key bindings
there, but for bash they normally go into ~/.inputrc.)

~/.bash_profile can be used instead of ~/.profile, but you also need to include
~/.bashrc if the shell is interactive.

Execution sequence of .bash_* files


/etc/profile
~/.bash_profile
~/.bashrc
~/.bash_login
~/.profile
~/.bash_logout

Interestingly, it seems that many search engines want to provide my blog as a result when folks want to know
something about zombie processes, even though this site has nothing to do with them per se. As such, I will discourse
for a bit on the seemingly morbid topic of Zombie Processes, this sites namesake.

What is a zombie process?

When a process finishes execution, it will have an exit status to report to its parent process. Because of this last little
bit of information, the process will remain in the operating systems process table as a zombie process, indicating that
it is not to be scheduled for further execution, but that it cannot be completely removed (and its process ID cannot be
reused) until it has been determined that the exit status is no longer needed.
When a child exits, the parent process will receive a SIGCHLD signal to indicate that one of its children has finished
executing; the parent process will typically call the wait()system call at this point. That call will provide the parent
with the childs exit status, and will cause the child to be reaped, or removed from the process table.

How do I see if there are zombie processes on a system?


Run ps aux and look for a Z in the STAT column.
How do I remove zombie processes from a system?
Well, first you can wait. Its possible that the parent process is intentionally leaving the process in a zombie state to
ensure that future children that it may create will not receive the same pid. Or perhaps the parent is occupied, and
will reap the child process momentarily.
Secondly, you can send a SIGCHLD signal to the parent (kill -s SIGCHLD <ppid>). This will cause wellbehaving parents to reap their zombie children.
Finally, you can kill the parent process of the zombie. At that point, all of the parents children will be adopted by the
init process (pid 1), which periodically runs wait() to reap any zombie children.

Buffering vs Caching
In general, buffering is the process of holding data in a region of the memory until the data is transported
from one place to another. Buffering is used when moving data between processes in the computer and in
telecommunication. Typically, buffering is required when there is difference between the speeds in which
the data is received and data is processed. Caching is the process of storing data in a separate place
(called the cache) such that they could be accessed faster if the same data is requested in the future.
When some data is requested, the cache is first checked to see whether it contains that data. If data is
already in the cache, the request can be satisfied faster.
What is Buffering?
Buffering is the process of holding data in a region of the memory until the data is transported from one
place to another. This region of memory that holds the data is called a buffer. Buffering is used when there
is a difference between the speed in which the data is received and the speed in which the data is
processed. Even though buffering can be implemented using hardware buffers or software buffers, most
widely used are the software buffers. Buffering is widely used in printer spooler, online video streaming
and telecommunication (when transferring data from one device to another). Most of the time, buffering is
done by writing data in to a queue in one speed and reading the data from the queue in another speed.
What is Caching?
Caching is the process of storing data in a separate place (called the cache) such that they could be
accessed faster if the same data is requested in the future. When some data is requested, the cache is
first checked to see whether it contains that data. If data is already in the cache, it is called a cache hit.
Then the data can be retrieved from the cache, which is much faster than retrieving it from the original
storage location. If the requested data is not in the cache, it is called a cache miss. Then the data needs
to be fetched from the original storage location, which would take a longer time. Caching is used in
different places. In the CPU, caching is used to improve the performance by reducing the time taken to
get data from the main memory. In web browsers, web caching is used to store responses from previous
visits to web sites, in order to make the next visits faster.
Whats the difference between Buffering and Caching?
Even though both caching and buffering involves storing data temporally in a different location, they have
some important differences. Caching is done to reduce the access time in retrieving data from a slower
storage device. It is based on the principle that the same data will be accessed multiple times thus storing

them in cache would reduce the access time largely. Buffering is mainly used to overcome the difference
between the speeds in which the data is received and data is processed by a device.

Paging vs Swapping
Paging is a memory management method used by operating systems. Paging allows the main memory to
use data that is residing on a secondary storage device. These data are stored in the secondary storage
device as blocks of equal size called pages. Paging allows the operating system to use data that will not
fit in to the main memory. Swapping is a term that is used to describe the act of moving all the segments
belonging to a process between the main memory and a secondary storage device.
What is Paging?
Paging is a memory management method used by operating systems. Paging allows the main memory to
use data that is residing on a secondary storage device. These data are stored in the secondary storage
device as blocks of same size called pages. Paging allows the operating system to use data that will not
fit in to the main memory. When a program tries to access a page, first the page table is checked to see
whether that page is on the main memory. Page table holds details about where the pages are stored. If it
is not in the main memory, it is called a page fault. Operating system is responsible for handling page
faults without showing it to the program. The operating system first finds where that particular page is
stored in the secondary storage and then brings it in to an empty page frame in the main memory. Then it
updates the page table to indicate that the new data is in the main memory and returns the control back to
the program that initially requested the page.
What is Swapping?
Swapping is the process of moving all the segments belonging to a process between the main memory
and a secondary storage device. Swapping occurs under heavier work loads. Operating system kernel
would move all the memory segments belonging to a process in to an area called swap area. When
selecting a process for swapping, the operating system will select a process that will not become active
for a while. When the main memory has enough space to hold the process, it will be transferred back in to
the main memory from the swap space so that its execution could be continued.
What is the difference between Paging and Swapping?
In paging, blocks of equal size (called pages) are transferred between the main memory and a secondary
storage device, while in swapping, all the segments belonging to a process will be moved back and forth
between the main memory and a secondary storage device. Since paging allows moving pages (it could
be a part of the address space of a process), it is more flexible than swapping. Since, paging only moves
pages (unlike swapping, which move a whole process), paging would allow more processes to reside on
the main memory at the same time, when compared with a swapping system. Swapping is more suitable
when running heavier workloads.

What is the difference between Swapping and Paging?


Swapping:
Whole process is moved from the swap device to the main memory for execution.
Process size must be less than or equal to the available main memory. It is easier to
implementation and overhead to the system. Swapping systems does not handle
the memory more flexibly as compared to the paging systems.
Paging:
Only the required memory pages are moved to main memory from the swap device
for execution.
Process size does not matter. Gives the concept of the virtual memory. It provides
greater flexibility in mapping the virtual address space into the physical memory of
the machine. Allows more number of processes to fit in the main memory
simultaneously. Allows the greater process size than the available physical memory.
Demand paging systems handle the memory more flexibly.

What does 2>&1 mean and when is it typically used?


The 2 (from 2>&1) is the UNIX file descriptor used by standard error (stderr).
Therefore, 2>&1 causes the shell to send anything headed to standard error to the
same place messages to standard output
Define sticky bit?
The bit S_ISVTX is known as sticky bit. If this bit is set for an executable program
file, then the first time the program was executed a copy of the programmers text
was saved in the swap area when the process terminated. The advantage of using
this is the program is loaded into memory faster the next time.
List the system calls used for process management:
System calls - Description
fork()
- To create a new process
exec()
- To execute a new program in a process
wait()
- To wait until a created process completes its execution
exit()
- To exit from a process execution
getpid()
- To get a process identifier of the current process
getppid()
- To get parent process identifier
nice()
- To bias the existing priority of a process
brk()
- To increase/decrease the data segment size of a process

Brief about the initial process sequence while the system boots up?
While booting, special process called the 'swapper' or 'scheduler' is created with
Process- ID 0.
The swapper manages memory allocation for processes and influences CPU
allocation. The swapper inturn creates 3 children:
the process dispatcher,
vhand and
dbflush
with IDs 1,2 and 3 respectively.
This is done by executing the file "/etc/init". Process dispatcher gives birth to the
shell.
Unix keeps track of all the processes in an internal data structure called the Process
Table (listing command is ps -el).
What Happens when you execute a program?
When you execute a program on your UNIX system, the system creates a special
environment for that program.
This environment contains everything needed for the system to run the program as
if no other program were running on the system.
Each process has process context, which is everything that is unique about the state
of the program you are currently running.

Every time you execute a program the UNIX system does a fork, which performs a
series of operations to create a process context
and then execute your program in that context.
The steps include the following:
Allocate a slot in the process table, a list of currently running programs kept by
UNIX.
Assign a unique process identifier (PID) to the process.
iCopy the context of the parent, the process that requested the spawning of the new
process.
Return the new PID to the parent process. This enables the parent process to
examine or control the process directly.
After the fork is complete, UNIX runs your program.
What is piping?
It is a technique which gives the output of one command as an input of another

Anda mungkin juga menyukai