Você está na página 1de 94

LAB MANUAL

Department: Computer Science and Engineering

Subject: System Programming

Subject Code: BTCS-40

Semester: 4th
LAB MANUAL
Department: Computer Science and Engineering

Subject: Operating System

Subject Code: BTCS-406

Semester: 4th
Syllabus

1. Installation Process of various operating systems

2. Virtualization, Installation of Virtual Machine Software and


installation of Operating System on Virtual Machine

3. Commands for files & directories: cd, ls, cp, md, rm, mkdir, rmdir.
Creating and viewing files using cat. File comparisons. Disk related
commands: checking disk free spaces. Processes in linux, connecting
processes with pipes, background processing, managing multiple
processes. Manual help. Background process: changing process
priority, scheduling of processes at command, batch commands, kill,
ps, who, sleep. Printing commands, grep, fgrep, find, sort, cal, banner,
touch, file. File related commands ws, sat, cut, grep.

4. Shell Programming: Basic of shell programming, various types of shell,


Shell Programming in bash, conditional & looping statement, case
statements, parameter passing and arguments, shell variables, shell
keywords, creating shell programs for automate system tasks, report
printing.
List of Practical

Sr. No. Topic

1. Introduction to Operating System

2. Installation Process of various operating systems

3. Commands for files & directories

4. Disk related commands: checking disk free spaces

5. Process in Linux: Connecting Processes with Pipes

6. Linux / Unix Commands

7. Shell Programming

8. Creating shell programs for automate system tasks

9. Write a shell script to find the greatest among the 3


given numbers
10. Write a shell script to find the smallest among the 3
given numbers
11. *Introduction to Unix
*Learning Beyond Syllabus Introduction to Unit
Experiment 1

AIM : Introduction to Operating System


An operating system (OS) is a collection of software that manages computer
hardware resources and provides common services for computer programs.
The operating system is an essential component of the system software in a
computer system. Application programs usually require an operating system
to function.

Types of operating systems:-


Real-time
Multi-user
Multi-tasking vs. single-tasking
Distributed
Embedded

Real-time
A real-time operating system is a multitasking operating system that aims at
executing real-time applications. Real-time operating systems often use
specialized scheduling algorithms so that they can achieve a deterministic
nature of behavior. The main objective of real-time operating systems is their
quick and predictable response to events. They have an event-driven or time-
sharing design and often aspects of both. An event-driven system switches
between tasks based on their priorities or external events while time-sharing
operating systems switch tasks based on clock interrupts.

Multi-user
A multi-user operating system allows multiple users to access a computer
system at the same time. Time-sharing systems and Internet servers can be
classified as multi-user systems as they enable multiple-user access to a
computer through the sharing of time. Single-user operating systems have
only one user but may allow multiple programs to run at the same time.
Multi-tasking vs. single-tasking
A multi-tasking operating system allows more than one program to be running at the
same time, from the point of view of human time scales. A single-tasking system
has only one running program. Multi-tasking can be of two types: pre-emptive and
co-operative. In pre-emptive multitasking, the operating system slices the CPU time
and dedicates one slot to each of the programs. Unix-like operating systems such as
Solaris and Linux support pre-emptive multitasking, as does AmigaOS. Cooperative
multitasking is achieved by relying on each process to give time to the other
processes in a defined manner. 16-bit versions of Microsoft Windows used
cooperative multi-tasking. 32-bit versions of both Windows NT and Win9x, used
pre-emptive multi-tasking. Mac OS prior to OS X used to support cooperative
multitasking.

Distributed
A distributed operating system manages a group of independent computers and
makes them appear to be a single computer. The development of networked
computers that could be linked and communicate with each other gave rise to
distributed computing. Distributed computations are carried out on more than one
machine. When computers in a group work in cooperation, they make a distributed
system.

Embedded
Embedded operating systems are designed to be used in embedded computer
systems. They are designed to operate on small machines like PDAs with less
autonomy. They are able to operate with a limited number of resources. They are
very compact and extremely efficient by design. Windows CE and Minix 3 are some
examples of embedded operating systems.

