Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
61 views

Tech Mahindra Unix-1 History of UNIX

The document provides an overview of the history and features of the UNIX operating system. It discusses how UNIX was originally developed in 1969 by AT&T and has since evolved into various branches with contributions from many groups. Some key features of UNIX include being multi-user, multi-tasking, portable, providing security and interactive user interfaces, and using a hierarchical file system. The architecture of UNIX includes the kernel, shell/utilities, and other applications. Files and directories are organized in the file system with inodes storing metadata. Links, paths, and users are also summarized.

Uploaded by

bjln
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Tech Mahindra Unix-1 History of UNIX

The document provides an overview of the history and features of the UNIX operating system. It discusses how UNIX was originally developed in 1969 by AT&T and has since evolved into various branches with contributions from many groups. Some key features of UNIX include being multi-user, multi-tasking, portable, providing security and interactive user interfaces, and using a hierarchical file system. The architecture of UNIX includes the kernel, shell/utilities, and other applications. Files and directories are organized in the file system with inodes storing metadata. Links, paths, and users are also summarized.

Uploaded by

bjln
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Tech Mahindra

Unix-1
History of UNIX
•UNIX was originally developed in 1969 by ATandT employees at Bell Labs. It is a
multitasking, multi-user computer operating system.
•Originally developed in an assembly language, it was almost entirely coded in C by the year
1973, which greatly aided its further development and porting to other hardware.
•Today the UNIX system has evolved into various branches. Its development has been
contributed by ATandT as well as many commercial vendors and universities (for example,
University of California, Berkeley's BSD), and non-profit organizations.
UNIX is not a single operating system. It has many flavors (aka. variants, types, or
implementations).
Although, based on a core set of UNIX commands, different flavors have their own unique
commands and features, and are designed to work with different types of hardware and different
requirements.
Some well known UNIX flavors are:
•AIX by IBM, Solaris by Sun Microsystems now owned by Oracle, HP-UX by Hewlett-Packard,
IRIX by Silicon Graphics, Inc. FreeBSD By FreeBSD Group, GNU/Linux:by Open Source
Movement which is actually not UNIX but a UNIX like system, SCO UNIX by The Santa Cruz
Operation Inc.

Feature of unix :
The UNIX operating system is available on machines with a wide range of computing power,
from microcomputers to mainframes, and on different manufacture's machines.
Features of UNIX:
•Multi-user: UNIX lets multiple users connect to it and make use of the computing facilities at
the same time.
•Multi-tasking: Schedules and runs many programs at the same time to improve the system
throughput.
•Portable: UNIX is written in C programming language so it’s available for almost all hardware
platforms without being written from scratch for each.
•Interactive: Provides user interface for users to communicate with the system.
•Shell: Shell is a program that provides a user interface for interacting with UNIX using
command line or graphical user interface. It also provides a programming environment with
scripting facilities.
•Security is one of the most important feature of UNIX. Provided at multiple levels - File level,
process level, user level etc.
•Hierarchical File System: UNIX provides a file system for the user to store files/directories in a
hierarchical form. UNIX file system has a single parent directory indicated by a forward slash. It
called the root directory.
Unix architecture :
UNIX is an operating system. That is it's the software that controls the hardware resources of a
computer and provides an environment under which programs can run.
Kernel: UNIX operating system's core parts are put together into a component called as the
kernel, which is responsible for the making the underlying hardware available to other operating
system components and programs
Shell and Utilities: are the programs which usually come with UNIX. The shell is an application
that runs on the top of an operating system. It provides the user - an interface to communicate
with the kernel. It also offers many features that vary from shell to shell e.g. command
interpretation, pipes, redirection, programming constructs etc.
Utilities are executable programs for the user to perform a variety of activities on the system e.g.
checking the list of users, repairing the file system etc.
Other application program:
These are the programs that solve business problem or are used for entertainment like Oracle
database software, word processor, presentation software or multimedia players.

File system
UNIX file system is like a upside down tree. At the very top of the tree is the root directory,
named "/".
This special directory is maintained by the UNIX system administrator. Under the root directory,
subdirectories organize the files and subdirectories.
If you look at the UNIX file system hierarchy, UNIX has a single root file system. Each UNIX
file has to be stored in some or the other directory, Each directory has a parent directory except
the root directory.
Important thing to remember is a directory is not a container for files and subdirectories but
rather it’s a list of files and subdirectories under it.
A directory provides a mapping from file name / directory name to the inode number.
All the top level directories in root get created while installing of the operating system. These
directories contain specific data for example:
• /bin stores external command files for the ordinary user
• /boot stores OS kernel information, programs and configuration required for booting the
operating system
• /home stores user home directories, which can have user’s documents, programs, and user
specific configuration files
• /etc stores the OS configuration files which are applicable to all the user accounts and affect the
entire operating system if modified.
• /dev stores the device files
• /lib stores the library files

Unix files :
Now that we have seen the UNIX directory structure, let's learn about the UNIX files.
A file has some attributes apart from the file's content. Amongst these attributes, the file name is
stored in the directory - but the other attributes like file size, permissions, no. of links, time
stamps etc. are stored in the inode.
Almost everything is represented as a file in UNIX. This provides a uniform view to all the
system resources makes it real easy for the programmers and system administrators to deal with
these resources.
In UNIX, the meaning of the bytes stored in the file would depend upon the programs that
interpret the file and not on the OS
UNIX does not dictate the file formats too! So it's possible to create files which are portable
across various operating systems and platforms under UNIX.
Every file under the UNIX file system has various attributes or properties such as: file name,
size, a owner, access rights and various time stamps like file creation time.
Every item in a UNIX file system belongs to one of the three possible types:
Ordinary/Regular files, Directory files, or Device/Special files:
An ordinary file contains text, data, or program information; however it cannot contain another
file or directory. So it can be thought of as one-dimensional array of bytes.
A directory contains directory(s) and/or file(s) within it. Each line in a directory file contains
only the name of the item, and a numerical reference to the location of the item, called inode
number.
Physical devices (printers, terminals etc) are represented as files in UNIX. There are two types of
device files, Character Special and Block Special Character special devices deal with the
incoming or outgoing data in terms of individual characters for example keyboard, printer or a
modem.
Block special devices transfer the data in chunks of data rather than individual bytes such as hard
disk and CDROM.

Link and path name :


Links make the same file available in multiple directories at the same time. The two types of
links are Hard link and symbolic link. Symbolic links are also called as soft links in some
documentation.
A Hard link adds another name to the file in the directory entry. It does not consume any disk
space as it just gives another path to access the same file. You can verify this by giving a ls -i
command, which displays the inode number of a file. inode number for all the hard links to a file
is same as of the file. Creating hard link increase the reference count for a file by one each time.
However hard links some limitations:
1) They can only be create for ordinary files
2) They can exist in the same file system i.e. they cannot be created across partitions, which
means you cannot have hard links to files on
a. Removable devices
b. Network resources
Now let's learn about symbolic links. A symbolic link stores the path of a file. It's a separate file
on the disk which takes 1 block. A block size is usually 1Kb or 4Kb depending upon the file
system format.
Symbolic links are flexible as they can store any kind of paths, including file and directory on the
same file system or partition, file or directory on a removable or network share.
The inode number of the original file and the symbolic link are different and creating symbolic
link does not increase the reference count for the file.
Path name :Every item in the file system with a name can be specified with a path name. A path
is a means of accessing the file over the command line.
There are two ways to represent a path: Absolute and relative.
Using an absolute path is referring to a file starting with the root directory forward slash (/) and
mentioning every directory which must be entered to reach the file system item in question.
For example to refer to a file data.xls in uday user's home directory an absolute path would be
/home/uday/data.xls.
A relative path is used to reach the file or directory with respect to the current directory, you are
working in. You have to use special characters other then forward slash to denote a relative path
such a dot(.) which means current directory, a double dot (..) which means the parent directory, a
tilde which means your home directory.
For example if you are logged in as uday user and want to address the data.xls file you can refer
to it by it's name
data.xls or ./data.xls
If you are somewhere else: you can refer to data.xls with ~/data.xls. Remember ~ means your
home directory.

