SlideShare a Scribd company logo
1 of 33
Unix The OperatingSystem
UNIX (THE OS) Page 1
Introduction to UNIX
UNIX is an operating system which was first developed in the 1960s, at AT&T
Bell Laboratories and at the University of California, and has been under
constant development ever since. By operating system, we mean the suite of
programs which make the computer work. It is a stable, multi-user, multi-tasking
system for servers, desktops and laptops.
UNIX systems also have a graphical user interface (GUI) similar to Microsoft
Windows which provides an easy to use environment. However, knowledge of
UNIX is required for operations which aren't covered by a graphical program, or
for when there is no windows interface available, for example, in a telnet
session.
Unix is also part of the underlying technology of the Internet. Although no
operating systems has any exclusive claim to the Internet, many of the standard
technologies, protocols and applications that make up the Internet were first
developed on Unix systems.
Multi-user:- Multi-user is a term that defines an operating
system or application software that allows access by multiple users of
a computer. Time-sharing systems are multi-user systems. Most batch
processing systems for mainframe computers may also be considered "multi-
user", to avoid leaving the CPU idle while it waits for I/O operations to complete.
Multi tasking:- multitasking is a method where multiple tasks, also
known as processes, are performed during the same period of time. The tasks
share common processing resources, such as a CPU and main memory. In the
case of a computer with a single CPU, only one task is said to be running at any
point in time, meaning that the CPU is actively executing instructions for that
task. Multitasking solves the problem by scheduling which task may be the one
running at any given time, and when another waiting task gets a turn.
Unix The OperatingSystem
UNIX (THE OS) Page 2
Graphical User Interface:- graphical user interface (GUI) is a
type of user interface that allows users to interact with electronic devices using
images rather than text commands. GUIs can be used in computers, hand-held
devices such as MP3 players, portable media players or gaming devices,
household appliances, office and industry equipment.
UNIX importance
UNIX, as it is implemented in its many variants, serves as the operating
system for all types of computers, including personal computers and
engineering workstations, multiuser microcomputers, minicomputers,
mainframes, and supercomputers, as well as special-purpose devices. The
number of computers running a variant of UNIX has grown explosively with
more than 40 million computers now running a variant of UNIX and more than
300 million people using these systems. This rapid growth, especially for
computers running Linux, is expected to continue, according to most computer
industry experts. The success of UNIX is due to many factors, including its
portability to a wide range of machines, its adaptability and simplicity, the wide
range of tasks that it can perform, its multiuser and multitasking nature, and its
suitability for networking, which has become increasingly important as the
Internet has blossomed. What follows is a description of the features that have
made UNIX so popular.
Open Source Code:- The source code for key variants of UNIX, and
not just the executable code, has been made available to users and
programmers. Because of this, many people have been able to adapt UNIX in
different ways. This openness has led to the introduction of a wide range of new
features and versions customized to meet special needs. It has been easy for
developers to adapt to UNIX, because the computer code for UNIX is
straightforward, modular, and compact.
Unix The OperatingSystem
UNIX (THE OS) Page 3
Cooperative Tools and Utilities:- The UNIX System provides users
with many different tools and utilities that can be leveraged to perform an amazing
variety of jobs. Some of these tools are simple commands that you can use to carry
out specific tasks. Other tools and utilities are really small programming languages
that you can use to build scripts to solve your own problems.
Multiuser and Multitasking Abilities:- The UNIX operating system
can be used for computers with many users or a single user, because it is a
multiuser system. It is also a multitasking operating system, because a single user
can carry out more than one task at once. For instance, you can run a program that
checks the spelling of words in a text file while you simultaneously read your
electronic mail.
Excellent Networking Environment:- The UNIX operating system
provides an excellent environment for networking. It offers programs and utilities that
provide the services needed to build networked applications-the basis for distributed,
networked computing. With networked computing, information and processing is
shared among different computers in a network. The UNIX system has proved to be
useful in client/server computing where machines on a network can be both clients
and servers at the same time. UNIX also has been the base system for the
development of Internet services and for the growth of the Internet.
Portability:- It is far easier to port UNIX to new machines than other
operating systems-that is, far less work is needed to adapt it to run on a new
hardware platform. The portability of UNIX results from its being written almost
entirely in the C programming language. The portability to a wide range of computers
makes it possible to move applications from one system to another.
Unix The OperatingSystem
UNIX (THE OS) Page 4
The Structure of UNIX Operating System
To understand how UNIX works, you need to understand its structure. The UNIX
operating system is made up of several major components. These components
include the kernel, the shell, the file system, and the commands (or user programs).
The relationship among the user, the shell, the kernel, and the underlying hardware
is displayed in Figure.
The Kernel:- The kernel is the part of the operating system that interacts
directly with the hardware of a computer, through device drivers that are built into the
kernel. It provides sets of services that can be used by programs, insulating these
programs from the underlying hardware. The major functions of the kernel are to
Unix The OperatingSystem
UNIX (THE OS) Page 5
manage computer memory, to control access to the computer, to maintain the file
system, to handle interrupts (signals to terminate execution), to handle errors, to
perform input and output services (which allow computers to interact with terminals,
storage devices, and printers), and to allocate the resources of the computer (such
as the CPU or input/output devices) among users.
Utilities:- The UNIX System contains several hundred utilities or user
programs. Commands are also known as tools, because they can be used
separately or put together in various ways to carry out useful tasks. You execute
these utilities by invoking them by name through the shell; this is why they are called
commands.
A critical difference between UNIX and earlier operating systems is the ease with
which new programs can be installed-the shell need only be told where to look for
commands, and this is user-definable.
The File System:- The basic unit used to organize information in UNIX is
called a file. The UNIX file system provides a logical method for organizing, storing,
retrieving, manipulating, and managing information. Files are organized into a
hierarchical file system, with files grouped together into directories. An important
simplifying feature of UNIX is the general way it treats files. For example, physical
devices are treated as files; this permits the same commands to work for ordinary
files and for physical devices; for instance, printing a file (on a printer) is treated
similarly to displaying it on the terminal screen.
The Shell:- The shell reads your commands and interprets them as
requests to execute a program or programs, which it then arranges to have carried
out. Because the shell plays this role, it is called a command interpreter. Besides
being a command interpreter, the shell is also a programming language. As a
programming language, it permits you to control how and when commands are
carried out.
Unix The OperatingSystem
UNIX (THE OS) Page 6
Applications Of UNIX
There are many applications of UNIX discussed as below:
 You can use applications built using UNIX commands, tools, and programs.
 horizontal applications like as government, industry, and education.
 Others are industry-specific and are known as vertical applications
 web browsers and web server application
 Another important class of applications deals with multimedia. Such
applications let users create and view multimedia files, including audio,
images, and video.
UNIX Philosphy
UNIX has developed a characteristic, consistent approach that is sometimes referred
to as the UNIX philosophy. This philosophy has deeply influenced the structure of
the system and the way it works. Keeping this philosophy in mind helps you
understand the way UNIX treats files and programs, the kinds of commands and
programs it provides, and the way you use it to accomplish a task.
The UNIX philosophy is based on the idea that a powerful and complex computer
system should still be simple, general, and extensible, and that making it so provides
important benefits for both users and program developers. Another way to express
the basic goals of the UNIX philosophy is to note that, for all its size and complexity,
UNIX still reflects the idea that “small is beautiful.” This approach is especially
reflected in the way UNIX treats files and in its focus on software tools.
Unix The OperatingSystem
UNIX (THE OS) Page 7
The Birth Of The Unix System
The history of the UNIX System dates back to the late 1960s when MIT, AT&T Bell
Labs, and then-computer manufacturer GE (General Electric) worked on an
experimental operating system called Multics. Multics, from Multiplexed Information
and Computing System, was designed to be an interactive operating system for the
GE 645 mainframe computer, allowing information sharing while providing security
Development met with many delays, and production versions turned out to be slow
and required extensive memory For a variety of reasons, Bell Labs dropped out of
the project. However, the Multics system implemented many innovative features and
produced an excellent computing environment.
1969 The Beginning The history of UNIX starts back in 1969, when Ken
Thompson, Dennis Ritchie and others started working on
the "little-used PDP-7 in a corner" at Bell Labs and what
was to become UNIX.
1971 First Edition It had a assembler for a PDP-11/20, file system, fork(), roff
and ed. It was used for text processing of patent
documents.
1973 Fourth Edition It was rewritten in C. This made it portable and changed
the history of OS's.
1975 Sixth Edition UNIX leaves home. Also widely known as Version 6, this is
the first to be widely available out side of Bell Labs. The
first BSD version (1.x) was derived from V6.
1979 Seventh Edition It was a "improvement over all preceding and following
Unices" [Bourne]. It had C, UUCP and the Bourne shell. It
was ported to the VAX and the kernel was more than 40
Unix The OperatingSystem
UNIX (THE OS) Page 8
Kilobytes (K).
1980 Xenix Microsoft introduces Xenix. 32V and 4BSD introduced.
1982 System III AT&T's UNIX System Group (USG) release System III, the
first public release outside Bell Laboratories. SunOS 1.0
ships. HP-UX introduced. Ultrix-11 Introduced.
1983 System V Computer Research Group (CRG), UNIX System Group
(USG) and a third group merge to become UNIX System
Development Lab. AT&T announces UNIX System V, the
first supported release. Installed base 45,000.
1984 4.2BSD University of California at Berkeley releases 4.2BSD,
includes TCP/IP, new signals and much more. X/Open
formed.
1984 SVR2 System V Release 2 introduced. At this time there are
100,000 UNIX installations around the world.
1986 4.3BSD 4.3BSD released, including internet name server. SVID
introduced. NFS shipped. AIX announced. Installed base
250,000.
1987 SVR3 System V Release 3 including STREAMS, TLI, RFS. At
this time there are 750,000 UNIX installations around the
world. IRIX introduced.
1988 POSIX.1 published. Open Software Foundation (OSF) and
UNIX International (UI) formed. Ultrix 4.2 ships.
1989 AT&T UNIX Software Operation formed in preparation for
spinoff of USL. Motif 1.0 ships.
1989 SVR4 UNIX System V Release 4 ships, unifying System V, BSD
and Xenix. Installed base 1.2 million.
1990 XPG3 X/Open launches XPG3 Brand. OSF/1 debuts. Plan 9 from
Bell Labs ships.
1991 UNIX System Laboratories (USL) becomes a company -
majority-owned by AT&T. Linus Torvalds commences
Unix The OperatingSystem
UNIX (THE OS) Page 9
Linux development. Solaris 1.0 debuts.
1992 SVR4.2 USL releases UNIX System V Release 4.2 (Destiny).
October - XPG4 Brand launched by X/Open. December
22nd Novell announces intent to acquire USL. Solaris 2.0
ships.
1993 4.4BSD 4.4BSD the final release from Berkeley. June 16 Novell
acquires USL
Late
1993
SVR4.2MP Novell transfers rights to the "UNIX" trademark and the
Single UNIX Specification to X/Open. COSE initiative
delivers "Spec 1170" to X/Open for fasttrack. In December
Novell ships SVR4.2MP , the final USL OEM release of
System V
1994 Single UNIX
Specification
BSD 4.4-Lite eliminated all code claimed to infringe on
USL/Novell. As the new owner of the UNIX trademark,
X/Open introduces the Single UNIX Specification (formerly
Spec 1170), separating the UNIX trademark from any
actual code stream.
1995 UNIX 95 X/Open introduces the UNIX 95 branding programme for
implementations of the Single UNIX Specification. Novell
sells UnixWare business line to SCO. Digital UNIX
introduced. UnixWare 2.0 ships. OpenServer 5.0 debuts.
1996 The Open Group forms as a merger of OSF and X/Open.
1997 Single UNIX
Specification,
Version 2
The Open Group introduces Version 2 of the Single UNIX
Specification, including support for realtime, threads and
64-bit and larger processors. The specification is made
freely available on the web. IRIX 6.4, AIX 4.3 and HP-UX
11 ship.
1998 UNIX 98 The Open Group introduces the UNIX 98 family of brands,
including Base, Workstation and Server. First UNIX 98
registered products shipped by Sun, IBM and NCR. The
Open Source movement starts to take off with
Unix The OperatingSystem
UNIX (THE OS) Page 10
announcements from Netscape and IBM. UnixWare 7 and
IRIX 6.5 ship.
1999 UNIX at 30 The UNIX system reaches its 30th anniversary. Linux 2.2
kernel released. The Open Group and the IEEE
commence joint development of a revision to POSIX and
the Single UNIX Specification. First LinuxWorld
conferences. Dot com fever on the stock markets. Tru64
UNIX ships.
2001 Single UNIX
Specification,
Version 3
Version 3 of the Single UNIX Specification unites IEEE
POSIX, The Open Group and the industry efforts. Linux
2.4 kernel released. IT stocks face a hard time at the
markets. The value of procurements for the UNIX brand
exceeds $25 billion. AIX 5L ships.
2003 ISO/IEC
9945:2003
The core volumes of Version 3 of the Single UNIX
Specification are approved as an international standard.
The "Westwood" test suite ship for the UNIX 03 brand.
Solaris 9.0 E ships. Linux 2.6 kernel released.
2007 Apple Mac OS X certified to UNIX 03.
2008 ISO/IEC
9945:2008
Latest revision of the UNIX API set formally standardized
at ISO/IEC, IEEE and The Open Group. Adds further APIs
2009 UNIX at 40 IDC on UNIX market -- says UNIX $69 billion in 2008,
predicts UNIX $74 billion in 2013
2010 UNIX on the
Desktop
Apple reports 50 million desktops and growing -- these are
Certified UNIX systems.
Unix The OperatingSystem
UNIX (THE OS) Page 11
Starting Out Of UNIX
You can access a UNIX system in one of two general ways: either locally (that is,
while sitting at the computer you are connected to), or remotely (by connecting to the
computer over a network). Most of what you will learn in this book applies equally
well to either case. In particular, the basic UNIX commands will work in exactly the
same way Before you can start using those commands, however, you will need to
know how to access your UNIX system.
Connecting Locally:- To connect to a UNIX machine locally, you need to
be physically at the computer. If that computer is a UNIX workstation, all you need to
do is log in with your username and password. If you are using Mac OS X, you just
need to run the Terminal application, available under Applications | Utilities, in order
to access the UNIX command line that is built in to the operating system.
Connecting Remotely:- When you connect to a UNIX system remotely,
you are using your computer to access another system that is running UNIX.
Typically, this system supports many users at once. For example, many large
universities offer a UNIX account to all their students. The students log in to the
system from their own computers, either through the Internet or over the university
network.
In order to connect to a UNIX system like this, you will need Internet access from
your own computer. (In some cases, you may be able to dial in directly to the UNIX
system, but the details for how to do this depend on the specific system
configuration.) You will also need a terminal emulator application.
Unix The OperatingSystem
UNIX (THE OS) Page 12
Logging in
Once you have access to your UNIX system, you will need to log in with your
username and password. The UNIX operating system was designed for multiple
users. Requiring each user to log in ensures that the system remains secure, and
that each user’s files remain private.
Selecting a Login Name:- Every UNIX system has at least one person,
called the system administrator, whose job is to maintain the system.
In general, your login name can be almost any combination of letters and numbers,
although there are a few constraints:
 Your login name must be more than two characters long. If it is longer than