Functions of an operating system


The basic functions of an operating system are:
Process Management
The process management activities handled by the OS are—
1. control access to shared resources like file, memory, I/O and CPU,
2. control execution of applications,
3. create, execute and delete a process (system process or user process),
4. cancel or resume a process
5. schedule a process, and

6. synchronization, communication and deadlock handling for processes.

Memory Management
The activities of memory management handled by OS are—
(1) allocate memory,
(2 ) free memory,
(3) re-allocate memory to a program when a used block is freed, and
(4) keep track of memory usage.
Device Management
The device management tasks handled by OS are
(1) open, close and write device drivers, and
(2) communicate, control and monitor the device driver.

Protection and Security


OS protects the resources of system. User authentication, file attributes like read,
write, encryption, and back-up of data are used by OS to provide basic protection.

User Interface or Command Interprete


Operating system provides an interface between the computer user and the computer
hardware. The user interface is a set of commands or a graphical user interface via
which the user interacts with the applications and the hardware.
Experiment 2

AIM : Installation Process of various operating systems


Installing Windows XP –

1. Getting your hardware 'up to date'.

Like Windows 2000, XP makes extensive use of the Microsoft ACPI


(Advanced Configuration & Power Interface), which relies heavily on
your system BIOS (Basic Input / Output System). Many slightly older
systems may not be set up to take advantage of ACPI functionality, so
it's worth checking with your motherboard and/or peripheral vendor to
see if an ACPI compliant BIOS upgrade exists for your hardware.

2. Starting the install in text


mode.
Starting an XP install is relatively simple. The CD-Rom containing the
installation files is self booting, and provided you have set your boot
priority in the BIOS to attempt boot from CD-Rom first, you should be
up and running within a few seconds! If your hard disk contains a
previous OS, such as Windows 98, you will be given the opportunity to
either boot from the CD, or from your hard disk. If not, the XP installer
goes directly to this screen first :
Hit F6 when you see this screen :
Next, the XP installer will load a series of generic drivers for such devices as SCSI
& IDE controllers. At this point, XP is simply trying out drivers to see what it can
find and work with :
This part of the process can take several minutes, during which time, your CD-Rom
drive will be exceptionally busy, as the XP installer tries out several hundred
different driver files. Once this hardware discovery process has finished, you will be
given several options :
Provided you are happy to continue, simply hitting your <enter> or <return> key
will take you on to the next screen, which contains the Microsoft licence agreement.
If you are willing to accept it, press the F8 key to continue.
The next screen we encounter, allows us to add or remove partitions, and decide
where XP is going to 'live' :

3. Creating custom partitions using the XP installer.


In the following example, we are going to split the new 10gb hard disk into 2 separate
but equal sized partitions, which will ultimately become our C: & D: drives.
Having pressed <C> to specify custom partitions, we are presented with the
following screen :
5. Copying Files.
Once the installer has formatted the C: partition or drive, it will begin
to copy all the files which XP needs onto the hard disk :
7. Getting Interactive
Once hardware detection is complete, it's time for you to set up your personal
preferences. First on the list is establishing your location and input language :
7. Finishing Off
Once you have completed the interactive steps, the installer will copy the
files necessary for configuring your networking:
Installation of Linux
Step 1 – Insert the Red Hat Linux DVD into the DVD-drive of your computer. As
soon as the following screen pops up, press ‗Enter‘ to install Red Hat Enterprise
Linux (RHEL) through GUI mode.
Step 2- RHEL installer would then prompt you conduct a check as to

whether the CD media from which you’re installing is functioning


correctly or not. Choose ‘Skip’, press enter and the installation would
begin.
Step 3- Next, we need to select the language- English or any other language as per
your preference, and then press ‗Next‘ .
Step 4- In this step, the RHEL installer would ask you about the appropriate type
of keyboard for the system. We take the ‗US English‘ keyboard, you can pick any
other option depending on the type of your keyboard. Then press ‗Next‘ to move to
the next step.
Step 5- Next, the installer would ask for an ‗installation number‘ if you wish to
install full set of Red Hat functionalities. Enter the installation number and press
‗OK‘ if you have an officially licensed installation number(for corporate clients that
buy Red Hat‘s backup support and full features).

