Professional Documents
Culture Documents
Decimal number
Binary number
0000
0000
0001
0001
0010
0010
0011
0011
0100
0100
0101
0101
0110
0110
0111
0111
1000
1000
1001
1001
10
1010
0001 0000
11
1011
0001 0001
12
1100
0001 0010
13
1101
0001 0011
14
1110
0001 0100
15
1111
0001 0101
Gray Code
From this table we can obtain the equivalent gray code of the
decimal numbers. There are several steps which will make you
understand how the codes are formed.
(1) In case of gray code one bit will change from its previous in
each steps. One thing must be kept in mind that the change of bit
always occurs from the right side i.e from L.S.B towards the M.S.B.
At first the first three bits are constant I,e 000 and the fourth bit
changes from 0 to 1. We know that for binary digit possible
third and fourth bit is 0 as both the bits are same. Lastly the XOR of
fourth and fifth bit is 1 as they are different. That is how the result
of binary to gray code conversion of 01001 is done whose
equivalent gray code is 01101.
Gray code to binary conversion
second binary bit will again alter and the third bit of the binary
number will be 0. Now, 4th bit of the given gray is 0 so the previous
binary bit will be unchanged, i.e 4th binary bit will be 0. Now again
the 5th grey bit is 1 thus the previous binary bit will alter, it will be
1 from 0. Therefore the equivalent Binary number in case of gray
code to binary conversion will be (01001)
Alphanumeric codes
Alphanumeric codes are sometimes called character codes due to
their certain properties. Now these codes are basically binary codes.
We can write alphanumeric data, including data, letters of the
alphabet, numbers, mathematical symbols and punctuation marks
by this code which can be easily understandable and can be
processed by the computers. Input output devices such as
keyboards, monitors, mouse can be interfaced using these codes.
12-bit Hollerith code is the better known and perhaps the first
effective code in the days of evolving computers in early days.
During this period punch cards were used as the inputting and
outputting data. But nowadays these codes are termed obsolete as
many other modern codes have evolved. The most common
alphanumeric codes used these days are ASCII code, EBCDIC
code and Unicode. Now we will discuss about them briefly.
ASCII CODES
ASCII stands for American Standard Code for Information
Interchange. Computers can only understand numbers, so an
ASCII code is the numerical representation of a character such as
'a' or '@' or an action of some sort. ASCII was developed a long
time ago and now the non-printing characters are rarely used for
their original purpose. Below is the ASCII character table and this
includes descriptions of the first 32 non-printing characters. ASCII
was actually designed for use with teletypes and so the
descriptions are somewhat obscure. If someone says they want
your CV however in ASCII format, all this means is they want
'plain' text with no formatting such as tabs, bold or underscoring the raw format that any computer can understand. This is usually
so they can easily import the file into their own applications
without issues. Notepad.exe creates ASCII text, or in MS Word
you can save a file as 'text only'
EBCDIC code
The EBCDIC stands for Extended Binary Coded Decimal Interchange
Code. IBM invented this code to extend the Binary Coded Decimal
which existed at that time. All the IBM computers and peripherals
use this code. It is an 8 bit code and therefore can accommodate
256 characters. Below is given some characters of EBCDIC code to
get familiar with it.
Char
EBCDIC
HEX
Char
EBCDIC
HEX
Char
EBCDIC
HEX
1100 0001
C1
1101 0111
D7
1111 0100
F4
1100 0010
C2
1101 1000
D8
1111 0101
F5
1100 0011
C3
1101 1001
D9
1111 0110
F6
1100 0100
C4
1110 0010
E2
1111 0111
F7
1100 0101
C5
1110 0011
E3
1111 1000
F8
1100 0110
C6
1110 0100
E4
1111 1001
F9
1100 0111
C7
1110 0101
E5
blank
...
...
1100 1000
C8
1110 0110
E6
...
...
1100 1001
C9
1110 0111
E7
...
...
1101 0001
D1
1110 1000
E8
...
...
1101 0010
D2
1110 1001
E9
...
...
1101 0011
D3
1111 0000
F0
...
...
1101 0100
D4
1111 0001
F1
...
...
1101 0101
D5
1111 0010
F2
...
...
1101 0110
D6
1111 0011
F3
System calls provide an interface between the process an the operating system. These calls are
generally available as Assembly language instruction.System Calls can also be made directly
through HLL programs for certain systems.UNIX System calls can be invoked directly from a C
or C++ program.System calls allow user-level processes to request some services from the
operating system which process itself is not allowed to do. In handling the trap, the operating
system will enter in the kernel mode, where it has access to privileged instructions, and can
perform the desired service on the behalf of user-level process. It is because of the critical nature
of operations that the operating system itself does them every time they are needed. For example,
for I/O a process involves a system call telling the operating system to read or write particular
area and this request is satisfied by the operating system.System programs provide basic
functioning to users so that they do not need to write their own environment for program
development (editors, compilers) and program execution (shells). In some sense, they are
bundles of useful system calls.
Consider a simple program to copy data from one file to another file .The first input of the
program will be the name of both files.These names can be specified depending on the design of
Operation System.Once the file names are obtained,the program opens an input file and create
an output file.Each of this operations require other System calls and may encounter possible
error conditions.
Methods of Passing Parameters to Operating System
Three methods are used in passing parameters to the operation system.
Process control
File management.
Device management
Communication.
Process control
End, abort
Load, execute
File management
Open , close
Device management
Information Maintenance
Information maintenance
Communication
Description
fork() cannot allocate sufficient memory to copy the parents page tables
and allocate a task structure for the child.
EAGAIN
ENOMEM
Shells in Linux
Linux Kernel
Computers understand the language of zeros and ones known as binary
language. In the early days of computing, instructions were provided using
binary language, which is difficult for all of us to read and write. Therefore, in
an operating system there is a special program called the shell. The shell
accepts human readable commands and translates them into something the
kernel can read and process.
What Is a Shell?
The shell gets started when you log in or open a console (terminal).
The shell is not part of system kernel, but uses the system kernel to execute programs,
create files etc.
Several shells are available for Linux including:
o BASH ( Bourne-Again SHell ) - Most common shell in Linux. It's Open Source.
o CSH (C SHell) - The C shell's syntax and usage are very similar to the C
programming language.
o KSH (Korn SHell) - Created by David Korn at AT & T Bell Labs. The Korn Shell
also was the base for the POSIX Shell standard specifications.
o TCSH - It is an enhanced but completely compatible version of the Berkeley
UNIXC shell (CSH).
Please note that each shell does the same job, but each understands different command syntax
and provides different built-in functions. Under MS-DOS, the shell name is COMMAND.COM
which is also used for the same purpose, but it is by far not as powerful as our Linux Shells are!
Shell Prompt
There are various ways to get shell access:
Terminal - Linux desktop provide a GUI based login system. Once logged in you can
gain access to a shell by running X Terminal (XTerm), Gnome Terminal (GTerm), or KDE
Terminal (KTerm) application.
Connect via secure shell (SSH) - You will get a shell prompt as soon as you log in into
remote server or workstation.
Use the console - A few Linux system also provides a text-based login system. Generally
you get a shell prompt as soon as you log in to the system.
Shell Name
Developed by
Where
Remark
CSH (C SHell)
Bill Joy
University
of The C shell's syntax and
California (For BSD) usage are very similar to
the
C
programming
language.
David Korn
TCSH
Note that each shell does the same job, but each understand a different command syntax and
provides different built-in functions.
In MS-DOS, Shell name is COMMAND.COM which is also used for same purpose, but it's not
as powerful as our Linux Shells are!
Any of the above shell reads command from user (via Keyboard or Mouse) and tells Linux Os
what users want. If we are giving commands from keyboard it is called command line interface
( Usually in-front of $ prompt, This prompt is depend upon your shell and Environment that you
set or by your System Administrator, therefore you may get different prompt ).
Tip:
To
find
$ echo $SHELL
your
current
shell
type
following
command
/etc/profile
2.
~/.bash_profile
3.
~/.bashrc
4.
~/.bash_logout
These files are text based shell scripts that can be used to define settings for either system wide
settings (those in the /etc directory), or for an individual user (those in the users home directory
specified by ~). Different files are called depending upon whether it is an interactive login shell
or a non-interactive shell.
~/etc/profile
The /etc/profile file provides the system wide default environment variables. Typically this sets
up the umask, LOGNAME, and mail directories etc. It can also be used to change the default
command search path (PATH) for all users on the system. As most systems don't have a
/etc/bashrc file aliases are sometimes included in the /etc/profile file.The file /etc/profile is
maintained by the system administrator of your UNIX machine and contains shell initialization
information required by all users on a system.
The file .profile is under your control. You can add as much shell customization information as
you want to this file. The minimum set of information that you need to configure includes
You can check your .profile available in your home directory. Open it using vi editor and check
all the variables set for your environment.
~/.bash_profile
This provides the user specific environment variables, and is often used to add local search paths
onto the PATH. This is called after the /etc/profile script.
~/.bashrc
This file is called for non-interactive shells, and is normally called from the ~/.bash_profile for
interactive shells. It is normally used for setting up aliases and any other commands that are run
during the startup.
~/.bash_logout
The ~/.bash_logout script is called when the user logs out of the interactive shell.
Open source - Linux source code is freely available and it is community based development
project. Multiple teams works in collaboration to enhance the capability of Linux operating
system and it is continuously evolving.
Multiuser - Linux is a multiuser system means multiple users can access system resources like
memory/ ram/ application programs at same time.
Multiprocessor - SMP support is available on the Intel and SPARC platforms (with work
currently in progress on other platforms), and Linux is used in several loosely-coupled MP
applications, including Beowulf systems.
Multithreading - Linux has native kernel support for multiple independent threads of control
within a single process memory space.
Hierarchicalfilesystem - Linux provides a standard file structure in which system files/ user
files are arranged.
Shell - Linux provides a special interpreter program which can be used to execute commands of
the operating system. It can be used to do various types of operations, call application programs
etc.
Security - Linux provides user security using authentication features like password protection/
controlled access to specific files/ encryption of data.
Demandloads executables - Linux only reads from disk those parts of a program that are
actually used.
Multiple virtual consoles - Several independent login sessions through the console, you switch
by pressing a hot-key combination (not dependent on video hardware). These are dynamically
allocated; you can use up to 64.
Support for different filesystems - Supports several common filesystems including minix,
Xenix,and all the common system V filesystems and has an advanced filesystem of its own,
which offers filesystems of up to 4 TB, and names up to 255 characters long.
Paging - Despite the best efforts to use physical memory efficiently, it may be that the available
memory is fully occupied. Linux then looks for 4 Kbyte pages of memory which can be freed.
Pages whose contents are already stored on hard disk are discarded. If one of these pages is
subsequently accessed, it has to be reloaded.
TCP/IP, SLIP & PPP support-Linux can be integrated into local unix networks. In principle, all
network services such as the network file system and remote login, can be used. SLIP & PPP
support the use of the TCP/IP protocol over serial lines. This means that it is possible to link into
the internet via the public telephone network using a high-speed modem.
Support for national keyboards & fonts- In linux you can use various national keyboards and
fonts. Since the latin1 font defined by the International Organisation for Standardisation (ISO)
contains umlauts, for example, the use of other fonts in Germany is not strictly necessary.
Shared libraries- These are collections of routines needed by a program to work. There are a
number of standard libraries used by more than one process at the same time. It therefore makes
sense to load the program code for these libraries into memory only once, rather than once for
each process.
SHELL COMMANDS
1.Pwd
Since a command line interface cannot provide graphics pictures of the file system
structure. It must have a different way of representing it. Think of the file system
tree as a maze , and you are standing in it. At any given moment, you stand in a
single directory. Inside that directory , you can see its file and the pathway to its
parent directory and the pathways to the subdirectories of the directory in which
you are standing.
The directory you are standing in is called the working directory .to find the name of
the working directory ,use the pwd command.
2.Cd
To change your working directory (where you are standing in the maze) you use the
cd command. To do this, type cd followed by the pathname of the desired working
directory. A pathname is the route you take along the branches of the tree to get to
the directory you want. Pathnames can be specified in one of two different ways,
absolute pathnames or relative pathnames. Lets deal with absolute pathnames
first.
3.Ls
One of the most used commands by Linux users and the one that a Linux beginner
must learn is- 'ls' Command. It is usually used to view the contents of current
directory. So, when you run this command, the files and sub-directories included
under the current directory will be listed before you. Very useful command and
everyone who uses Linux should know this command.
3.cat
cat is one of the most frequently used commands on Unix-like operating systems. It
has three related functions with regard to text files: displaying them, combining
copies of them and creating new ones.
syntax is
cat [options] [filenames] [-] [filenames]
The square brackets indicate that the enclosed items are optional.
Reading Files
The most common use of cat is to read the contents of files, and cat is often the
most convenient program for this purpose. All that is necessary to open a text file
for viewing on the display monitor is to type the word cat followed by a space and
the name of the file and then press the ENTER key. For example, the following will
display the contents of a file named desktop:
catdesktop
The standard output (i.e., default destination of the output) for cat, as is generally
the case for other command line (i.e., all-text mode) programs, is the monitor
screen. However, it can be redirected from the screen, for example, to another file
to be written to that file or to another command to use as the input for that
command.
In the following example, the standard output of cat is redirected using the output
redirection operator (which is represented by a rightward pointing angular bracket)
to file2:
cat file1 > file2
That is, the output from cat is written to file2 instead of being displayed on the
monitor screen.
>>FILTERS::
1.head COMMAND
This command gives the top most lines existed inside a file in a working directory.
2.head n5
This command gives the top five lines of a existed file.
3.tail COMMAND
This command gives the last most lines existed inside a file in a working directory.
4.tail n5
This command gives the last five lines of a existed file.
6.Sort
Sort command is helpful to sort/order lines in text files. You can sort the data in text
file and display the output on the screen, or redirect it to a file. Based on your
requirement, sort provides several command line options for sorting data in a text
file.
In Linux whenever you are not sure about the name of a file and you want to do
something with files such as either search for them or copy them or delete some
files based on some knowledge you have about the filenames then you can use
Wildcards. Wildcards are basically an indicator to the shell that some particular part
of the filename is not known to you and the shell can insert a combination of
characters in those places and then work on all the newly formed filenames.
1.ls x ch0[14]
Would list all the files that begin with the letter sequence ' beckham ' and end with
either a 1, 2 or 3. Thus the possible filenames that could be listed (if they exists) are
beckham1.jpg , beckham2.jpg and beckham3.jpg
2.ls x ch0[1-3]
Remember that [] represents a range from which any character can be present. This
range can be something like [0-4] or [1-9] or anything like that in case of numbers.
Letters could also be selected such as [a-g] or [F-Z] or [A-Z].
name chmod stands for "change mode", and it is used to define the way a
file can be accessed.
Before continuing, you should read the section What Are File Permissions,
And How Do They Work? in our documentation of the umask command. It
contains a comprehensive description of how to define and express file
permissions.
In general, chmod commands take the form:
chmodoptionspermissionsfilename
the permissions exactly like this," and the letters "r", "w", and "x" stand for
"read", "write", and "execute", respectively. The commas separate the
different classes of permissions, and there are no spaces in between them.
NETWORK COMMANDS
1.NETSTAT Command
Netstat (Network Statistic) command display connection info,
routing table information etc. To displays routing table information
use option as -r.
2. PING Command
PING (Packet INternet Groper) command is the best way to
test connectivity between two nodes. Whether it is Local Area
Network (LAN) or Wide Area Network (WAN). Ping use ICMP
(Internet Control Message Protocol) to communicate to other
devices. You can ping host name of ip address using below
command