eight, only the first eight characters are relevant.
 It must contain only lowercase letters and numbers and must begin with a
lowercase letter. No symbols or spaces are allowed.
 It cannot be the same as another login name already in use. Some login
names are customarily reserved for certain uses; for example, root is often a
login name for the system administrator (sometimes called the superuser).
it is important to choose something that won’t become embarrassing or confusing
later. In some cases the system administrator may select a login name for you.
Unix The OperatingSystem
UNIX (THE OS) Page 13
Choosing a Password:- If you begin by installing a UNIX variant on your
own system, it will ask you to choose a password when you select a login name. If
your account is on a remote system, your system administrator will probably assign
you a temporary password, which you should change the first time you log in. UNIX
places some requirements on passwords, typically including the following:
 Passwords must have at least six characters.
 Passwords must contain at least two alphabetic characters (uppercase or
lowercase letters), and at least one number or symbol. Note that UNIX is
sensitive to case, so WIZARD is a different password than w1zard..
 Your login name with its letters reversed or shifted cannot be used as a
password. For example, if your login name is msilver, you cannot choose
silverm or revlism as a password.
Entering Commands
The UNIX System makes hundreds of programs available to the user. To run one of
these programs you issue a command. When you type date, for example, you are
really instructing the UNIX System command interpreter to execute a program with
the name date, and to display the results on your screen.
The most commonly used commands, however, are typically constant across
versions.
Command Options and Arguments:- The UNIX System has a
standardized command syntax that applies to almost all commands. Understanding
these patterns makes it easier to learn new UNIX commands. Some commands are
used alone, some require arguments that describe what the command is to operate
on, and some provide options that let you specify certain choices. Here is an
example of each type of command.
Unix The OperatingSystem
UNIX (THE OS) Page 14
The date command is usually used alone:
$ date
Fri Apr 27 22:14:05 EDT 2007
As you can see, entering the command date prints the current day and time.
Many commands take arguments (typically filenames) that specify what the
command operates on. For example, to view a file, you can type
$ cat notes
This tells the cat command to display the file notes.
Commands often allow you to specify options that influence the operation of the
command. You specify options for UNIX System commands by using a minus sign
followed by a letter or word. For example, the command ls by itself lists all the files in
a directory If you enter
$ ls -l
the -l option says to print a long version of the list with details about each file.
Stopping a Command:- You can stop a command by hitting CTRL-C. The
UNIX System will halt the command and return to the system prompt. You can do
this either while typing or after running a command. For example, you could use
CTRL-C if you were in the middle of entering a command and realized that it was
misspelled. Or you could use it to cancel ls if it were taking too long to list the
contents of a very large directory
CTRL-C is an example of a control character.
Unix The OperatingSystem
UNIX (THE OS) Page 15
The passwd Command:- On some UNIX systems, you are forced to
change your password after a certain length of time (determined by the system
administrator) for security reasons. Even if your system doesn’t enforce this, you
should remember to change it periodically You can do this with the passwd
command. When you issue the command, it asks for your current password, and a
new password, and then requires you to retype the new password to confirm it.
$ passwd
passwd: changing password for corwin
Old password:
New password:
Re-enter new password:
$
The cal command:- The cal command prints a calendar for any month or
year. If you do not give it an argument, it prints the current month. For example, on
March 27, 2007, you would get the following:
$ cal
March 2007
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
If you give cal a single number, it is treated as a year, and cal prints the calendar for
that year. So, for example, cal 2007 will display a calendar for all of 2007. If you
want to print a specific month other than the current month, enter the month number
first, then the year. To get the calendar for April 2008, use the following command:
$ cal 4 2008
Unix The OperatingSystem
UNIX (THE OS) Page 16
The who Command:- On a multiuser system among friends or coworkers,
you may wonder who else is currently logged in. The UNIX System provides a
standard command for getting this information:
$ who
dbp pts/10 Apr 2 09 52
etch pts/15 Apr 2 16 13
a-liu pts/16 Mar 29 23 21
corwin pts/18 Apr 2 06 33
raf pts/27 Apr 1 22 04
smullyan pts/31 Apr 2 16 48
For each user who is currently logged into this system, the who command provides
one line of output.
The finger Command:- The finger command provides you with more
complete information about other users on the system. The command:
$ finger corwin
will print out information about the user corwin. For example,
Login name: corwin Name: Eric Kruger
Directory:/home/corwin Shell:/usr/bin/bash
Last login Sun Aug 28 20:13:05 on pts/17
Project: Currently, I'm writing up my summer research project.
The write Command:- The write command copies the text you type to the
screen of another user who is logged in. If your login name is raf, the command:
$ write corwin
Hey, are you busy?
CTRL-D
will display the following message on corwin’s screen
Message from raf
Hey, are you busy?
EOF
Unix The OperatingSystem
UNIX (THE OS) Page 17
The talk Command:- A problem with write is that your messages can overlap
each other, which is awkward to read. The talk command is an enhanced
communication program. If your login name is raf, and you type.
$ talk corwin
the talk command notifies corwin that you wish to speak with him and asks him to
approve. Corwin sees the following on his screen:
Message from Talk_Daemon@amber at 20:15 ...
talk: connection requested by raf@amber
talk: respond with: talk raf@amber
The mesg Command :- Both the write and talk commands allow someone
to type a message that will be displayed on your screen. You may find it
disconcerting to have messages appear unexpectedly while you are working. In
order to control this, the UNIX System provides the mesg command, which allows
you to accept or refuse messages sent via write and talk. Type
$ mesg n
to prohibit programs run by other people from writing to your screen. Anyone who
tries to write you get the error message
Permission denied
Typing mesg n after someone has sent you a message will stop the conversation.
The sender will see the message “Can no longer write to user.”
The command
$ mesg y
Getting Command Details:- It can be hard to remember all the
commands and how to use them. The UNIX operating system comes with a built-in
manual so that you can look up the details for how to use each command. To view
Unix The OperatingSystem
UNIX (THE OS) Page 18
the manual page for a command, just type man followed by the command name. For
example,
$ man ls
will display the man page for ls. In addition, many commands have some amount of
built-in help. For example, ls --help will display a shorter version of the man page.
Logging Out
When you finish your work session and wish to leave the UNIX system, type exit (or
CTRL-D) to log out. After a few seconds, your UNIX system will display the “login:”
prompt:
$ exit
login:
This shows that you have logged out, and that the system is ready for another user
to log in using your terminal.
Always log out when you finish your work session or when leaving your computer.
An unattended session allows a passing stranger to access your work and possibly
the work of others.
If you have a single-user system, it is important to remember that logging out is not
the same as turning off your computer. To avoid problems, run the shutdown
command (or on some systems, poweroff) before logging out in order to make it
safe to turn off the machine. If you just turn the computer off without running
shutdown, you run a real risk of damaging files or loosing data.
Unix The OperatingSystem
UNIX (THE OS) Page 19
Command Summary :-
Command Use
passwd Change your password
date Get the current date and time
cal Display a calendar
who List all users who are currently logged in
finger username Get information about username
write username Send a chat message to username
talk username Open a chat session with username
mesg y
mesg n
Accept or block incoming messages
man command Get information about command
mailx
mailx address
Read e-mail messages, or send an e-mail to address
exit Log out of the system
shutdown poweroff Turn off the machine
Working with Files and Directories
The UNIX file system provides a powerful and flexible way to organize and manage
your information. the commands that provide the basic file manipulation operations-
viewing files, changing directories, deleting and moving files-are among the UNIX
commands you will use most often.
Files:- A file is the basic structure that stores information on the UNIX System
(and on Windows systems, as well). Conceptually, a computer file is similar to a
paper document. Technically a file is a sequence of bytes that is stored somewhere
on a storage device, such as a hard drive. A file can contain any kind of information
that can be represented as a sequence of bytes. Word processing documents,
bitmap images, and computer programs are all examples of files.
Unix The OperatingSystem
UNIX (THE OS) Page 20
Filenames:- Every file has a title, called a filename. A filename can be almost
any sequence of characters, and up to 255 characters long. (On some older versions
of UNIX, two filenames are considered the same if the first 14 characters are
identical, so be careful if you use long filenames on these systems.) You can use
any ASCII character in a filename except for the null character (ASCII NUL) or the
slash (/), which has a special meaning in the UNIX file system. The slash acts as a
separator between directories and files.
Many of these characters have special meanings in the command shell, which
makes them difficult to work with in filenames
! (exclamation
point)
* (asterisk) {,} (brackets)
# (pound sign) ? (question mark) ; (semicolon)
& (ampersand)  (backslash) ^ (caret)
| (pipe) (,) (parentheses) Tab
@ (at sign) ‘,” (single or double
quotes)
Space
$ (dollar sign) < , > (left or right arrow) Backspace
Capitalization
Windows does not distinguish between uppercase and lowercase letters in
filenames. You could save a file with the name Notes.DOC and find it by searching
for notes.doc. The UNIX file system, however, is case-sensitive, meaning that
uppercase and lowercase letters are distinct. In UNIX, NOTES, Notes, and notes
would be three different files. If you save a file with the name Music, you will not find
it by searching for music. This also applies to commands in UNIX. If you are trying to
log out with the exit command, typing EXIT will not work. By the way, this explains
Unix The OperatingSystem
UNIX (THE OS) Page 21
why URLs (web addresses) can be case-sensitive, since the first web server was
created on a UNIX-based platform, and many web servers still run UNIX.
Filename Extensions:- In Windows, filenames typically consist of a
basename, followed by a period and a short filename extension. Many Windows
programs depend on the extension to determine how to use the file. For example, a
file named solitaire.exe is considered to be a file named solitaire with the extension
.exe, where the .exe extension tells Windows that it is an executable program. If the
file extension is altered or deleted, it will be more difficult to work with the file in
Windows.
Some programs either produce or expect a file with a particular filename extension.
For example, files that contain C source code have the extension .c, so sorting.c
would be a C language file. Similarly, web browsers expect that HTML files will have
the extension .html, such as index.html.
Common File Extensions :-
Table:- Common File Extensions
C File Type Extension File Type
.au Audio .mpg,
.mpeg
MPEG video
.c C language source
code
.o Object file (compiled and assembled
code)
.cc C++ source code .pl Perl script
.class Compiled Java file .ps PostScript file
.conf Configuration file .py Python script
.d Directory .sh Bourne shell script
.gif GIF image .tar tar archive
.gz Compressed with
gzip
.tar.Z,
.tar.gz
Files that have been archived with tar
and then compressed
.h Header file for a C
program
.tex Text formatted with Tex/LaTeX
.html Webpage .txt ASCII text
.jar Java archive .uu, .uue Uuencoded file
.java Java source code .wav Wave audio
.jpg,
.jpeg
JPEG image .z Compressed with pack
Unix The OperatingSystem
UNIX (THE OS) Page 22
Table:- Common File Extensions
C File Type Extension File Type
.log Log file .Z Compressed with compress
UNIX files can have more than one extension. For example, the file book.tar.Z is a
file that has first been archived using the tar command (which adds the extension
.tar) and then compressed using the compress command (which adds the .Z). This
enables a single script to both decompress the file and untar it, using the filename as
input and parsing each of the extensions to perform the appropriate task.
. Directories
Files contain the information you work with. Directories provide a way to organize
your files. A directory is just a container for as many files as you care to put in it. If
you think of a file as analogous to a document in your office, then a directory is like a
file folder. In fact, directories in UNIX are exactly like folders in Windows.
For example, you may decide to create a directory to hold all of your notes. You
could name it Notes and use it to hold only files that are your notes, keeping them
separated from your e-mail, programs, and other files.
Subdirectories:- A directory can also contain other directories. A directory
inside another directory is called a subdirectory. You can create as many
subdirectories inside a particular directory as you wish.
Choosing Directory Names:- It is a good idea to adopt a convention for
naming directories so that they can be easily distinguished from ordinary files. Some
people give directories names that are all uppercase letters, some use directory
names that begin with an uppercase letter, and others distinguish directories using
the extension .d or .dir. For example, if you decide to use names beginning with an
Unix The OperatingSystem
UNIX (THE OS) Page 23
uppercase letter for directories and avoid naming ordinary files this way, you will
know that Notes, Misc, Multimedia, and Programs are all directories.
The Hierarchical File Structure:- Because directories can contain
other directories, which can in turn contain other directories, the UNIX file system is
called a hierarchical file system. Within the UNIX System, there is no limit to the
number of files and directories you can create in a directory that you own.
Pathnames:- the UNIX System allows you to specify filenames by including
the location of the file in the directory tree. This type of name is called a pathname,
because it is a listing of the directories you travel through along the path you take to
get to the file. The path through the file system starts at root (/), and the names of
directories and files in a pathname are separated by slashes.
For example, the pathname for one of the save files is
/home/raf/Email/save
and the pathname for the other is
/home/raf/Work/save
Relative Pathnames:-You do not always have to specify the full pathnames
when you refer to files. As a convenient shorthand, you can also specify a path to a
file relative to your present directory Such a pathname is called a relative pathname.
Instead of starting with a / for root, the relative pathname starts with the name of a
Unix The OperatingSystem
UNIX (THE OS) Page 24
subdirectory For example, suppose you are in your home directory, /home/raf. The
relative path for the save file in the Email subdirectory is Email/save, and the relative
path for the other save file is Work/save.
Specifying the Current Directory:- A single dot (.) is used as a
shortcut to refer to the directory you are currently in. This directory is known as the
current directory.
Specifying the Parent Directory:- Two dots (.., pronounced “dot-dot”)
refer to the parent directory of the one you are currently in. The parent directory is
the one at the next higher level in the directory tree. Because the file system is
hierarchical, all directories have a parent directory The dot-dot references can be
used many times to refer to things far up in the file system. The following sequence,
for example,
../..
refers to the parent of the parent of the current directory. If you are in Work, then ../..
is the same thing as the home directory, since home is the parent of raf, which is the
parent of Work.
Specifying a Home Directory:- A tilde (~) can be used to refer to your
home directory (Strictly speaking, this is a feature of the shell, which will be
discussed in the next chapter. It will work on most modern UNIX systems.)
These shortcuts can be combined. For example, if your home directory is /home/raf,
then
~/../liz
refers to the home directory for the user liz.
Unix The OperatingSystem
UNIX (THE OS) Page 25
Configuring the Shell
When your login shell starts up, it looks for certain files in your home directory.
These files contain commands that can be used to configure your working
environment. The particular files it looks for depend on which shell you are using:
 sh runs the commands in a configuration file called .profile.
 ksh also uses the .profile file. In addition, you can set a variable in your