Others can select ‗Skip entering installation number‘ and press ‗OK‘ to proceed.
RHEL would show a warning message, press ‗Skip‘ in it to continue.
Step 6- The Red Hat installer would then require you to create partitions in your
computer‘s hard disk for the installation. You can do it in four ways but the simplest
way is to select ‗Use free space on selected drives and create default layout‘ as this
option will not affect any other OS residing in your system.
Check the ‗review and modify portioning layout‘ to create partitions and click next.

Step 7- In this step you must create the required system partitions and mount points
such as ‗/boot‘, ‗/home‘, ‗swap‘ etc which are required for the Linux‘s proper
functioning.

To create different partitions such as /home, /var etc, click on ‗New‘ to create the
partitions.
Then, select /home in the mount point and choose ‗ext3‘ as the file system and give
the desired size for it and then click ‗OK‘. Similarly also create /boot and /var.
Also, create a swap partition by clicking on ‗New‘ and then choosing the filesystem
as ‗swap‘ and also give the size of Swap partition.(Usually size of swap partition
SHOULD BE twice the size of RAM available to the system but you can keep its
size less than that too)
Once you have made all the desired partitions and given their mount points,
click ‗Next‘ to continue installation.

Step 8- This step pertains to the default OS that will be loaded by the
GRUB loader
(Note- If you have multiple Operating Systems installed, you would see multiple
options here and you have to check in front of the OS name that you want to be
loaded by default when the system is started.)
Click ‗Next‘ to continue.
Step 9- This step pertains to the network settings of the Linux system that you are
going to install. You can select the Ethernet devices through which the system would
communicate with other devices in the network.
You can also provide the hostname, Gateway address and DNS address to the system
during this step. (However it‘s better to adjust these settings once the system has
been fully installed).

Step 10- The next step is to adjust the system clock to your particular time zone.
Select your time zone and then click ‗Next‘.
Step 11 – This is a very important step that deals with the root(super-user)
password for the system . Type the password and confirm it and then click next.

Step 12 – The RHEL installer would then prompt you about if you wish to install
some extra ‗Software Development‘ or ‗Web Server‘ features. By default, keep
it at ‗Customize later‘ and press ‗Next‘.
Step 13- This next step will initiate the installation of Red Hat Linux, press
‗Next‘ to begin the process.

Step 14- Upon the completion of installation you should the following screen.
Press Reboot and you‘d be ready to use your newly installed Red Hat Linux OS.
Experiment 3

AIM : Commands for files & directories

MS DOS Internal Commands:-


An internal command is a MS-DOS command that is stored in the system
memory and loaded from the command.com.

List of Internal Commands


CD (Change Directory) is a command used to switch directories in MS-
DOS and the Windows command line.

Syntax:
CD [/D] [drive:][path]
Cls is a command that allows a user to clear the complete contents of the
screen and leave only a prompt.

Syntax:
CLS
Copy Command Allows the user to copy one or more files to an
alternate location.
Syntax:
COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination]
[/A | /B]] [/V] [/Y | /-Y]
The date command can be used to look at the current date of the computer
as well as change the date to an alternate date.
Syntax:
DATE [date]
The dir command allows you to see the available files and directories in the current
directory. In addition to listing the contents of a directory, the dir command will also
show the last modification date and time, as well as the file size.

Mkdir command Allows you to create your own directories in MS-DOS.


Ren and rename command Used to rename files and directories from the
original name to a new name.
Time Command Allows the user to view and edit the computer's time.
Ver command Displays the version of MS-DOS or if running Windows 95 or
above the version of Windows.
Vol command Displays the volume information about the designated drive.
Move command Allows you to move files or directories from one folder
to another, or from one drive to another.
The cat command is used for:
1. Display text file on screen

2. Read text file


3. Create a new text file
4. File concatenation
5. Modifying file

Purpose
Basic file operation on a text file such as displaying or creating new files.