Inode :
inode is data structure containing useful information about a file system item in the UNIX file
system. inodes are stored in a special area on the disk called inode block and do not have names.
Instead they are identified with a number called inode number, which is an index number in a
table called as a inode table.
Unix users :
There are four types of users in UNIX operating system:
Super user who also referred to as a system administrator or root user. A root user has an overall
authority on UNIX OS and is responsible for: operating system maintenance, backup and
recovery, user management, printer management etc.
Super user login name is 'root' and you can identify root user by its prompt hash #
Owner is usually a user who creates a file or directory. For every UNIX file, there can be only
one owner.
Group: In UNIX, groups can be formed based on the area of work. Only Super user can create a
group and assign members to it.
Others: User who belongs to a group, other than your group is other for you.
File or directory owner can grant the access permission on a file or directory. Root user can
change/grant permissions on the file systems items on behalf of their respective owners.

Unix commands :
Now let's see some basic UNIX commands which help you getting some basic information about
your login and your UNIX server.
It's recommended that while you watch and listen to this module, login to UNIX server and
practice the commands along with the training.
pwd command shows working directory (current directory )
who command shows who is logged on
who am i command shows the login name of the current user. Who command takes any strings
two parameters instead of am and i and displays the same output each time. Try who is he.
tty command prints the file name of the terminal connected to standard input
man command formats and displays online manual pages []
date command prints or sets the system date and time []
echo command prints the parameters passed to it on the console.
Let's see the three usages of the echo command: with double quotes, with single quotes and
without quotes.
When you use double quotes around a string shell evaluates the shell variables starting with a $
and replaces the values in the string. The entire string is passed as a single parameter to the echo
command.
When you use single quotes around a string then shell does not evaluate the shell variable and
the entire string passed as it is to the echo command.
When you do not use any quotes around a string. Individual words are passed as different
parameters to the echo command, and the shell evaluates the shell variables.
clear command wipes out the console screen analogous to CLS in DOS/Windows
which command_name shows the path of the specified command
type command_name shows the type of the specified command: shell built-in or file path if it is
external
file file_name shows the type of the file whether regular file, directory file or special file