.profile to cause it to read the commands in a second file. The variable is
called ENV. By convention, that file is often called .kshrc.
 bash uses the file .bash_profile. If that file does not exist, it will look for the file
.profile, instead. The .bash_profile often contains a line that causes bash to
run the commands in a second file, bashrc. When you log out of bash, it will
run the commands in .bash_logout.
 csh looks for a file called .login. It will also run commands in .cshrc. When you
log out of the C shell, it will run the commands in the file .logout.
 tcsh uses the .login file as well. It also looks for .tshrc. If that file does not
exist, it will look for .cshrc instead. Like the C shell, tcsh will run the .logout
file when you log out.
This may all sound very confusing, but these configuration files all work in pretty
much the same way Each of these files is actually an example of a shell script. They
contain commands or instructions for the shell. The commands include settings that
allow you to customize your environment.
The first file that the shell reads (.profile, .bash_profile, or .login) contains variables
or settings that you want to be in effect throughout your login session. The section
“Shell Variables” later in this chapter describes these variables. The file might also
include commands you want to run at login, such as cal (to display a calendar for the
current month) or who (to show the list of users who are currently logged in).
Unix The OperatingSystem
UNIX (THE OS) Page 26
Interactive Shells:- You can start another shell after you log in by using the
name of the shell as a command; for example, to start the Korn shell, you could type
ksh at the command prompt. This type of shell is not a login shell, and you do not
have to log in again to use it, but it is still an interactive shell, meaning that you
interact with the shell by typing in commands The instances of the shell that run in a
terminal window when you are using a graphical interface are also interactive non-
login shells. When you start a non-login shell, it does not read your .profile,
.bash_profile, or .login file (or your .logout file), but it will still read the second shell
configuration file (such as .bashrc).
Sample Configuration Files:- If you define a variable by typing its new
value on the command line, it will return to its previous value the next time you log in.
In order to keep important variables such as PATH, PS1, and TERM defined every
time you log in, they are usually included in one of your configuration files. Here are
a few examples of those files. Don’t worry if the commands don’t make sense yet-
you can come back to this later, after reading the sections “Shell Variables” and
“Command Aliases.”
Sample.bash profile:- Every time you log in, bash reads your .bash_profile.
This file includes definitions of environment variables that will be shared with other
programs and commands such as who that you want to run at the beginning of each
login session. A typical .bash_profile might look some-thing like this:
# .bash_profile - example
# set environment variables
export TERM=vt100
export PATH=$PATH:/sbin:/usr/sbin:$HOME/bin
export MAILCHECK=30
# allow incoming messages from other users
mesg y
Unix The OperatingSystem
UNIX (THE OS) Page 27
# make sure backspace works
stty erase "^H"
# show all users who are currently logged in
who
# load aliases and local variables
. -/.bashrc
The last line executes your .bashrc file. If you leave it out, bash will not read your
aliases and variable definitions when you log in.
Sample .bashrc File:- when you start an interactive bash shell after
logging in (e.g., by opening an xterm window), it reads the commands in your
.bashrc file. This file includes commands and definitions that you want to have
executed every time you run a shell-not just at login. The .bashrc file defines local
shell variables (but not environment variables, which belong in .bash_profile), shell
options, and command aliases. It might look something like this:
# .bashrc file-example
# set shell variables (such as the prompt)
PS1="u w> "
# set shell options
set −o noclobber
set −o emacs
set +o notify
# set default file permissions
umask 027
# define aliases
Unix The OperatingSystem
UNIX (THE OS) Page 28
alias lg='ls -g -color=tty'
alias r='fc -s'
alias rm='rm -i'
alias cp='cp -r'
alias wg='who | grep'
alias hibernate='sudo apm -s'
A configuration file for ksh could look like this, as well. However, the line PS1=“u
w>” in this example would have to be changed to PS1=‘$LOGNAME $(pwd)> ’,
because ksh doesn’t support the bash shortcuts for defining the prompt.
Sample .login File:-As the name suggests, tcsh reads the .login file only
when you log in. Your .login file should contain commands and variable definitions
that only need to be executed at the beginning of your session. Examples of things
you would put in .login are commands for initializing your terminal settings,
commands such as date that you want to run at the beginning of each login session,
and definitions of environment variables.
The following is a short example of what you might put in a typical .login file:
# .login file-example
# show number of users on system
echo "There are" who wc -l "users on the system"
# set terminal options-- in particular,
# make sure that the Backspace key works
stty erase "^H"
# set environment variables
setenv term vt100
setenv mail ( 60 /var/spool/mail/$user)
Unix The OperatingSystem
UNIX (THE OS) Page 29
These examples illustrate the use of setenv, the C shell command for defining
environment variables. setenv and its use are discussed further later on, in the
section “csh and tcsh Variables.”
Sample .tcshrc File:- The difference between .tcshrc and .login is that tcsh
reads .login only at login, but it reads .tcshrc both when it is being started up as a
login shell and when it is invoked as an interactive non-shell. The .tcshrc file includes
commands and definitions that you want to have executed every time you run a
shell-not just at login.
Your .tcshrc should include your alias definitions, and definitions of variables that are
used by the shell but are not environment variables. Environment variables should
be defined in .login.
# .tcshrc file-example
# set shell variables
set path = ($path /sbin /usr/sbin /usr/bin /$home/bin)
set prompt = "[%n@%m %c] tcsh % "
# turn on ignoreeof and noclobber
# turn off notify
set ignoreeof
set noclobber
unset notify
# define aliases
alias lsc ls -Ct
alias wg 'who | grep'
alias rm rm -i
alias cp cp -r
alias hibernate sudo apm -s
# set permissions for file creation
Unix The OperatingSystem
UNIX (THE OS) Page 30
umask 027
This sample file includes C shell variable definitions and aliases, both of which are
explained in the following sections.
Shell Variables
The shell provides a mechanism to define variables that can be used to hold pieces
of information. Shell variables can be used to customize the way in which programs
(including the shell itself) interact with you. This section will describe some of the
standard variables used by the shell and other programs, and explain what they do
for you.
Assigning Variables and Aliases :-
Table: Assigning Variables and Aliases
sh, ksh, or bash csh or tcsh Effect
VAR=value set var=value Assign a value to a variable
$VAR $var Get the value of a variable
set set List shell variables
unset VAR unset var Remove a variable
env env List all environment variables
VAR=value; export VAR export
VAR=value
setenv var
value
Create an environment
variable
unset VAR unsetenv var Remove an environment
variable
set -o View shell options
set -o option set option Turn on a shell option
set +o option unset option Turn off an option
alias name=value alias name
value
Create a command alias
unalias name unalias name Remove an alias
Unix The OperatingSystem
UNIX (THE OS) Page 31
Variables in sh, ksh, and bash:- You define a shell variable by typing
a name followed by an=sign and a value. For example, you could create a variable
called PROJDIR to save the pathname for a directory you use often:
$ PROJDIR=/home/nate/Work/cs106x/Proj_3/lib/Source
To assign a value with a space in it, use quotes, like this:
$ FILELIST='graphics.c strings.c sorting.c'
In the Bourne-compatible shells, variable names are conventionally written in
uppercase letters, although you can use lowercase names as well. As with
filenames, variable names are case-sensitive, so the shell will treat PROJDIR and
projdir as two different variables.
To get the value of a shell variable, precede the variable name with a dollar sign, $.
You can print a variable with the echo command, which copies its standard input to
its standard output.
$ echo $PROJDIR
/home/nate/Work/cs106x/Proj ect_3/lib/Source
Environment Variables in sh, ksh, and bash:-
When you run a command, the shell makes certain shell variables and their values
available to the program. The program can then use this information to customize its
actions. The collection of variables and values provided to programs is called the
environment.
Your environment includes variables set by the system, such as HOME, LOGNAME,
and PATH (described in the next section). You can display your environment
variables with the command env:
$ env
HOSTNAME=localhost.localdomain
SHELL=/bin/bash
Unix The OperatingSystem
UNIX (THE OS) Page 32
MAIL=/var/spool/mail/raf
PATH=/usr/local/bin:/bin:/usr/bin:/home/raf/bin
PWD=/home/raf/Proj ect
PS1='$ '
HOME=/home/raf
LOGNAME=raf
To make variables that you define yourself available to commands as part of the
environment
Common Shell Variables in sh, ksh, and bash:- The following is
a short summary of some of the most common shell variables, including those set
automatically by the system.
 HOME contains the absolute pathname of your login directory HOME is