Syntax
The basic syntax is as follows:
cat filename
OR
cat > filename
OR
cat [options] filename
OR
cat file1
cat > file2
cat file3 | command
cat file4 | grep something

Display A File
cat filename
cat /path/to/file
cat /etc/passwd
Experiment 4ent 5
AIM : Disk related Commands: Checking disk free
spaces
Checking Disk capacity, Partition tables, etc.
[root@server ~]# fdisk -l
Get Detailed/current information directly from
hard drive [root@server ~]# hdparm -I /dev/sda
Check available/used/free spaces in each
partitions [root@server ~]# df -h
Check Hard drive speeds
[root@server ~]# hdparm -Tt /dev/sda
To list the partition tables for the specified
devices #fdisk -l
Pass print option to displays the
partition table #parted /dev/sda print
To display all disks and storage controllers in the
system #lshw -class disk -class storage
Find Out Disks Name Only
#lshw -short -C disk
Partition the new disk using fdisk command
#fdisk -l | grep '^Disk'
Format the new disk using mkfs.ext3
command #mkfs.ext3 /dev/sdb1
Mount the new disk using mount command
#mkdir /disk1
#mount /dev/sdb1 /disk1
#df -H
Label the partition
#e2label /dev/sdb1 /backup
Checking the Hard Disk for errors
#fsck.file_system_type, E.g #fsck.ext3
Show list of partitions mounted
# df -h [man]
Experiment 56

AIM : Process in Linux: Connecting Processes with Pipes

Process in Linux:
A process is an instance of a program in execution. A process is composed of
several user threads (or simply threads), each of which represents an execution
flow of the process.
However each lightweight process has an independent execution context and
is treated as an independent process by the Kernel. For a deeper understanding
lets take a look at the way a new process is created in Linux. One can use
either the fork() or the clone() command to create a new process. A fork()
always creates a completely independent process which does not share the
address space of the parent process (though a forked process does start with a
pointer to the same address space and a copy-on-write model is used to
optimize space utilization). A clone() on the other hand allows granular
control over process creation and one can specify whether the child process
should share the address space, open files, signals etc with the parent. A
process created using clone() which shares these attributes with its parents is
known as a light-weight process. In effect therefore in Linux everything is a
process which either shares the resources of its parent OR does not. In fact
fork() is implemented as a wrapper over clone() by setting all flags to share
nothing between the parent and child processes.

Connecting Processes with Pipes


A very useful Linux feature is named pipes which enable different processes
to communicate.
A simple example of using a pipe is the command:
ls | grep x
When bash examines the command line, it finds the vertical bar character |
that separates the two commands. Bash and other shells run both commands,
connecting the output of the first to the input of the second. The ls program
produces a list of files in the current directory, while the grep program reads
the output of ls and prints only those lines containing the letter x.
The other sort of pipe is a ―named‖ pipe, which is sometimes called a FIFO. FIFO
stands for ―First In, First Out‖ and refers to the property that the order of bytes
going in is the same coming out. The ―name‖ of a named pipe is actually a file
name within the file system. Pipes are shown by ls as any other file with a couple of
differences:
% ls -l fifo1
prw-r--r-- 1 andy users 0 Jan 22 23:11 fifo1|

The p in the leftmost column indicates that fifo1 is a pipe. The rest of the permission
bits control who can read or write to the pipe just like a regular file. On systems with
a modern ls, the | character at the end of the file name is another clue, and on Linux
systems with the color option enabled, fifo| is printed in red by default.

Managing multiple processes in Linux


Every running process in Unix has a priority assigned to it.
You can change the process priority using nice and renice utility. Nice command
will launch a process with an user defined scheduling priority. Renice command will
modify the scheduling priority of a running process.
Experiment 6

AIM : Linux / Unix Commands

Linux / Unix Commands


Kill Command: The kill command is used on Linux and other Unix-like
operating systems to terminate processes without having to log out or reboot
(i.e., restart) the computer. Thus, it is particularly important to the stability of
such systems.