cal command displays the calendar of the current month/year. It can take options which display
calendar of any month and year.
bc command starts the bc program in interactive mode. bc is a filter command. Usually this type
commands take the input from keyboard or file and process it interactively and print the output
on the screen. bc takes polynomial mathematical expressions such as 2 * 3 plus 8 as input per
line, evaluates them and prints the result on the screen. You can press Ctrl + d to quit the bc
command.
write user1 Lets you write a message to the other user; user1 in this example
ls command displays the directory listing of a directory. It's a versatile command with lots of
options, which let you see the hidden files, sort the files by size, modification time or extension.
Wild card characters :
A wildcard character is a special character that represents one or more other characters. The most
commonly used wildcard characters are the asterisk (*), which typically represents zero or more
characters in a string of characters, and the question mark (?), which typically represents any one
character.
For example *.log can be used to represent all the files which have a .log extension.
[] represent a character class i.e. any character entered within []. For example [abcd]* represent
all the file name that start with a, b, c or d
- specifies range, and is usually used in the [] to present a range of characters like
[a-z]
! works as not operator.
Redirection:
Redirection is used to redirect standard streams to user specified locations. The most common
use of the redirection is to send the output of a command to a file instead of the display screen or
reading from a file instead of from keyboard.
The UNIX operating has three standard streams:
1.input stream identified by file descriptor 0 also called as stdin
2.output stream identified by 1 also called a stdout and
3.error stream identified by 2 also called a stderr
UNIX shell uses angular brackets to denote redirection. The typical syntax of output redirection
is
command file_name
You can optionally have the standard file descriptor in output redirection:
command 1> file_name
For appending the output of a command to a file use the redirection operator twice like:
command >> file_name
Input redirection means reading from a file instead of the standard input
Take bc command for instance which reads math expressions from keyboard and displays the
output to screen. Create a file which contains few mathematical expressions, one per line such as
2 * 5 plus 8
4.5 * 2.65 etc.
Save it as math1. To send this file to bc, you can use input redirection like:
bc math1,
also you can optionally use a file descriptor for stdin
bc 0 math1
While it's optional to use file descriptor in case of output or input redirection you must use file
descriptor for error redirection:
For example:
ls / -R 2> error-log
This command redirects al the errors to a file called error-log while all the output is displayed on
the screen.

Commands continuation:
cat command concatenates and displays once or several ordinary files. cat reads from the stdard
input when invoked without any parameters and repeats the same text that you input.
You can use this property of cat command to create a text file. You just have to redirect the
output of the cat command to file. After editing is done you can press Ctrl + d to save the file.
Note that, cat is a command and not an editor; so don't expect to edit the file with cat, like a fully
fledged editor.
touch command is used to modify the last access and modification time of a file. touch command
modifies the time stamps of a file if exits otherwise it creates a empty file.
It's common among UNIX users to create empty files using touch commnd for example:
touch newfile.txt
This command can create a newfile.txt file of 0 size.

 mkdir command is used to create one or more directories.


E.g.
mkdir d1
mkdir d2 d3
mkdir can accept new directory names containing full or relative paths:
E.g:
mkdir /home/staff/d1
or
mkdir ~/d2
mkdir can be used with a -p option to create the parent directories if they do not exist. However,
-p option does not overwrite a parent directory if it already exists.
rmdir command can remove empty directories.
For Ex.:
$rmdir d2 d3

 cd command takes a absolute (i.e. full) or relative path as a parameter and changes your
current directory to the specified path
For ex:
cd .. takes you to the parent directory of your current directory. DOS/Windows users should note
the space between cd and double dot, not using a space between cd and double dot can cause a
command not found error.
cp command copies a files and directories.
Ex:
$ cp file1 file2
By default cp command overwrites a file without confirmation, to copy interactively you can use
-i option.
$ cp -i file1 file2
cp can copy multiple files to a directory. You can also use wild card characters to represent
multiple files
$ cp file1 file2... dest_directory
If you want to copy a directory into another directory you must use -r option with cp command.
$ cp -r directory1 directory2 ... dest_directory

 rm command is used to remove files or directories from the UNIX file system
$ rm
rm too supports an interactive option -i
$ rm [-i] file ...
To remove a non empty directory along with all the content use -r option
$ rm -r directory ...
Remember! with great power comes great responsibility. Always use rm command with caution
and double check what you are typing before you hit enter. UNIX does not have a recycle bin
and it's not simple to undo your actions.

 ln command is used for creating a link. When ln is used without any option, it creates a
hard link.
$ ln file1 file2
When used a -s option ln creates a symbolic / soft link
$ ln -s file1 file3

You might also like