automatically defined and set to your login directory as part of the login
process. The shell itself uses this information to determine the directory to
change to when you type cd with no argument.
 LOGNAME contains your login name. It is set automatically by the system.
 PWD is a special variable that gets set automatically to your present working
directory You can use this variable to include your current directory in the
prompt or in a command line.
 PATH lists the directories in which the shell searches to find the program to
run when you type a command. A default PATH is set by the system, but
many users modify it to add additional command directories.
A typical example of a customized PATH, in this case for user anita, is the following:
PATH=$PATH:/sbin:/usr/bin:/home/anita/bin
Shell Options in ksh and bash:- The Korn shell and bash provide a
number of options that turn on special features. To turn on an option, use the set
command with -o (option) followed by the option name. To view your current option
settings, use set -o by itself.
Unix The OperatingSystem
UNIX (THE OS) Page 33
The noclobber option prevents you from overwriting an existing file when you redirect
output from a command. This can save you from losing data that may be difficult or
impossible to replace. You can turn on noclobber with set:
$ set -o noclobber
Suppose noclobber is set, and your current directory contains a file named temp. If
you try to redirect the output of a command to temp, you get a warning:
$ ls -1 > temp
temp: file exists
You can tell the shell that you really do want to overwrite the file by putting a bar
(pipe symbol) after the redirection symbol, like this:
$ ls -1 >| temp
To turn off an option, use set +o, as in
$ set +o noclobber
The ignoreeof feature prevents you from accidentally logging yourself off by typing
CTRL-D. If you use this option, you must type exit to terminate the shell.
s

More Related Content

What's hot (20)

UNIX Operating System
UNIX Operating SystemUNIX Operating System
UNIX Operating System
 
L7 operating system
L7   operating systemL7   operating system
L7 operating system
 
Operating System
Operating SystemOperating System
Operating System
 
WELCOME TO THE CORE OF UNIX OPERATING SYSTEM
WELCOME TO THE CORE OF UNIX OPERATING SYSTEMWELCOME TO THE CORE OF UNIX OPERATING SYSTEM
WELCOME TO THE CORE OF UNIX OPERATING SYSTEM
 
Linux Vs Unix
Linux Vs UnixLinux Vs Unix
Linux Vs Unix
 
Module 3 unit 1
Module 3  unit 1Module 3  unit 1
Module 3 unit 1
 
Neha ict project
Neha ict projectNeha ict project
Neha ict project
 
Linux vs windows
Linux vs windowsLinux vs windows
Linux vs windows
 
Ch02
Ch02Ch02
Ch02
 
Linux
LinuxLinux
Linux
 
Presentation On Operating system
Presentation On Operating systemPresentation On Operating system
Presentation On Operating system
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
 
Windows V/S Linux OS - Comparison
Windows V/S Linux OS - ComparisonWindows V/S Linux OS - Comparison
Windows V/S Linux OS - Comparison
 
Case study operating systems
Case study operating systemsCase study operating systems
Case study operating systems
 
Case study windows
Case study windowsCase study windows
Case study windows
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
Group 5 Report Effect
Group 5 Report EffectGroup 5 Report Effect
Group 5 Report Effect
 
Unix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | BlocksUnix and shell programming | Unix File System | Unix File Permission | Blocks
Unix and shell programming | Unix File System | Unix File Permission | Blocks
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Unix Security
Unix SecurityUnix Security
Unix Security
 

Viewers also liked

Avto 12 de octubre 2013
Avto 12 de octubre 2013Avto 12 de octubre 2013
Avto 12 de octubre 2013Fadri
 
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICOprocessociviletelematico
 
Presentaciónpatricia ovelar
Presentaciónpatricia ovelarPresentaciónpatricia ovelar
Presentaciónpatricia ovelarpatyovelar
 
Общественный контроль и дружинники
Общественный контроль и дружинники Общественный контроль и дружинники
Общественный контроль и дружинники Vadim Karastelev
 
Bowen v Taylor
Bowen v TaylorBowen v Taylor
Bowen v TaylorJonSutz
 
Mission vishvas-resume template-18
Mission vishvas-resume template-18Mission vishvas-resume template-18
Mission vishvas-resume template-18vishvasyadav45
 
Использование вопрошания кейсы (1)
Использование вопрошания кейсы (1)Использование вопрошания кейсы (1)
Использование вопрошания кейсы (1)Vadim Karastelev
 
Dodatek Marketingový plán tianDe 2020 cz
Dodatek Marketingový plán tianDe 2020 czDodatek Marketingový plán tianDe 2020 cz
Dodatek Marketingový plán tianDe 2020 czLiza Alypova
 
Hanson Amended Final December 2013 Version_pdf
Hanson Amended Final December 2013 Version_pdfHanson Amended Final December 2013 Version_pdf
Hanson Amended Final December 2013 Version_pdfRaymon Hanson
 
1. tian de business community
1. tian de business community1. tian de business community
1. tian de business communityLiza Alypova
 
Policy Watch : India’s Integration into the Global Economy
 Policy Watch : India’s Integration into the Global Economy Policy Watch : India’s Integration into the Global Economy
Policy Watch : India’s Integration into the Global EconomyConfederation of Indian Industry
 
Project communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpProject communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpvishvasyadav45
 
Vsegda krasivye volosy_sekret_omolazhivayuschikh_ki
Vsegda krasivye volosy_sekret_omolazhivayuschikh_kiVsegda krasivye volosy_sekret_omolazhivayuschikh_ki
Vsegda krasivye volosy_sekret_omolazhivayuschikh_kiLiza Alypova
 
03 service retirement governance recommendation cmmaao pmi pmp
03 service retirement governance recommendation cmmaao pmi pmp03 service retirement governance recommendation cmmaao pmi pmp
03 service retirement governance recommendation cmmaao pmi pmpvishvasyadav45
 

Viewers also liked (20)