A process, also referred to as a task, is an executing (i.e., running) instance of


a program. Each process is automatically assigned a unique process
identification number (PID) when it is created for use by the system to
reference the process.

The syntax for kill is

kill [signal or option] PID(s)

Thus, if it is desired to terminate a process with a PID of 485, the following


will usually be sufficient:

kill 485

ps command: The ps (i.e., process status) command is used to provide


information about the currently running processes, including their process
identification numbers (PIDs).

A process, also referred to as a task, is an executing (i.e., running) instance of


a program. Every process is assigned a unique PID by the system.
The basic syntax of ps is
ps [options]
A common and convenient way of using ps to obtain much more complete
information about the processes currently on the system is to use the
following: ps -aux | less
Who command: Displays who is logged on to the system.
Syntax
who [ OPTION ]... [ FILE ] [ am i ]

Sleep Command: The sleep command is used to delay for a specified


amount of time.

Syntax
sleep NUMBER[SUFFIX]...

grep command:
grep is used to search text for patterns specified by the user. It is one of the most
useful and powerful commands on Linux and other Unix-like operating systems.

grep's basic syntax is

grep [option(s)] pattern [file(s)]

grep can search any number of files simultaneously. Thus, for example, the
following would search the three files file1, file2 and file3 for any line that contains
the string (i.e., sequence of characters) Lin:

grep Lin file1 file2 file3

fgrep Command
Purpose

Searches a file for a literal string.

Syntax

fgrep [ -h] [ -i] [ -s] [ -u] [ -v] [ -w ] [ -x] [ -y ] [ [ -b] [ -n] | [ -c | -l | -q ] ] [ -


pSeparator] {Pattern | -ePattern | -fStringFile} [File...]

Description

The fgrep command searches the input files specified by the File Parameter
(standard input by default) for lines matching a pattern. The fgrep command
searches specifically for Pattern parameters that are fixed strings. The fgrep
command displays the file containing the matched line if you specify more than one
file in the File parameter.
Find Command
The find command is used to locate files on a Unix or Linux system. find will search
any set of directories you specify for files that match the supplied search criteria.
You can search for files by name, owner, group, type, permissions, date, and other
criteria. The search is recursive in that it will search all subdirectories too.
The syntax looks like this:
find where-to-look criteria what-to-do
All arguments to find are optional, and there are defaults for all parts. (This may
depend on which version of find is used. Here we discuss the freely available Gnu
version of find, which is the version available on YborStudent.) For example, where-
to-look defaults to . (that is, the current working directory), criteria defaults to none
(that is, select all files), and what-to-do (known as the find action) defaults to -print
(that is, display the names of found files to standard output). Technically, the criteria
and actions are all known as find primaries.
For example:
find
will display the pathnames of all files in the current directory and all subdirectories.
The commands
find . -print
find -print
find .

Sort command
Sort command is helpful to sort/order lines in text files. You can sort the data in
text file and display the output on the screen, or redirect it to a file. Based on
your requirement, sort provides several command line options for sorting data in
a text file.
Sort Command Syntax:
$ sort [-options]
For example, here is a test file:
$ cat test
zzz
sss
qqq
aaa
BBB
ddd
AAA

Cal command: cal command is used to display the calendar.


SYNTAX:
The Syntax is
cal [options] [month] [year]

Touch command:
The touch command is the easiest way to create new, empty files. It is also
used to change the timestamps (i.e., dates and times of the most recent access
and modification) on existing files and directories.

touch's syntax is

touch [option] file_name(s)

When used without any options, touch creates new files for any file names
that are provided as arguments (i.e., input data) if files with such names do not
already exist. Touch can create any number of files simultaneously.
Thus, for example, the following command would create three new, empty
files named file1, file2 and file3:
touch file1 file2 file3
File command: the file command attempts to classify each filesystem object
(i.e., file, directory or link) that is provided to it as an argument (i.e., input).

A simplified version of file's syntax is file [option(s)] object_name(s