Avto 12 de octubre 2013
Avto 12 de octubre 2013Avto 12 de octubre 2013
Avto 12 de octubre 2013
 
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO
3. PROCESSO CIVILE TELEMATICO - DECRETO INGIUNTIVO TELEMATICO
 
Presentaciónpatricia ovelar
Presentaciónpatricia ovelarPresentaciónpatricia ovelar
Presentaciónpatricia ovelar
 
Общественный контроль и дружинники
Общественный контроль и дружинники Общественный контроль и дружинники
Общественный контроль и дружинники
 
Bowen v Taylor
Bowen v TaylorBowen v Taylor
Bowen v Taylor
 
Test Corr
Test CorrTest Corr
Test Corr
 
Economy Matters - Nov-Dec 2014
Economy Matters - Nov-Dec 2014Economy Matters - Nov-Dec 2014
Economy Matters - Nov-Dec 2014
 
Mission vishvas-resume template-18
Mission vishvas-resume template-18Mission vishvas-resume template-18
Mission vishvas-resume template-18
 
Mezoroller cz
Mezoroller czMezoroller cz
Mezoroller cz
 
Использование вопрошания кейсы (1)
Использование вопрошания кейсы (1)Использование вопрошания кейсы (1)
Использование вопрошания кейсы (1)
 
Dodatek Marketingový plán tianDe 2020 cz
Dodatek Marketingový plán tianDe 2020 czDodatek Marketingový plán tianDe 2020 cz
Dodatek Marketingový plán tianDe 2020 cz
 
Hanson Amended Final December 2013 Version_pdf
Hanson Amended Final December 2013 Version_pdfHanson Amended Final December 2013 Version_pdf
Hanson Amended Final December 2013 Version_pdf
 
CII Communique December 2016
CII Communique  December 2016CII Communique  December 2016
CII Communique December 2016
 
1. tian de business community
1. tian de business community1. tian de business community
1. tian de business community
 
Policy Watch : India’s Integration into the Global Economy
 Policy Watch : India’s Integration into the Global Economy Policy Watch : India’s Integration into the Global Economy
Policy Watch : India’s Integration into the Global Economy
 
Project communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmpProject communication plan v1c cmmaao pmi pmp
Project communication plan v1c cmmaao pmi pmp
 
21
2121
21
 
盛大文学
盛大文学盛大文学
盛大文学
 
Vsegda krasivye volosy_sekret_omolazhivayuschikh_ki
Vsegda krasivye volosy_sekret_omolazhivayuschikh_kiVsegda krasivye volosy_sekret_omolazhivayuschikh_ki
Vsegda krasivye volosy_sekret_omolazhivayuschikh_ki
 
03 service retirement governance recommendation cmmaao pmi pmp
03 service retirement governance recommendation cmmaao pmi pmp03 service retirement governance recommendation cmmaao pmi pmp
03 service retirement governance recommendation cmmaao pmi pmp
 

Similar to Unix seminar

CHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptxCHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptxMahiDivya
 
Linux System-R.D.Sivakumar
Linux System-R.D.SivakumarLinux System-R.D.Sivakumar
Linux System-R.D.SivakumarSivakumar R D .
 
IntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroductionIntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroductionNagavelliMadhavi
 
Unix Quick Learn
Unix Quick LearnUnix Quick Learn
Unix Quick LearnNisanth
 
Introduction to unix (1).pptx
Introduction to unix (1).pptxIntroduction to unix (1).pptx
Introduction to unix (1).pptxvirat834293
 
ppt on linux by MUKESH PATEL
ppt on linux by MUKESH PATELppt on linux by MUKESH PATEL
ppt on linux by MUKESH PATELneo_patel
 
OPERATING SYSTUM class 9 Information.pptx
OPERATING SYSTUM class 9 Information.pptxOPERATING SYSTUM class 9 Information.pptx
OPERATING SYSTUM class 9 Information.pptxrajdeepcs10
 
Linux principles and philosophy
Linux principles and philosophyLinux principles and philosophy
Linux principles and philosophyaliabintouq
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating SystemShivam Pandey
 
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiIntroduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiSowmya Jyothi
 
Unix shell programming intro-part-1
Unix shell programming intro-part-1Unix shell programming intro-part-1
Unix shell programming intro-part-1Prachi Sasankar
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docxBhuvanaR13
 

Similar to Unix seminar (20)

Wk2 UNIX
Wk2  UNIXWk2  UNIX
Wk2 UNIX
 
Ch1-Unix.pptx
Ch1-Unix.pptxCh1-Unix.pptx
Ch1-Unix.pptx
 
CHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptxCHAPTER 1 INTRODUCTION TO UNIX.pptx
CHAPTER 1 INTRODUCTION TO UNIX.pptx
 
UNIX_module1.pptx
UNIX_module1.pptxUNIX_module1.pptx
UNIX_module1.pptx
 
Linux System-R.D.Sivakumar
Linux System-R.D.SivakumarLinux System-R.D.Sivakumar
Linux System-R.D.Sivakumar
 
IntroToUnix.ppt
IntroToUnix.pptIntroToUnix.ppt
IntroToUnix.ppt
 
IntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroductionIntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroduction
 
Linux Introduction
Linux IntroductionLinux Introduction
Linux Introduction
 
Presentation1.pdf
Presentation1.pdfPresentation1.pdf
Presentation1.pdf
 
Unix Quick Learn
Unix Quick LearnUnix Quick Learn
Unix Quick Learn
 
Introduction to unix (1).pptx
Introduction to unix (1).pptxIntroduction to unix (1).pptx
Introduction to unix (1).pptx
 
Spsl unit1
Spsl   unit1Spsl   unit1
Spsl unit1
 
ppt on linux by MUKESH PATEL
ppt on linux by MUKESH PATELppt on linux by MUKESH PATEL
ppt on linux by MUKESH PATEL
 
OPERATING SYSTUM class 9 Information.pptx
OPERATING SYSTUM class 9 Information.pptxOPERATING SYSTUM class 9 Information.pptx
OPERATING SYSTUM class 9 Information.pptx
 
Linux principles and philosophy
Linux principles and philosophyLinux principles and philosophy
Linux principles and philosophy
 
training report
training reporttraining report
training report
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya JyothiIntroduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
Introduction to Unix operating system Chapter 1-PPT Mrs.Sowmya Jyothi
 
Unix shell programming intro-part-1
Unix shell programming intro-part-1Unix shell programming intro-part-1
Unix shell programming intro-part-1
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docx
 

Unix seminar

  • 1. Unix The OperatingSystem UNIX (THE OS) Page 1 Introduction to UNIX UNIX is an operating system which was first developed in the 1960s, at AT&T Bell Laboratories and at the University of California, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops. UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no windows interface available, for example, in a telnet session. Unix is also part of the underlying technology of the Internet. Although no operating systems has any exclusive claim to the Internet, many of the standard technologies, protocols and applications that make up the Internet were first developed on Unix systems. Multi-user:- Multi-user is a term that defines an operating system or application software that allows access by multiple users of a computer. Time-sharing systems are multi-user systems. Most batch processing systems for mainframe computers may also be considered "multi- user", to avoid leaving the CPU idle while it waits for I/O operations to complete. Multi tasking:- multitasking is a method where multiple tasks, also known as processes, are performed during the same period of time. The tasks share common processing resources, such as a CPU and main memory. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is actively executing instructions for that task. Multitasking solves the problem by scheduling which task may be the one running at any given time, and when another waiting task gets a turn.
  • 2. Unix The OperatingSystem UNIX (THE OS) Page 2 Graphical User Interface:- graphical user interface (GUI) is a type of user interface that allows users to interact with electronic devices using images rather than text commands. GUIs can be used in computers, hand-held devices such as MP3 players, portable media players or gaming devices, household appliances, office and industry equipment. UNIX importance UNIX, as it is implemented in its many variants, serves as the operating system for all types of computers, including personal computers and engineering workstations, multiuser microcomputers, minicomputers, mainframes, and supercomputers, as well as special-purpose devices. The number of computers running a variant of UNIX has grown explosively with more than 40 million computers now running a variant of UNIX and more than 300 million people using these systems. This rapid growth, especially for computers running Linux, is expected to continue, according to most computer industry experts. The success of UNIX is due to many factors, including its portability to a wide range of machines, its adaptability and simplicity, the wide range of tasks that it can perform, its multiuser and multitasking nature, and its suitability for networking, which has become increasingly important as the Internet has blossomed. What follows is a description of the features that have made UNIX so popular. Open Source Code:- The source code for key variants of UNIX, and not just the executable code, has been made available to users and programmers. Because of this, many people have been able to adapt UNIX in different ways. This openness has led to the introduction of a wide range of new features and versions customized to meet special needs. It has been easy for developers to adapt to UNIX, because the computer code for UNIX is straightforward, modular, and compact.
  • 3. Unix The OperatingSystem UNIX (THE OS) Page 3 Cooperative Tools and Utilities:- The UNIX System provides users with many different tools and utilities that can be leveraged to perform an amazing variety of jobs. Some of these tools are simple commands that you can use to carry out specific tasks. Other tools and utilities are really small programming languages that you can use to build scripts to solve your own problems. Multiuser and Multitasking Abilities:- The UNIX operating system can be used for computers with many users or a single user, because it is a multiuser system. It is also a multitasking operating system, because a single user can carry out more than one task at once. For instance, you can run a program that checks the spelling of words in a text file while you simultaneously read your electronic mail. Excellent Networking Environment:- The UNIX operating system provides an excellent environment for networking. It offers programs and utilities that provide the services needed to build networked applications-the basis for distributed, networked computing. With networked computing, information and processing is shared among different computers in a network. The UNIX system has proved to be useful in client/server computing where machines on a network can be both clients and servers at the same time. UNIX also has been the base system for the development of Internet services and for the growth of the Internet. Portability:- It is far easier to port UNIX to new machines than other operating systems-that is, far less work is needed to adapt it to run on a new hardware platform. The portability of UNIX results from its being written almost entirely in the C programming language. The portability to a wide range of computers makes it possible to move applications from one system to another.
  • 4. Unix The OperatingSystem UNIX (THE OS) Page 4 The Structure of UNIX Operating System To understand how UNIX works, you need to understand its structure. The UNIX operating system is made up of several major components. These components include the kernel, the shell, the file system, and the commands (or user programs). The relationship among the user, the shell, the kernel, and the underlying hardware is displayed in Figure. The Kernel:- The kernel is the part of the operating system that interacts directly with the hardware of a computer, through device drivers that are built into the kernel. It provides sets of services that can be used by programs, insulating these programs from the underlying hardware. The major functions of the kernel are to
  • 5. Unix The OperatingSystem UNIX (THE OS) Page 5 manage computer memory, to control access to the computer, to maintain the file system, to handle interrupts (signals to terminate execution), to handle errors, to perform input and output services (which allow computers to interact with terminals, storage devices, and printers), and to allocate the resources of the computer (such as the CPU or input/output devices) among users. Utilities:- The UNIX System contains several hundred utilities or user programs. Commands are also known as tools, because they can be used separately or put together in various ways to carry out useful tasks. You execute these utilities by invoking them by name through the shell; this is why they are called commands. A critical difference between UNIX and earlier operating systems is the ease with which new programs can be installed-the shell need only be told where to look for commands, and this is user-definable. The File System:- The basic unit used to organize information in UNIX is called a file. The UNIX file system provides a logical method for organizing, storing, retrieving, manipulating, and managing information. Files are organized into a hierarchical file system, with files grouped together into directories. An important simplifying feature of UNIX is the general way it treats files. For example, physical devices are treated as files; this permits the same commands to work for ordinary files and for physical devices; for instance, printing a file (on a printer) is treated similarly to displaying it on the terminal screen. The Shell:- The shell reads your commands and interprets them as requests to execute a program or programs, which it then arranges to have carried out. Because the shell plays this role, it is called a command interpreter. Besides being a command interpreter, the shell is also a programming language. As a programming language, it permits you to control how and when commands are carried out.
  • 6. Unix The OperatingSystem UNIX (THE OS) Page 6 Applications Of UNIX There are many applications of UNIX discussed as below:  You can use applications built using UNIX commands, tools, and programs.  horizontal applications like as government, industry, and education.  Others are industry-specific and are known as vertical applications  web browsers and web server application  Another important class of applications deals with multimedia. Such applications let users create and view multimedia files, including audio, images, and video. UNIX Philosphy UNIX has developed a characteristic, consistent approach that is sometimes referred to as the UNIX philosophy. This philosophy has deeply influenced the structure of the system and the way it works. Keeping this philosophy in mind helps you understand the way UNIX treats files and programs, the kinds of commands and programs it provides, and the way you use it to accomplish a task. The UNIX philosophy is based on the idea that a powerful and complex computer system should still be simple, general, and extensible, and that making it so provides important benefits for both users and program developers. Another way to express the basic goals of the UNIX philosophy is to note that, for all its size and complexity, UNIX still reflects the idea that “small is beautiful.” This approach is especially reflected in the way UNIX treats files and in its focus on software tools.
  • 7. Unix The OperatingSystem UNIX (THE OS) Page 7 The Birth Of The Unix System The history of the UNIX System dates back to the late 1960s when MIT, AT&T Bell Labs, and then-computer manufacturer GE (General Electric) worked on an experimental operating system called Multics. Multics, from Multiplexed Information and Computing System, was designed to be an interactive operating system for the GE 645 mainframe computer, allowing information sharing while providing security Development met with many delays, and production versions turned out to be slow and required extensive memory For a variety of reasons, Bell Labs dropped out of the project. However, the Multics system implemented many innovative features and produced an excellent computing environment. 1969 The Beginning The history of UNIX starts back in 1969, when Ken Thompson, Dennis Ritchie and others started working on the "little-used PDP-7 in a corner" at Bell Labs and what was to become UNIX. 1971 First Edition It had a assembler for a PDP-11/20, file system, fork(), roff and ed. It was used for text processing of patent documents. 1973 Fourth Edition It was rewritten in C. This made it portable and changed the history of OS's. 1975 Sixth Edition UNIX leaves home. Also widely known as Version 6, this is the first to be widely available out side of Bell Labs. The first BSD version (1.x) was derived from V6. 1979 Seventh Edition It was a "improvement over all preceding and following Unices" [Bourne]. It had C, UUCP and the Bourne shell. It was ported to the VAX and the kernel was more than 40
  • 8. Unix The OperatingSystem UNIX (THE OS) Page 8 Kilobytes (K). 1980 Xenix Microsoft introduces Xenix. 32V and 4BSD introduced. 1982 System III AT&T's UNIX System Group (USG) release System III, the first public release outside Bell Laboratories. SunOS 1.0 ships. HP-UX introduced. Ultrix-11 Introduced. 1983 System V Computer Research Group (CRG), UNIX System Group (USG) and a third group merge to become UNIX System Development Lab. AT&T announces UNIX System V, the first supported release. Installed base 45,000. 1984 4.2BSD University of California at Berkeley releases 4.2BSD, includes TCP/IP, new signals and much more. X/Open formed. 1984 SVR2 System V Release 2 introduced. At this time there are 100,000 UNIX installations around the world. 1986 4.3BSD 4.3BSD released, including internet name server. SVID introduced. NFS shipped. AIX announced. Installed base 250,000. 1987 SVR3 System V Release 3 including STREAMS, TLI, RFS. At this time there are 750,000 UNIX installations around the world. IRIX introduced. 1988 POSIX.1 published. Open Software Foundation (OSF) and UNIX International (UI) formed. Ultrix 4.2 ships. 1989 AT&T UNIX Software Operation formed in preparation for spinoff of USL. Motif 1.0 ships. 1989 SVR4 UNIX System V Release 4 ships, unifying System V, BSD and Xenix. Installed base 1.2 million. 1990 XPG3 X/Open launches XPG3 Brand. OSF/1 debuts. Plan 9 from Bell Labs ships. 1991 UNIX System Laboratories (USL) becomes a company - majority-owned by AT&T. Linus Torvalds commences
  • 9. Unix The OperatingSystem UNIX (THE OS) Page 9 Linux development. Solaris 1.0 debuts. 1992 SVR4.2 USL releases UNIX System V Release 4.2 (Destiny). October - XPG4 Brand launched by X/Open. December 22nd Novell announces intent to acquire USL. Solaris 2.0 ships. 1993 4.4BSD 4.4BSD the final release from Berkeley. June 16 Novell acquires USL Late 1993 SVR4.2MP Novell transfers rights to the "UNIX" trademark and the Single UNIX Specification to X/Open. COSE initiative delivers "Spec 1170" to X/Open for fasttrack. In December Novell ships SVR4.2MP , the final USL OEM release of System V 1994 Single UNIX Specification BSD 4.4-Lite eliminated all code claimed to infringe on USL/Novell. As the new owner of the UNIX trademark, X/Open introduces the Single UNIX Specification (formerly Spec 1170), separating the UNIX trademark from any actual code stream. 1995 UNIX 95 X/Open introduces the UNIX 95 branding programme for implementations of the Single UNIX Specification. Novell sells UnixWare business line to SCO. Digital UNIX introduced. UnixWare 2.0 ships. OpenServer 5.0 debuts. 1996 The Open Group forms as a merger of OSF and X/Open. 1997 Single UNIX Specification, Version 2 The Open Group introduces Version 2 of the Single UNIX Specification, including support for realtime, threads and 64-bit and larger processors. The specification is made freely available on the web. IRIX 6.4, AIX 4.3 and HP-UX 11 ship. 1998 UNIX 98 The Open Group introduces the UNIX 98 family of brands, including Base, Workstation and Server. First UNIX 98 registered products shipped by Sun, IBM and NCR. The Open Source movement starts to take off with
  • 10. Unix The OperatingSystem UNIX (THE OS) Page 10 announcements from Netscape and IBM. UnixWare 7 and IRIX 6.5 ship. 1999 UNIX at 30 The UNIX system reaches its 30th anniversary. Linux 2.2 kernel released. The Open Group and the IEEE commence joint development of a revision to POSIX and the Single UNIX Specification. First LinuxWorld conferences. Dot com fever on the stock markets. Tru64 UNIX ships. 2001 Single UNIX Specification, Version 3 Version 3 of the Single UNIX Specification unites IEEE POSIX, The Open Group and the industry efforts. Linux 2.4 kernel released. IT stocks face a hard time at the markets. The value of procurements for the UNIX brand exceeds $25 billion. AIX 5L ships. 2003 ISO/IEC 9945:2003 The core volumes of Version 3 of the Single UNIX Specification are approved as an international standard. The "Westwood" test suite ship for the UNIX 03 brand. Solaris 9.0 E ships. Linux 2.6 kernel released. 2007 Apple Mac OS X certified to UNIX 03. 2008 ISO/IEC 9945:2008 Latest revision of the UNIX API set formally standardized at ISO/IEC, IEEE and The Open Group. Adds further APIs 2009 UNIX at 40 IDC on UNIX market -- says UNIX $69 billion in 2008, predicts UNIX $74 billion in 2013 2010 UNIX on the Desktop Apple reports 50 million desktops and growing -- these are Certified UNIX systems.
  • 11. Unix The OperatingSystem UNIX (THE OS) Page 11 Starting Out Of UNIX You can access a UNIX system in one of two general ways: either locally (that is, while sitting at the computer you are connected to), or remotely (by connecting to the computer over a network). Most of what you will learn in this book applies equally well to either case. In particular, the basic UNIX commands will work in exactly the same way Before you can start using those commands, however, you will need to know how to access your UNIX system. Connecting Locally:- To connect to a UNIX machine locally, you need to be physically at the computer. If that computer is a UNIX workstation, all you need to do is log in with your username and password. If you are using Mac OS X, you just need to run the Terminal application, available under Applications | Utilities, in order to access the UNIX command line that is built in to the operating system. Connecting Remotely:- When you connect to a UNIX system remotely, you are using your computer to access another system that is running UNIX. Typically, this system supports many users at once. For example, many large universities offer a UNIX account to all their students. The students log in to the system from their own computers, either through the Internet or over the university network. In order to connect to a UNIX system like this, you will need Internet access from your own computer. (In some cases, you may be able to dial in directly to the UNIX system, but the details for how to do this depend on the specific system configuration.) You will also need a terminal emulator application.
  • 12. Unix The OperatingSystem UNIX (THE OS) Page 12 Logging in Once you have access to your UNIX system, you will need to log in with your username and password. The UNIX operating system was designed for multiple users. Requiring each user to log in ensures that the system remains secure, and that each user’s files remain private. Selecting a Login Name:- Every UNIX system has at least one person, called the system administrator, whose job is to maintain the system. In general, your login name can be almost any combination of letters and numbers, although there are a few constraints:  Your login name must be more than two characters long. If it is longer than eight, only the first eight characters are relevant.  It must contain only lowercase letters and numbers and must begin with a lowercase letter. No symbols or spaces are allowed.  It cannot be the same as another login name already in use. Some login names are customarily reserved for certain uses; for example, root is often a login name for the system administrator (sometimes called the superuser). it is important to choose something that won’t become embarrassing or confusing later. In some cases the system administrator may select a login name for you.
  • 13. Unix The OperatingSystem UNIX (THE OS) Page 13 Choosing a Password:- If you begin by installing a UNIX variant on your own system, it will ask you to choose a password when you select a login name. If your account is on a remote system, your system administrator will probably assign you a temporary password, which you should change the first time you log in. UNIX places some requirements on passwords, typically including the following:  Passwords must have at least six characters.  Passwords must contain at least two alphabetic characters (uppercase or lowercase letters), and at least one number or symbol. Note that UNIX is sensitive to case, so WIZARD is a different password than w1zard..  Your login name with its letters reversed or shifted cannot be used as a password. For example, if your login name is msilver, you cannot choose silverm or revlism as a password. Entering Commands The UNIX System makes hundreds of programs available to the user. To run one of these programs you issue a command. When you type date, for example, you are really instructing the UNIX System command interpreter to execute a program with the name date, and to display the results on your screen. The most commonly used commands, however, are typically constant across versions. Command Options and Arguments:- The UNIX System has a standardized command syntax that applies to almost all commands. Understanding these patterns makes it easier to learn new UNIX commands. Some commands are used alone, some require arguments that describe what the command is to operate on, and some provide options that let you specify certain choices. Here is an example of each type of command.
  • 14. Unix The OperatingSystem UNIX (THE OS) Page 14 The date command is usually used alone: $ date Fri Apr 27 22:14:05 EDT 2007 As you can see, entering the command date prints the current day and time. Many commands take arguments (typically filenames) that specify what the command operates on. For example, to view a file, you can type $ cat notes This tells the cat command to display the file notes. Commands often allow you to specify options that influence the operation of the command. You specify options for UNIX System commands by using a minus sign followed by a letter or word. For example, the command ls by itself lists all the files in a directory If you enter $ ls -l the -l option says to print a long version of the list with details about each file. Stopping a Command:- You can stop a command by hitting CTRL-C. The UNIX System will halt the command and return to the system prompt. You can do this either while typing or after running a command. For example, you could use CTRL-C if you were in the middle of entering a command and realized that it was misspelled. Or you could use it to cancel ls if it were taking too long to list the contents of a very large directory CTRL-C is an example of a control character.
  • 15. Unix The OperatingSystem UNIX (THE OS) Page 15 The passwd Command:- On some UNIX systems, you are forced to change your password after a certain length of time (determined by the system administrator) for security reasons. Even if your system doesn’t enforce this, you should remember to change it periodically You can do this with the passwd command. When you issue the command, it asks for your current password, and a new password, and then requires you to retype the new password to confirm it. $ passwd passwd: changing password for corwin Old password: New password: Re-enter new password: $ The cal command:- The cal command prints a calendar for any month or year. If you do not give it an argument, it prints the current month. For example, on March 27, 2007, you would get the following: $ cal March 2007 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 If you give cal a single number, it is treated as a year, and cal prints the calendar for that year. So, for example, cal 2007 will display a calendar for all of 2007. If you want to print a specific month other than the current month, enter the month number first, then the year. To get the calendar for April 2008, use the following command: $ cal 4 2008
  • 16. Unix The OperatingSystem UNIX (THE OS) Page 16 The who Command:- On a multiuser system among friends or coworkers, you may wonder who else is currently logged in. The UNIX System provides a standard command for getting this information: $ who dbp pts/10 Apr 2 09 52 etch pts/15 Apr 2 16 13 a-liu pts/16 Mar 29 23 21 corwin pts/18 Apr 2 06 33 raf pts/27 Apr 1 22 04 smullyan pts/31 Apr 2 16 48 For each user who is currently logged into this system, the who command provides one line of output. The finger Command:- The finger command provides you with more complete information about other users on the system. The command: $ finger corwin will print out information about the user corwin. For example, Login name: corwin Name: Eric Kruger Directory:/home/corwin Shell:/usr/bin/bash Last login Sun Aug 28 20:13:05 on pts/17 Project: Currently, I'm writing up my summer research project. The write Command:- The write command copies the text you type to the screen of another user who is logged in. If your login name is raf, the command: $ write corwin Hey, are you busy? CTRL-D will display the following message on corwin’s screen Message from raf Hey, are you busy? EOF
  • 17. Unix The OperatingSystem UNIX (THE OS) Page 17 The talk Command:- A problem with write is that your messages can overlap each other, which is awkward to read. The talk command is an enhanced communication program. If your login name is raf, and you type. $ talk corwin the talk command notifies corwin that you wish to speak with him and asks him to approve. Corwin sees the following on his screen: Message from Talk_Daemon@amber at 20:15 ... talk: connection requested by raf@amber talk: respond with: talk raf@amber The mesg Command :- Both the write and talk commands allow someone to type a message that will be displayed on your screen. You may find it disconcerting to have messages appear unexpectedly while you are working. In order to control this, the UNIX System provides the mesg command, which allows you to accept or refuse messages sent via write and talk. Type $ mesg n to prohibit programs run by other people from writing to your screen. Anyone who tries to write you get the error message Permission denied Typing mesg n after someone has sent you a message will stop the conversation. The sender will see the message “Can no longer write to user.” The command $ mesg y Getting Command Details:- It can be hard to remember all the commands and how to use them. The UNIX operating system comes with a built-in manual so that you can look up the details for how to use each command. To view
  • 18. Unix The OperatingSystem UNIX (THE OS) Page 18 the manual page for a command, just type man followed by the command name. For example, $ man ls will display the man page for ls. In addition, many commands have some amount of built-in help. For example, ls --help will display a shorter version of the man page. Logging Out When you finish your work session and wish to leave the UNIX system, type exit (or CTRL-D) to log out. After a few seconds, your UNIX system will display the “login:” prompt: $ exit login: This shows that you have logged out, and that the system is ready for another user to log in using your terminal. Always log out when you finish your work session or when leaving your computer. An unattended session allows a passing stranger to access your work and possibly the work of others. If you have a single-user system, it is important to remember that logging out is not the same as turning off your computer. To avoid problems, run the shutdown command (or on some systems, poweroff) before logging out in order to make it safe to turn off the machine. If you just turn the computer off without running shutdown, you run a real risk of damaging files or loosing data.
  • 19. Unix The OperatingSystem UNIX (THE OS) Page 19 Command Summary :- Command Use passwd Change your password date Get the current date and time cal Display a calendar who List all users who are currently logged in finger username Get information about username write username Send a chat message to username talk username Open a chat session with username mesg y mesg n Accept or block incoming messages man command Get information about command mailx mailx address Read e-mail messages, or send an e-mail to address exit Log out of the system shutdown poweroff Turn off the machine Working with Files and Directories The UNIX file system provides a powerful and flexible way to organize and manage your information. the commands that provide the basic file manipulation operations- viewing files, changing directories, deleting and moving files-are among the UNIX commands you will use most often. Files:- A file is the basic structure that stores information on the UNIX System (and on Windows systems, as well). Conceptually, a computer file is similar to a paper document. Technically a file is a sequence of bytes that is stored somewhere on a storage device, such as a hard drive. A file can contain any kind of information that can be represented as a sequence of bytes. Word processing documents, bitmap images, and computer programs are all examples of files.
  • 20. Unix The OperatingSystem UNIX (THE OS) Page 20 Filenames:- Every file has a title, called a filename. A filename can be almost any sequence of characters, and up to 255 characters long. (On some older versions of UNIX, two filenames are considered the same if the first 14 characters are identical, so be careful if you use long filenames on these systems.) You can use any ASCII character in a filename except for the null character (ASCII NUL) or the slash (/), which has a special meaning in the UNIX file system. The slash acts as a separator between directories and files. Many of these characters have special meanings in the command shell, which makes them difficult to work with in filenames ! (exclamation point) * (asterisk) {,} (brackets) # (pound sign) ? (question mark) ; (semicolon) & (ampersand) (backslash) ^ (caret) | (pipe) (,) (parentheses) Tab @ (at sign) ‘,” (single or double quotes) Space $ (dollar sign) < , > (left or right arrow) Backspace Capitalization Windows does not distinguish between uppercase and lowercase letters in filenames. You could save a file with the name Notes.DOC and find it by searching for notes.doc. The UNIX file system, however, is case-sensitive, meaning that uppercase and lowercase letters are distinct. In UNIX, NOTES, Notes, and notes would be three different files. If you save a file with the name Music, you will not find it by searching for music. This also applies to commands in UNIX. If you are trying to log out with the exit command, typing EXIT will not work. By the way, this explains
  • 21. Unix The OperatingSystem UNIX (THE OS) Page 21 why URLs (web addresses) can be case-sensitive, since the first web server was created on a UNIX-based platform, and many web servers still run UNIX. Filename Extensions:- In Windows, filenames typically consist of a basename, followed by a period and a short filename extension. Many Windows programs depend on the extension to determine how to use the file. For example, a file named solitaire.exe is considered to be a file named solitaire with the extension .exe, where the .exe extension tells Windows that it is an executable program. If the file extension is altered or deleted, it will be more difficult to work with the file in Windows. Some programs either produce or expect a file with a particular filename extension. For example, files that contain C source code have the extension .c, so sorting.c would be a C language file. Similarly, web browsers expect that HTML files will have the extension .html, such as index.html. Common File Extensions :- Table:- Common File Extensions C File Type Extension File Type .au Audio .mpg, .mpeg MPEG video .c C language source code .o Object file (compiled and assembled code) .cc C++ source code .pl Perl script .class Compiled Java file .ps PostScript file .conf Configuration file .py Python script .d Directory .sh Bourne shell script .gif GIF image .tar tar archive .gz Compressed with gzip .tar.Z, .tar.gz Files that have been archived with tar and then compressed .h Header file for a C program .tex Text formatted with Tex/LaTeX .html Webpage .txt ASCII text .jar Java archive .uu, .uue Uuencoded file .java Java source code .wav Wave audio .jpg, .jpeg JPEG image .z Compressed with pack
  • 22. Unix The OperatingSystem UNIX (THE OS) Page 22 Table:- Common File Extensions C File Type Extension File Type .log Log file .Z Compressed with compress UNIX files can have more than one extension. For example, the file book.tar.Z is a file that has first been archived using the tar command (which adds the extension .tar) and then compressed using the compress command (which adds the .Z). This enables a single script to both decompress the file and untar it, using the filename as input and parsing each of the extensions to perform the appropriate task. . Directories Files contain the information you work with. Directories provide a way to organize your files. A directory is just a container for as many files as you care to put in it. If you think of a file as analogous to a document in your office, then a directory is like a file folder. In fact, directories in UNIX are exactly like folders in Windows. For example, you may decide to create a directory to hold all of your notes. You could name it Notes and use it to hold only files that are your notes, keeping them separated from your e-mail, programs, and other files. Subdirectories:- A directory can also contain other directories. A directory inside another directory is called a subdirectory. You can create as many subdirectories inside a particular directory as you wish. Choosing Directory Names:- It is a good idea to adopt a convention for naming directories so that they can be easily distinguished from ordinary files. Some people give directories names that are all uppercase letters, some use directory names that begin with an uppercase letter, and others distinguish directories using the extension .d or .dir. For example, if you decide to use names beginning with an
  • 23. Unix The OperatingSystem UNIX (THE OS) Page 23 uppercase letter for directories and avoid naming ordinary files this way, you will know that Notes, Misc, Multimedia, and Programs are all directories. The Hierarchical File Structure:- Because directories can contain other directories, which can in turn contain other directories, the UNIX file system is called a hierarchical file system. Within the UNIX System, there is no limit to the number of files and directories you can create in a directory that you own. Pathnames:- the UNIX System allows you to specify filenames by including the location of the file in the directory tree. This type of name is called a pathname, because it is a listing of the directories you travel through along the path you take to get to the file. The path through the file system starts at root (/), and the names of directories and files in a pathname are separated by slashes. For example, the pathname for one of the save files is /home/raf/Email/save and the pathname for the other is /home/raf/Work/save Relative Pathnames:-You do not always have to specify the full pathnames when you refer to files. As a convenient shorthand, you can also specify a path to a file relative to your present directory Such a pathname is called a relative pathname. Instead of starting with a / for root, the relative pathname starts with the name of a
  • 24. Unix The OperatingSystem UNIX (THE OS) Page 24 subdirectory For example, suppose you are in your home directory, /home/raf. The relative path for the save file in the Email subdirectory is Email/save, and the relative path for the other save file is Work/save. Specifying the Current Directory:- A single dot (.) is used as a shortcut to refer to the directory you are currently in. This directory is known as the current directory. Specifying the Parent Directory:- Two dots (.., pronounced “dot-dot”) refer to the parent directory of the one you are currently in. The parent directory is the one at the next higher level in the directory tree. Because the file system is hierarchical, all directories have a parent directory The dot-dot references can be used many times to refer to things far up in the file system. The following sequence, for example, ../.. refers to the parent of the parent of the current directory. If you are in Work, then ../.. is the same thing as the home directory, since home is the parent of raf, which is the parent of Work. Specifying a Home Directory:- A tilde (~) can be used to refer to your home directory (Strictly speaking, this is a feature of the shell, which will be discussed in the next chapter. It will work on most modern UNIX systems.) These shortcuts can be combined. For example, if your home directory is /home/raf, then ~/../liz refers to the home directory for the user liz.
  • 25. Unix The OperatingSystem UNIX (THE OS) Page 25 Configuring the Shell When your login shell starts up, it looks for certain files in your home directory. These files contain commands that can be used to configure your working environment. The particular files it looks for depend on which shell you are using:  sh runs the commands in a configuration file called .profile.  ksh also uses the .profile file. In addition, you can set a variable in your .profile to cause it to read the commands in a second file. The variable is called ENV. By convention, that file is often called .kshrc.  bash uses the file .bash_profile. If that file does not exist, it will look for the file .profile, instead. The .bash_profile often contains a line that causes bash to run the commands in a second file, bashrc. When you log out of bash, it will run the commands in .bash_logout.  csh looks for a file called .login. It will also run commands in .cshrc. When you log out of the C shell, it will run the commands in the file .logout.  tcsh uses the .login file as well. It also looks for .tshrc. If that file does not exist, it will look for .cshrc instead. Like the C shell, tcsh will run the .logout file when you log out. This may all sound very confusing, but these configuration files all work in pretty much the same way Each of these files is actually an example of a shell script. They contain commands or instructions for the shell. The commands include settings that allow you to customize your environment. The first file that the shell reads (.profile, .bash_profile, or .login) contains variables or settings that you want to be in effect throughout your login session. The section “Shell Variables” later in this chapter describes these variables. The file might also include commands you want to run at login, such as cal (to display a calendar for the current month) or who (to show the list of users who are currently logged in).
  • 26. Unix The OperatingSystem UNIX (THE OS) Page 26 Interactive Shells:- You can start another shell after you log in by using the name of the shell as a command; for example, to start the Korn shell, you could type ksh at the command prompt. This type of shell is not a login shell, and you do not have to log in again to use it, but it is still an interactive shell, meaning that you interact with the shell by typing in commands The instances of the shell that run in a terminal window when you are using a graphical interface are also interactive non- login shells. When you start a non-login shell, it does not read your .profile, .bash_profile, or .login file (or your .logout file), but it will still read the second shell configuration file (such as .bashrc). Sample Configuration Files:- If you define a variable by typing its new value on the command line, it will return to its previous value the next time you log in. In order to keep important variables such as PATH, PS1, and TERM defined every time you log in, they are usually included in one of your configuration files. Here are a few examples of those files. Don’t worry if the commands don’t make sense yet- you can come back to this later, after reading the sections “Shell Variables” and “Command Aliases.” Sample.bash profile:- Every time you log in, bash reads your .bash_profile. This file includes definitions of environment variables that will be shared with other programs and commands such as who that you want to run at the beginning of each login session. A typical .bash_profile might look some-thing like this: # .bash_profile - example # set environment variables export TERM=vt100 export PATH=$PATH:/sbin:/usr/sbin:$HOME/bin export MAILCHECK=30 # allow incoming messages from other users mesg y
  • 27. Unix The OperatingSystem UNIX (THE OS) Page 27 # make sure backspace works stty erase "^H" # show all users who are currently logged in who # load aliases and local variables . -/.bashrc The last line executes your .bashrc file. If you leave it out, bash will not read your aliases and variable definitions when you log in. Sample .bashrc File:- when you start an interactive bash shell after logging in (e.g., by opening an xterm window), it reads the commands in your .bashrc file. This file includes commands and definitions that you want to have executed every time you run a shell-not just at login. The .bashrc file defines local shell variables (but not environment variables, which belong in .bash_profile), shell options, and command aliases. It might look something like this: # .bashrc file-example # set shell variables (such as the prompt) PS1="u w> " # set shell options set −o noclobber set −o emacs set +o notify # set default file permissions umask 027 # define aliases
  • 28. Unix The OperatingSystem UNIX (THE OS) Page 28 alias lg='ls -g -color=tty' alias r='fc -s' alias rm='rm -i' alias cp='cp -r' alias wg='who | grep' alias hibernate='sudo apm -s' A configuration file for ksh could look like this, as well. However, the line PS1=“u w>” in this example would have to be changed to PS1=‘$LOGNAME $(pwd)> ’, because ksh doesn’t support the bash shortcuts for defining the prompt. Sample .login File:-As the name suggests, tcsh reads the .login file only when you log in. Your .login file should contain commands and variable definitions that only need to be executed at the beginning of your session. Examples of things you would put in .login are commands for initializing your terminal settings, commands such as date that you want to run at the beginning of each login session, and definitions of environment variables. The following is a short example of what you might put in a typical .login file: # .login file-example # show number of users on system echo "There are" who wc -l "users on the system" # set terminal options-- in particular, # make sure that the Backspace key works stty erase "^H" # set environment variables setenv term vt100 setenv mail ( 60 /var/spool/mail/$user)
  • 29. Unix The OperatingSystem UNIX (THE OS) Page 29 These examples illustrate the use of setenv, the C shell command for defining environment variables. setenv and its use are discussed further later on, in the section “csh and tcsh Variables.” Sample .tcshrc File:- The difference between .tcshrc and .login is that tcsh reads .login only at login, but it reads .tcshrc both when it is being started up as a login shell and when it is invoked as an interactive non-shell. The .tcshrc file includes commands and definitions that you want to have executed every time you run a shell-not just at login. Your .tcshrc should include your alias definitions, and definitions of variables that are used by the shell but are not environment variables. Environment variables should be defined in .login. # .tcshrc file-example # set shell variables set path = ($path /sbin /usr/sbin /usr/bin /$home/bin) set prompt = "[%n@%m %c] tcsh % " # turn on ignoreeof and noclobber # turn off notify set ignoreeof set noclobber unset notify # define aliases alias lsc ls -Ct alias wg 'who | grep' alias rm rm -i alias cp cp -r alias hibernate sudo apm -s # set permissions for file creation
  • 30. Unix The OperatingSystem UNIX (THE OS) Page 30 umask 027 This sample file includes C shell variable definitions and aliases, both of which are explained in the following sections. Shell Variables The shell provides a mechanism to define variables that can be used to hold pieces of information. Shell variables can be used to customize the way in which programs (including the shell itself) interact with you. This section will describe some of the standard variables used by the shell and other programs, and explain what they do for you. Assigning Variables and Aliases :- Table: Assigning Variables and Aliases sh, ksh, or bash csh or tcsh Effect VAR=value set var=value Assign a value to a variable $VAR $var Get the value of a variable set set List shell variables unset VAR unset var Remove a variable env env List all environment variables VAR=value; export VAR export VAR=value setenv var value Create an environment variable unset VAR unsetenv var Remove an environment variable set -o View shell options set -o option set option Turn on a shell option set +o option unset option Turn off an option alias name=value alias name value Create a command alias unalias name unalias name Remove an alias
  • 31. Unix The OperatingSystem UNIX (THE OS) Page 31 Variables in sh, ksh, and bash:- You define a shell variable by typing a name followed by an=sign and a value. For example, you could create a variable called PROJDIR to save the pathname for a directory you use often: $ PROJDIR=/home/nate/Work/cs106x/Proj_3/lib/Source To assign a value with a space in it, use quotes, like this: $ FILELIST='graphics.c strings.c sorting.c' In the Bourne-compatible shells, variable names are conventionally written in uppercase letters, although you can use lowercase names as well. As with filenames, variable names are case-sensitive, so the shell will treat PROJDIR and projdir as two different variables. To get the value of a shell variable, precede the variable name with a dollar sign, $. You can print a variable with the echo command, which copies its standard input to its standard output. $ echo $PROJDIR /home/nate/Work/cs106x/Proj ect_3/lib/Source Environment Variables in sh, ksh, and bash:- When you run a command, the shell makes certain shell variables and their values available to the program. The program can then use this information to customize its actions. The collection of variables and values provided to programs is called the environment. Your environment includes variables set by the system, such as HOME, LOGNAME, and PATH (described in the next section). You can display your environment variables with the command env: $ env HOSTNAME=localhost.localdomain SHELL=/bin/bash
  • 32. Unix The OperatingSystem UNIX (THE OS) Page 32 MAIL=/var/spool/mail/raf PATH=/usr/local/bin:/bin:/usr/bin:/home/raf/bin PWD=/home/raf/Proj ect PS1='$ ' HOME=/home/raf LOGNAME=raf To make variables that you define yourself available to commands as part of the environment Common Shell Variables in sh, ksh, and bash:- The following is a short summary of some of the most common shell variables, including those set automatically by the system.  HOME contains the absolute pathname of your login directory HOME is automatically defined and set to your login directory as part of the login process. The shell itself uses this information to determine the directory to change to when you type cd with no argument.  LOGNAME contains your login name. It is set automatically by the system.  PWD is a special variable that gets set automatically to your present working directory You can use this variable to include your current directory in the prompt or in a command line.  PATH lists the directories in which the shell searches to find the program to run when you type a command. A default PATH is set by the system, but many users modify it to add additional command directories. A typical example of a customized PATH, in this case for user anita, is the following: PATH=$PATH:/sbin:/usr/bin:/home/anita/bin Shell Options in ksh and bash:- The Korn shell and bash provide a number of options that turn on special features. To turn on an option, use the set command with -o (option) followed by the option name. To view your current option settings, use set -o by itself.
  • 33. Unix The OperatingSystem UNIX (THE OS) Page 33 The noclobber option prevents you from overwriting an existing file when you redirect output from a command. This can save you from losing data that may be difficult or impossible to replace. You can turn on noclobber with set: $ set -o noclobber Suppose noclobber is set, and your current directory contains a file named temp. If you try to redirect the output of a command to temp, you get a warning: $ ls -1 > temp temp: file exists You can tell the shell that you really do want to overwrite the file by putting a bar (pipe symbol) after the redirection symbol, like this: $ ls -1 >| temp To turn off an option, use set +o, as in $ set +o noclobber The ignoreeof feature prevents you from accidentally logging yourself off by typing CTRL-D. If you use this option, you must type exit to terminate the shell. s