Experiment 7
Experiment 8
AIM : Shell Programming
Shell is a user program or it's environment provided for user interaction.
Shell is an command language interpreter that executes commands read
from the standard input device (keyboard) or from a file.
Shell is not part of system kernel, but uses the system kernel to execute
programs, create files etc.
Several shell available with Linux including:

BASH ( Bourne- Brian Fox and Free Software Most common shell
Again SHell ) Chet Ramey Foundation in Linux. It's
Freeware shell.
CSH (C SHell) Bill Joy University of The C shell's syntax
California (For and usage are very
BSD) similar to
the C programming
language.
KSH (Korn SHell) David Korn AT & T Bell Labs --
TCSH

Conditional and looping statements:


if condition
if condition which is used for decision making in shell script, If given
condition is true then command1 is executed.
Syntax:
if condition
then
command1 if condition is true or if exit status
of condition is 0 (zero)
...
...
Nested if-else-if
You can write the entire if-else construct within either the body of the if
statement of the body of an else statement. This is called the nesting of ifs.

Syntax:
if condition
then
if condition
then
.....
..
do this
else
....
..
do this
fi
else
...
.....
do this
fi
Loop defined as:
"Computer can repeat particular instruction again and again, until particular
condition satisfies. A group of instruction that is executed repeatedly is called
a loop."
Bash supports:
for loop
while loop

for loop:
Syntax:
for { variable name } in { list }
do
execute one for each item in the list until the list is
not finished (And repeat all statement between do and done)
done
while loop
Syntax:
while [ condition ]
do
command1
command2
command3
..
....
done

The case Statement


The case statement is good alternative to Multilevel if-then-else-fi statement.
It enable you to match several values against one variable. Its easier to read
and write.

Syntax:
case $variable-name in
pattern1) command
...
..
command;;
pattern2) command
...
..
command;;
patternN) command
...
..
command;;
*) command
...
..
command;;
esac
Experiment 89

AIM : creating shell programs for automate system


tasks Use of 'at'

'at' is a program to carry out commands that you intend to do only once. It's
mostly used for scheduling specific jobs under specific circumstances. If
you had to rotate your company's webserver logs every Saturday, 'at' is not
the appropriate tool for the job. That would be done best with 'cron', about
which we will talk about shortly. Let say your boss, the CTO, called for a
meeting with you at 1:00. He wants to know how frequently your external
consultants are logging into the network. This is a prime candidate for 'at'.

First, you'd type:


Code:
at 12:45
which would give you plenty of time to get that information before the meeting. You will
see the 'at' prompt:

Use of 'cron'
From a system administrator's point of view, the cron daemon is probably
the best thing since sliced bread. You can schedule practically any program
(provided that they don't have a graphic user interface since cron is not
really designed to run GUI applications) at any time, for any date and at any
interval. That is to say, if you want a text dump of the number of times a
person with the IP address 64.09.200.12 has logged into your computer and
you only want it on February 4th, cron will do this for you.

The jobs that you want to run with cron can be scheduled in various ways.
The most common way is to edit a file which is known as your crontab.
Normally, each user has his/her own and is able to schedule jobs by editing
it. You can add to and delete entries from you crontab by typing:
Code:
crontab –e
Table 1. Guide to Cron times

Variations on a theme
Crontab entries don't have to necessarily have just numbers in them. We can
combine the numbers with other characters to modify how commands get carried
out. For example, I have a USB webcam that doesn't really do what it's supposed
to, which is to take a picture every minute and then shut off. It takes the picture
all right, but it doesn't shut off. So I wrote a script to shut it off and then I added a
crontab entry to call this script every minute. This is what I added:
Code:
0-59/1 * * * * $HOME/shutoff_cam >/dev/null 2>&1
Let's look at this one part at a time
0-59/1
basically means that between the 0-59 minutes of every hour, at every 1 minute
interval, the camera is to shut off. To show you how useful cron is, I remember
seeing a James Bond movie where the perpetual bad-guy, Blofeld, was
brainwashing girls to carry out biological attacks from a base in the Swiss Alps. He
would play these hypnotic tapes to the girls every evening. There is one scene
where you see Blofeld and one of his minions switching the tapes manually. If
only they had had a Linux computer! They could have done this:

cron.hourly, cron.daily and cron.monthly


Most Linux distributions have three directories in /etc called cron.hourly,
cron.daily andcron.monthly, which, as you may have already guessed, lets the
systems administrator run jobs on an hourly, daily or monthly basis. Simply by
placing a shell script here, jobs can be carried out at those intervals. There is
no need to have a crontab entry for these jobs.
Experiment 9

Experiment 10
AIM : Write a shell script to find the largest among
the 3 given numbers

echo Enter 3 numbers with spaces in between


read a b c
l=$a
if [ $b -gt $l ]
then
l=$b
fi
if [ $c -gt $l ]
then
l=$c
fi
echo Lagest of $a $b $c is $l
Experiment 10
Experiment 11
AIM : Write a shell script to find the smallest among
the 3 given numbers
echo Enter 3 numbers with spaces in between
read a b c
s=$a
if [ $b -lt $s ]
then
s=$b
fi
if [ $c -lt $s ]
then
s=$c
fi
echo Smallest of $a $b $c is $s
Experiment 11

Experiment 12
AIM : Introduction to UNIX

UNIX
UNIX is an operating system which was first developed in the 1960s, 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.

Types of UNIX
There are many different versions of UNIX, although they share common
similarities. The most popular varieties of UNIX are Sun Solaris, GNU/Linux,
and MacOS X.
Here in the School, we use Solaris on our servers and workstations, and
Fedora Linux on the servers and desktop PCs.

The UNIX operating system


The UNIX operating system is made up of three parts; the kernel, the shell
and the programs.
The kernel
The kernel of UNIX is the hub of the operating system: it allocates time and
memory to programs and handles the filestore and communications in
response to system calls.
As an illustration of the way that the shell and the kernel work together,
suppose a user types rm myfile (which has the effect of removing the file
myfile). The shell
searches the filestore for the file containing the program rm, and then requests the
kernel, through system calls, to execute the program rm on myfile. When the process
rm myfile has finished running, the shell then returns the UNIX prompt % to the
user, indicating that it is waiting for further commands.
The shell

The shell acts as an interface between the user and the kernel. When a user logs in,
the login program checks the username and password, and then starts another
program called the shell. The shell is a command line interpreter (CLI). It interprets
the commands the user types in and arranges for them to be carried out. The
commands are themselves programs: when they terminate, the shell gives the user
another prompt (% on our systems).
The adept user can customise his/her own shell, and users can use different shells on
the same machine. Staff and students in the school have the tcsh shell by default.
The tcsh shell has certain features to help the user inputting commands.
Filename Completion - By typing part of the name of a command, filename or
directory and pressing the [Tab] key, the tcsh shell will complete the rest of the name
automatically. If the shell finds more than one name beginning with those letters you
have typed, it will beep, prompting you to type a few more letters before pressing
the tab key again.
History - The shell keeps a list of the commands you have typed in. If you need to
repeat a command, use the cursor keys to scroll up and down the list or type history
for a list of previous commands.

Files and processes


Everything in UNIX is either a file or a process.
A process is an executing program identified by a unique PID (process identifier).
A file is a collection of data. They are created by users using text editors, running
compilers etc.
Examples of files:
a document (report, essay etc.)
the text of a program written in some high-level programming language
instructions comprehensible directly to the machine and incomprehensible to
a casual user, for example, a collection of binary digits (an executable or
binary file);
a directory, containing information about its contents, which may be a mixture
of other directories (subdirectories) and ordinary files.

The Directory Structure


All the files are grouped together in the directory structure. The file-system is
arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy
is traditionally called root (written as a slash / )

In the diagram above, we see that the home directory of the undergraduate student
"ee51vn" contains two sub-directories (docs and pics) and a file called report.doc.

The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"

Starting an UNIX terminal


To open an UNIX terminal window, click on the "Terminal" icon
from Applications/Accessories menus.
An UNIX Terminal window will then appear with a % prompt, waiting for you
to start entering commands.

Você também pode gostar