You are on page 1of 282

Operating Systems

Computers have two fundamental


components:
Hardware: Physical components inside a
computer
Software: Set of instructions or programs
that understand how to use the hardware
of the computer in a meaningful way
Operating Systems (continued)
Hardware components include:
Processor (CPU)
Physical memory (RAM)
Hard disk, floppy disk, and CD-ROM
drives
Sound and video cards
Circuit boards

November 17, 2009 3


Operating Systems (continued)
Two different types of programs are executed
on a computer:
Applications
Operating system (OS) software

Device Driver: Software containing instructions


that the OS uses to control and interact with a
specific type of computer hardware
User Interface: An application program that
allows the user to interact with the OS and
other application programs

November 17, 2009 4


Operating Systems (continued)
Operating system:
 Software program
 Set of instructions between hardware and
software
 Way user communicates with computer
Processing of application programs
 All input/output of computer
 Controls/manages resources and users

November 17, 2009 5


Operating Systems (continued)

The role of operating system software

November 17, 2009 6


Unix/Linux History
Unix first version created in Bell Labs-1969
Write Unix system in C language-1973 by Denis Ritchie
AT&T licenses source code for low cost, Trademarkes Unix
name, licensees must create new name for their operating
systems
Many Unix Flavors:, IBM-AIX, Solaris,UnixWare, HP-UX

November 17, 2009 7


Unix Principles
Multiuser, Multitasking
Configuration data stored in text
Ability to chain programs together to
perform complex tasks
Working with Wide variety of
computers
High Level of Security

November 17, 2009 8


GNU Project / FSF
GNU (Gnu Not Unix) Project started
in 1984 (R. Stallman)
Goal: create “free” Unix clone
By 1990, nearly all required users
applications created (gcc, emacs,..)
Free Software Foundation
Non-profit organization that manages
GNU project

November 17, 2009 9


GPL- GNU General Public
License
Primary license for Open Source
Software
Encourages free software
All enhancements and changes to
GPL software must also be GPL
Often called “copyleft”
“all rights reversed”

November 17, 2009 10


GPL- GNU General Public
License-2
freedom to run the program, for any
purpose.
freedom to modify the program to
suit your needs.
freedom to redistribute copies, either
gratis or for a fee.
freedom to distribute modified
versions of the program, so that the
community can benefit from your
improvements
November 17, 2009 11
Linux Origins
Linus Torvalds
Finnish college student in 1991 create
Linux kernel
Code was made available over the
internet for free
Coders world wide took part in developing
the OS

When Linux Kernel combined with


GNU applications, complete free Unix-
like OS appears (GNU/Linux OS)
November 17, 2009 12
Why Linux
Linux and GNU software are distributed
under the terms of the GNU Public License
Agreement (GPL)

Linux is continually being developed by


individuals throughout the world

Skilled programmers can submit additions


and improvements to the Linux OS to
Linux Development Team over the internet

November 17, 2009 13


Why Linux
Applications are developed that are
both free and commercial
Linux is for Intel based platforms,
Power PC, Alpha-based Linux is for
Intel based, multiprocessor
compatibility (SMPs)
Fully supported
Many distribution
(redhat,suse,fedora,ubuntu ...)

November 17, 2009 14


Red Hat Enterprise Linux
Custom version of recent Linux
kernel
Utility and applications
Installation and configuration
software
Support available

November 17, 2009 15


Installing Red Hat Linux
Partitioning Hard disks
Primary Partition + Swap partition
Installation method
Network Configuration
IP ,Netmask, Gateway, Hostname +Domain
name +Name Server
Configuring Boot manager (LILO, Grub)
Select Package

November 17, 2009 16


Hard disk partitioning
hda: Primary Master IDE
hdb: Primary Slave IDE
hdc: Secondary Master IDE
hdd: Secondary Slave IDE
sda: First hard on SCSI bus (or SATA).
sdb: Second hard on SCSI bus (or
SATA).

November 17, 2009 17


Hard disk partitioning-2
Primary Partitions: 1,2,3,4
Logical Partitions: 5,6,7…
hdxy IDE
sdxy SCSI, or SATA
x (name of hard disk)
y (partition number )
Example: hda2,hdb5,sda6

November 17, 2009 18


Hard disk partitioning-3

Track

Sector

Cylinders

Sectors
Head

November 17, 2009 19


Hard disk partitioning-4

• Series of Sectors addressed by


(CHS)
• First sector name MBR: Master
Boot Record contain:
• Boot program
• Partition Table:4 Primary partitions
1234
MBR Partition 1 Partition 2 Partition 3 Partition 4

November 17, 2009 20


Hard disk partitioning-5
Primary Primary Primary Primary
Partition 1 Partition 2 Partition 3 Partition 4

1234

Status Start FS End

A 2 FAT32 2000

Boot 2001 FAT16 3500


0000
Program 3501 EXT2 6000
1BEh 6001 NTFS 8000
Partition
1FEh Table

November 17, 2009 21


Hard disk partitioning-6
Primary Primary Primary Primary
Partition 1 Partition 2 Partition 3 Partition 4
MBR

1234

Boot Sectors

P. P. 1 P. P. 2 P. P. 3 P. P. 4
Type: FAT32 Type: Extended Type: Ext2 Type: NTFS
M
B
R

November 17, 2009 22


Hard disk partitioning-7
P1: FAT32 P2: Extended
M
B C: D: E: F:
R

P1: FAT32 P2: EXT3 P3: Extended


M
B C: / D: E: F: Swap
R

< 1024

November 17, 2009 23


Installing VMWare and using a
virtual machine to install Linux
Download VMWare
(http://vmware.com/download/server/)
Apply for license keys
(http://register.vmware.com/content/regist
ration.html)

November 17, 2009 24


Begin the installation
Accept the license terms

November 17, 2009 26


Customize

November 17, 2009 27


Choose desired features and
installation path

November 17, 2009 28


Disable AutoRun

Note: Windows XP requires extra steps here

November 17, 2009 29


Disable each auto-run type in
XP

November 17, 2009 30


Ready to install!

November 17, 2009 31


This may take a while

Note: You may need to temporarily disable your


Virus Shield (mcsheild.exe hogs processor ticks
while VMWare installs)
November 17, 2009 32
Enter one of the serial number
you applied for in the step
above.

November 17, 2009 33


Finished!

November 17, 2009 34


Connect to the new VMWare
instance

November 17, 2009 35


Check settings

November 17, 2009 36


Select a directory on a drive
with plenty of free space

November 17, 2009 37


Create a new virtual machine

November 17, 2009 38


Choose Linux

November 17, 2009 39


Give it a name

November 17, 2009 40


Using NAT is easiest

November 17, 2009 41


8 GB is plenty

November 17, 2009 42


VMWare will now create a new
space for the Virtual Machine

November 17, 2009 43


New Guest OS setup complete

November 17, 2009 44


Confirm NAT is selected

This works best, especially when the Host OS is using DHCP


November 17, 2009 45
Ready to install OS

Insert your install CD (DVD) and start the virtual machine

November 17, 2009 46


Installation Mode
New or Upgrade
from where
CD
HTTP, FTP, NFS, Hard disk
Kickstart

November 17, 2009 47


Performing the Installation:
Starting the Installation
(continued)

Beginning a Red Hat installation


Linux-OS
48
Performing the Installation:
Starting the Installation
(continued)
Press F2 at Welcome screen to get
installation options
Check media for errors prior to installation
Optional, but recommended

Linux-OS
49
Performing the Installation:
Starting the Installation
(continued)

Viewing installation options

Linux-OS
50
Choosing the Language,
Keyboard, Mouse, and Monitor
Keyboard model and layout automatically
detected
Check “Emulate 3 Button” if mouse does
not have third button
Most monitors automatically detected
If not, try to locate on list of monitor models or
use generic model with correct horizontal and
vertical sync
Incorrect monitor settings can damage
monitor
Linux-OS
51
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)

Selecting an installation language


Linux-OS
52
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)

Verifying keyboard
configuration
Linux-OS
53
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)

Figure 3-6: Selecting a mouse


type
Linux-OS
54
Choosing the Language,
Keyboard, Mouse, and Monitor
(continued)

Verifying monitor configuration


Linux-OS
55
Specifying the Installation Type
Personal Desktop
GUI environment and common applications
Workstation
Same as Personal Desktop plus administrative
and network tools
Server
Several server services
Custom

Linux-OS
56
Specifying the Installation Type
(continued)

Figure 3-8: Choosing an installation


type
Linux-OS
57
Hard Disk Partitioning
Filesystems can be accessed if attached
(mounted) to a directory
Minimum of two partitions
Partition for root directory
Partition for virtual memory (swap memory)
 Area on hard disk used to store information normally
residing in physical memory (RAM)
Automatic or manual partitioning

Linux-OS
58
Hard Disk Partitioning
(continued)

Common Linux filesystems and sizes

Linux-OS
59
Hard Disk Partitioning
(continued)

Figure 3-9: Choosing a disk partitioning


method
Linux-OS
60
Hard Disk Partitioning
(continued)
Different types of filesystems
Ext2: Used on most Linux computers
Ext3: Performs journaling
Vfat: Compatible with Windows’ FAT filesystem
REISER: Performs journaling
Journaling: Keeps track of the information
written to the hard drive
Disk Druid: Graphical partitioning program

Linux-OS
61
Hard Disk Partitioning
(continued)

The Disk Druid partitioning utility


Linux-OS
62
Hard Disk Partitioning
(continued)

Figure 3-11: Creating a new


partition
Linux-OS
63
Configuring the Boot Loader
Boot loader: Program started by BIOS ROM
Loads kernel into memory
Can also boot other existing OSs
GRand Unified Bootloader (GRUB): Boot
loader configured during Fedora Linux
installation
Dual booting: Choose OS to boot at startup

Linux-OS
64
Configuring the Boot Loader
(continued)

Figure 3-12: Configuring a boot


loader
Linux-OS
65
Configuring the Boot Loader
(continued)
Boot loader usually resides on the MBR or
on first sector of / or /boot partition
Kernel parameters: Information passed to
Linux kernel via the boot loader
Large Block Addressing 32-bit (LBA32):
Enables Large Block Addressing in boot
loader
For large hard disks not fully supported by the
BIOS

Linux-OS
66
Configuring the Boot Loader
(continued)

Configuring advanced boot loader options

Linux-OS
67
Configuring the Network and
Firewall

Specifying a network configuration

Linux-OS
68
Configuring the Network and
Firewall (continued)
Will NIC be activated at boot time?
Manual IP configuration
Set IP address, Netmask, host name, gateway, primary
domain name space (DNS)
Automatic IP configuration via DHCP
Firewall prevents traffic from entering computer
Customize which traffic is allowed through

Linux-OS
69
Configuring the Network and
Firewall (continued)

Configuring a firewall
Linux-OS
70
Choosing a System Language
and Time Zone

Selecting additional language support

Linux-OS
71
Choosing a System Language
and Time Zone (continued)

Choosing a time zone

Linux-OS
72
Creating the Root User
Authentication: Users log in via valid user
name and password
Configure two user accounts
Administrator account (root)
 Full rights to system
Regular user account

Linux-OS
73
Creating the Root User
(continued)

Setting a root password

Linux-OS
74
Selecting Packages

Figure 3-19: Selecting


packages
Linux-OS
75
Installing Packages

Figure 3-19: Package


Installation
Linux-OS
76
Completing the Firstboot Wizard
Complete the installation
License agreement
Graphics settings
User accounts and authentication
Install additional software
Log in with user account for daily tasks
Shadow password: stored in separate DB
from user accounts
MD5: password encryption method

Linux-OS
77
Completing the Firstboot Wizard
(continued)

Setting the date and time

Linux-OS
78
Completing the Firstboot Wizard
(continued)

Configuring screen resolution and color


depth
Linux-OS
79
Completing the Firstboot Wizard
(continued)

Creating a regular user account

Linux-OS
80
Completing the Firstboot Wizard
(continued)

Configuring user information


Linux-OS
81
Completing the Firstboot Wizard
(continued)

Configuring authentication
Linux-OS
82
Installing Linux: Installation
Methods
FTP server
HTTP Web server
NFS server
Packages on hard disk
Boot from first Red Hat (Fedora) Linux CD-
ROM

83
Performing the Installation: Starting
the Installation (continued)

Beginning a Red Hat installation


84
Performing the Installation: Starting
the Installation (continued)
Press F2 at Welcome screen to get
installation options
Check media for errors prior to installation
Optional, but recommended

85
Choosing the Language, Keyboard,
Mouse, and Monitor
Keyboard model and layout
automatically detected
Check “Emulate 3 Button” if mouse
does not have third button
Most monitors automatically detected
If not, try to locate on list of monitor models
or use generic model with correct horizontal
and vertical sync

86
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Selecting an installation language


87
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Verifying keyboard configuration


88
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Selecting a mouse type


89
Choosing the Language, Keyboard,
Mouse, and Monitor (continued)

Verifying monitor configuration


90
Specifying the Installation Type
Personal Desktop
GUI environment and common applications
Workstation
Same as Personal Desktop plus administrative
and network tools
Server
Several server services
Custom

91
Specifying the Installation Type
(continued)

Choosing an installation type


92
Hard Disk Partitioning
Filesystems can be accessed if attached
(mounted) to a directory
Minimum of two partitions
Partition for root directory
Partition for virtual memory (swap memory)
 Area on hard disk used to store information normally
residing in physical memory (RAM)
Automatic or manual partitioning

93
Hard Disk Partitioning
(continued)

Common Linux filesystems and sizes

94
Hard Disk Partitioning
(continued)

Choosing a disk partitioning method


Hard Disk Partitioning
(continued)

The Disk Druid partitioning utility


96
Hard Disk Partitioning
(continued)

Creating a new partition

97
Configuring the Boot Loader
Boot loader: Program started by BIOS ROM
Loads kernel into memory
Can also boot other existing OSs
GRand Unified Bootloader (GRUB): Boot
loader configured during Fedora Linux
installation
Dual booting: Choose OS to boot at startup

98
Configuring the Boot Loader
(continued)

Configuring a boot loader

99
Configuring the Boot Loader
(continued)
Boot loader usually resides on the MBR or
on first sector of / or /boot partition
Kernel parameters: Information passed to
Linux kernel via the boot loader
Large Block Addressing 32-bit (LBA32):
Enables Large Block Addressing in boot
loader
For large hard disks not fully supported by the
BIOS

100
Configuring the Boot Loader
(continued)

Configuring advanced boot loader options

101
Configuring the Network and
Firewall

Specifying a network configuration

102
Configuring the Network and
Firewall (continued)
Will NIC be activated at boot time?
Manual IP configuration
Set IP address, Netmask, host name, gateway, primary
domain name space (DNS)
Automatic IP configuration via DHCP
Firewall prevents traffic from entering computer
Customize which traffic is allowed through

103
Configuring the Network and
Firewall (continued)

Configuring a firewall
104
Choosing a System Language and
Time Zone

Selecting additional language support


105
Choosing a System Language and
Time Zone (continued)

Choosing a time zone


106
Creating the Root User
Authentication: Users log in via valid user
name and password
Configure two user accounts
Administrator account (root)
 Full rights to system
Regular user account

107
Creating the Root User
(continued)

Setting a root password

108
Selecting Packages

Selecting packages
109
Installing Packages

Package Installation
110
Completing the Firstboot Wizard
Complete the installation
License agreement
Graphics settings
User accounts and authentication
Install additional software
Log in with user account for daily tasks
Shadow password: stored in separate DB
from user accounts
MD5: password encryption method

111
Completing the Firstboot Wizard
(continued)

Setting the date and time

112
Completing the Firstboot Wizard
(continued)

Configuring screen resolution and color depth

113
Completing the Firstboot Wizard
(continued)

Creating a regular user account

114
Completing the Firstboot Wizard
(continued)

Configuring user information


115
Completing the Firstboot Wizard
(continued)

Configuring authentication
116
Local Login
Text mode login at Virtual consoles
Multiple non-GUI logins are possible through the
use of virtual consoles
There are by default 6 available virtual consoles
Available through Ctrl-Alt-F[1-6]
Graphical login
If X is running, it is available as Ctrl-Alt-F7

November 17, 2009 117


Linux Graphical Environments

XFree86: standard X windows System


GNOME – Desktop environment based on the
GTK+ toolkit
KDE – Desktop environment based on the Qt
toolkit

November 17, 2009 118


Shells, Terminals, and the
Kernel

Shells, terminals

119
Common Linux terminals

120
Running Commands
Command-line terminal may be accessed
from GUI environment
Command prompt:
Root user: #
Regular user: $

121
Running Commands
Command have the following syntax:
command [options] [arguments]
Each item is separated by a space
Case sensitive
Options modify the command’s behavior
Arguments are filenames or other
information needed by the command
Separated commands with semicolon (;)
Example: date;cal

November 17, 2009 122


Changing Your Password

Password should be changed after first login


From the Red Hat menu, choose
Preferances Password
From a terminal, use passwd

November 17, 2009 123


Shutting Down the Linux
System

Commands to halt and reboot the Linux operating


system

124
The Filesystem Hierarchy
Standard
Filesystem Hierarchy Standard (FHS):
Standard set of directories for Linux and
UNIX systems
File and subdirectory contents
Gives Linux software developers ability to locate
files on any Linux system
 Create non-distribution–specific software

125
The Filesystem Hierarchy
Standard (continued)

: Linux directories defined by FHS

126
The Filesystem Hierarchy
Standard (continued)

Linux directories defined by FHS

127
Linux File Hierarchy
Concepts

The Windows filesystem structure

The Linux filesystem structure

128
Linux File Hierarchy Concepts

Directories may /
contain plain files
or other directories bin users tmp
Leads to a tree
structure for the doug rocket
filesystem
Root directory: / joke.txt cs2204

lab1.txt lab2.txt

November 17, 2009 129


Listing Directory Contents
List the content of a current directory or a specified
directory
Usage:
ls [options] [files or dirs]
• Example:
• ls
• ls /home
• ls –l
• ls -a

130
The Home Directory
Every user has a home directory, typically under
/home

Contain user-specific configuration files as well as


user data

Represented by the ~ character

November 17, 2009 131


Absolute pathnames
Absolute pathnames begin with a slash (/)

Complete “road map” to file location

Can be used anytime you wish to specify a file


name

November 17, 2009 132


Relative pathnames
relative pathnames do not begin with a slash (/)

Specifies location relative to your current working


directory

Can be used as a shorter way to specify a file name

November 17, 2009 133


pathnames
 Separate directories by /
 Absolute path /
 start at root and follow
the tree bin users tmp
 e.g. /users/doug/joke.txt
 Relative path doug rocket
 start at working
directory
joke.txt cs2204
 .. refers to level above;
 . refers to working dir.
lab1.txt lab2.txt
 If /users/doug/cs2204 is
working dir, this refer
to the same file as
previous one
November 17, 2009 134

Changing Directory
pwd displays the absolute path to the current
directory
cd changes directories
- To an absolute path: $ cd /home/issa/work
- To relative path:$ cd project/docs
- To a directory one level up: $ cd ..
- To your directory home: $ cd
- To your previous working directory: $ cd -

November 17, 2009 135


File names
File names may be up to 255 characters
All characters are valid, except the “/”
It may be unwise to use certain special characters in
filename
File names are case-sensitive
Example: MAIL, Mail, mail, and mAil
Again, possible, but may not be wise

November 17, 2009 136


Getting Command Help
Linux distributions contain many
commands
Manual pages: Most common form of
documentation for Linux commands
“man” pages
At command prompt, type “man” followed by a
command name
Contain different sections

137
Manual page section numbers

138
Getting Command Help
Examples
man ls
man 5 passwd (5 for section)
man passwd

November 17, 2009 139


Other Help Utilities
command --help
The whatis same as man –f
The apropos same as man –k
info
 Text based with sections organized by subject
 Command is info section_name

Gnome documentation

November 17, 2009 140


Copying files and Directories
 cp – copy files and directories
Usage:
cp [options] file destination
More than one files may be copied at a time if the
destination is a directory
cp [options] file1 file2 dest

November 17, 2009 141


Copying Files and Directories:
The Destination
If the destination exists and is a directory, the
copy is placed there with the same name
 If the destination exist and is a file, the copy
overwrites the destination file
If the destination does not exist, the copy is
created with that name

142
Moving and Renaming
Files and Directories
 mv – move and/or rename files and directories
Usage:
mv [options] file destination
More than one files may be moved at a time if the
destination is a directory
mv [options] file1 file2 dest

143
Moving and Renaming Files and
Directories: the Destination
If the destination exists and is a directory, the source
files or directory is moved there with the same name
 If the destination exist and is a file, the source file is
moved to that filename, overwriting the file
If the destination does not exist, the source file or
directory is renamed with that name

144
Removing and Creating Files
 rm – remove files
Usage:
rm [options] filenames
 -i interactive
 -r recursive (when removing directory)
 -f force

 touch – create empty files or update filestamps

145
Creating and Removing
Directories
 mkdir – make a directory
 rmdir – remove an empty directory
 rm –r – recursively remove a directory
and all of its content
Determining File Content
Files can contain many types of data
Check file type before opening to determine
appropriate command or application to use
Syntax
file [options] filename (s)

November 17, 2009 147


Viewing an Entire Text File

Syntax
cat [options] [file …]
Contents of the files are displayed
sequentially with no break
Files display “concatenated”

November 17, 2009 148


Viewing Files One Screenful
At a Time
Syntax
less [options] [filename]
Display the contents of a text file one screen at a time
less is the pager used by man
 Syntax
more [options] [filename]

November 17, 2009 149


bash Introduction
Bourne shell (sh) –original UNIX shell written
by Steven Bourne at AT&T
bash “Bourne Again shell “ Developed for
GNU project
bash The de facto standard Linux shell
Backward – compatible with Bourne shell (sh)
– the original (standard) UNIX shell.

November 17, 2009 150


bash Heritage
C shell (csh) – written by bill joy at UC Berkeley
Added many features such as command completion,
history and job control
Korn shell (ksh) – written by David Korn at AT&T
Bourne Again Shell (bash) Implements many of
the extra features found in csh, ksh
Command line completion
Command line editing
Command line history
Sophisticated prompt control

November 17, 2009 151


File Globbing
Globbing is wildcard expansion:
* matches zero or more characters
 ? matches any single character
 [a-z] matches a range of characters
 [^a-z] matches all except the range

Example
$ls /usr/bin/b*
$ls /usr/bin/?b*
$ls a[0-9]
$ls [!Aa]*

152
The Tab key
Type <TAB> key to complete command line:
For the command name, it will complete a command
name
For an argument, it will complete a file name
Examaple:
slo<TAB>
slocate
ls myf<TAB>

November 17, 2009 153


history
bash stores a history of commands you’ve entered,
which can be used to repeat commands
Use history command to see a list of
“remembered” commands: $ history
Use bang character !

!x execute last command begin with x


!2 execute command no 2
!! Execute Last command

154
History-2
Use the up and down arrow keys to scroll
through previous commands
Type <CTRL-R> to search for a command
in command history
(reverse-i-search)`’:
To recall last argument from previous
command:
<ESC>. Or <ALT-.>

November 17, 2009 155


Command Editing Tricks
<Ctrl-a> move to beginning of line
<Ctrl-e> move cursor to end of line
<Esc>f move cursor to beginning of next
word
<Esc>b move cursor to beginning of
previous or current word
<Ctrl-u> delete to beginning of line
<Ctrl-k> delete to end of line

156
Command Editing Tricks
Editing Modes
By default, bash uses emacs-style key
bindings for command editing
Type set –o vi
to change key bindings to vi-style
Make vi the default by adding the command
above to $HOME/.inputrc

November 17, 2009 157


Tilde
Hidden file begin with . for listing them use ls -a
Tilde (~)
Refer to your home directory:

$ cat ~/.bashrc
May refer to another user’s home directory:

$ ls ~issa/.bashrc

158
The bash Shell
Variable
A variable is a label that has a value
Variables are resident in memory
Tow types: local and environment
Local variables are used only by the shell
Environment variables are passed onto other
commands and shells.
 set to display all variables
 env display environment variables

November 17, 2009 159


Local Variable
Conventionally all upper-case
Setting variable value
$ CREDIT=300
$ echo $CREDIT
Common Local Variables
HISTFILESIZE determine how many command to be
saved in the history file on logout
COLUMN sets the width of the terminal
LINES sets the height of terminals
PS1 sets the prompt

November 17, 2009 160


Environment variables

Shell variables exist only in current shell


instance
Environment variables passed to subshells
Shell variables can be exported into
environment
$ CREDIT=300; export CREDIT

November 17, 2009 161


Common Environment variables

HOME Path to user’s home directory


LANG Identification of default language
program should use
PWD User’s current working directory
EDITOR default editor program
LESS options to pass to the command less
TERM terminal type

November 17, 2009 162


Environment variables

PATH colon separated list of locations where


commands can be found
which command (not variable) showing path
of executable
$which ls
Path to command can also be given explicitly
$ /bin/ls /etc
$ ./ls /etc

November 17, 2009 163


Aliases

Aliases let you create shortcuts to command


$ Alias dir=‘ls –laF’
Use alias to see all set aliases
To see alias value: $ alias dir
$ alias dir=‘ls –laF’

November 17, 2009 164


Variable and String
Parameter/Variable: $
Substitute the value of variable in a command line
$ cat $HOME/.bash_profile
$ echo $PATH
Curly braces: { }
A string is created for every pattern inside the braces
regardless if any file exist
$ rm hello.{c,o}

November 17, 2009 165


Command and Math
Command output: ` ` or $()
 substitute output from a command in a command line
$ echo “Hostname: `hostname`”
$ echo $(date)
Arithmetic: $[ ]
Substitute result of arithmetic expression in a
command line
$ echo Area: $[ $x * $y ]

November 17, 2009 166


Protecting from Expansion:
Backslash
Backslash ( \ ) is the escape character and makes
the next character literal
$ echo Your cost: \$5.00
Used as last character on line to continue command
on next line:
$ echo “This long string will be echoed \
back as one long line”
This long string will be echoed back as one long
line”

November 17, 2009 167


Protecting from Expansion:
Quotes
Single quotes (‘) inhibit all expansion
Double quotes (“) inhibit all expansion except
 $ (dollar sign) including $()
` (back tick), command substitution
 \ (backslash),single character inhibition
 ! (exclamation point), history substitution

November 17, 2009 168


Shell Startup Script

November 17, 2009 169


Shell Startup Script

November 17, 2009 170


Startup Script: order of execution

November 17, 2009 171


/etc/profile

November 17, 2009 172


/etc/profile.d

November 17, 2009 173


~/.bash_profile and ~.bashrc

November 17, 2009 174


~/.bash_logout

November 17, 2009 175


Overview of vi and vim
vi: the “visual editor”, standard Linux and
Unix editor
vim: the “vi improved” standard Red Hat
editor
On Red hat operating systems, the vi
command invokes vim
Derived from earlier Unix editors
ed->ex->vi->vim

November 17, 2009 176


Starting of vi and vim
To start vim : vi filename
If the file exists, the file is opened and the content
are displayed
If the file doesn’t exists, vicreate it when the
edits are saved for the first time

November 17, 2009 177


Three Modes of vi and vim
Command mode
Cursor movement
Change, delete, yank, put
Insert mode
Type in new text
Return to command mode with <ESC>
Ex mode
Configuring, exiting, saving
Search and replace

November 17, 2009 178


Three Modes of vi and vim

command
mode
wrong command
i ESC :
insert last line
mode Mode or Ex mode

November 17, 2009 179


Cursor Movement
Insert mode
h left, j down , k up , l right
w word ahead, b word back
Arrow keys also work
a append after the cursor
i insert before the cursor
A append to end of line
I insert at beginning of line
o open a line below
O open a line above

November 17, 2009 180


Command mode

<esc> takes you from insert mode back


to command mode
 cc change line, dd delete line, yy yank
(copy) line
 cw change word, dw delete word, yw
yank word
Use p or P to put (paste) copied or deleted
data

November 17, 2009 181


Undoing Changes
u undo most recent change
U undo all changes to current line since the
cursor landed on the line
<Ctrl-r> redo last “undone” change

November 17, 2009 182


Searching for Text
/text search downwards for “text”
?text search Upwards for “text”
n continue search in the same direction
N continue search in the opposite direction

November 17, 2009 183


Saving and Exiting: ex mode

:wq save changes


:q or q! abandon changes
:w save without exit
:e! abandon changes without exit
:wq! Forcing save changes
:w! Forcing save without exit

November 17, 2009 184


A few tricks
5dd delete 5 line (a number can precede any
of the tow character change, delete, yank, or
put command
x delete a character
rc replace a character with c
R replace character for character until
<esc>

November 17, 2009 185


Users
Every user of the system is assigned a
unique User ID number
User’s names and uid are stored in
/etc/passwd
User are assigned a home directory and a
program that is run when they log in (usually
shell)
Users cannot read, write or execute each
others’ files without permission
November 17, 2009 186
Groups
User’s are assigned to groups with unique
group ID number (gid)
gids are stored in /etc/group
Each user is given their own private group
They can also be added to other groups to gain
additional access
 all users in a group can share files that
belong to the group

November 17, 2009 187


The root users
The root user: a special administrative
account
Sometimes called the superuser
root has complete control over the system
 An unlimited capacity to damage the system!
You should not log in as root without a very
good reason
 Normal (“unprivileged”) users potential to do
damage is limited

November 17, 2009 188


User and Group ID Numbers
User names map to user ID numbers
Group names map to group ID numbers
Data stored on the hard disk is stored numerically
Authentication information is stored in plain text files:
/etc/passwd
/etc/shadow
/etc/group

November 17, 2009 189


System Users and Groups
Server programs such as web or print
servers typically run as unprivileged users,
not as root
Examples: mail, lp, nobody
Running programs in this way limits the
amount of damage any single program can
do to the system

November 17, 2009 190


Changing Your Identity
To change your password, run passwd
Insecure passwords are rejected
To start a new shell as a different user:
su
su –
su username
su - username

November 17, 2009 191


The Linux Security Model
Users and groups are used to control
access to files and resources
Users log in to the system by supplying
their user name and password
Every file on the system is owned by a
user and associated with a group
Every process has an owner and group
affiliation , and can only access the
resources its owner or group can access

November 17, 2009 192


Linux File Security
Every file and directory has permission set
that determine who can access it
Permission are set for:
The owner of the file (called “user”)
The group members
All others
Permissions that are set are called read,
write and execute permissions

November 17, 2009 193


Linux Process Security
When a process accesses a file the user
and group of the process are compared
with the user and group of the file
If the user matches, the user permissions apply
If the group matches, but the user doesn’t, the
group permissions apply
If neither match, the other permission apply

November 17, 2009 194


Examining Permissions
File permissions may be viewed using ls
$ ls –l /bin/login
-rwxr-xr-x 1 root root 19080 Apr 1 18:26 /bin/login

File type and file access permission are


symbolized by a 10-character string

November 17, 2009 195


Using Categories
File permissions are established for each of
three user categories. Each category also
has a one-letter symbol:
u - the file’s owners (user)
g - other users in the file’s group
o – everyone else (others)

November 17, 2009 196


File Permission Types
Four symbols are used when displaying
permission:

 r : permission to read a file or list a directory’s


content
w : permission to write to a file or create and
remove files from a directory
x : permission to execute a program file or
change into a directory and do long listing of the
directory
- : no permission (in place of the r, w, or x)
November 17, 2009 197
File Permission Types

November 17, 2009 198


Examining Directories
The first character in the long listing
distinguish directories (d) from regular files
(-)
$ ls –ld /bin
drwxr-xr-x 2 root root 4096 Apr 1 18:26 /bin

$ ls –l /bin/df
-rwxr-xr-x 1 root root 4096 Apr 1 18:26 /bin/df

Others file types indicators exist

November 17, 2009 199


Examining User Permissions
Characters 2,3, and 4 in the access mode
identify user permissions
$ ls –l /bin/login
-rwxr-xr-x 1 root root 19080 Apr 1 18:26 /bin/login

This file can be read, written, and


executed by its owner, and read and
executed by everyone else

November 17, 2009 200


Examining group Permissions
Characters 5,6, and 7 in the access mode
identify group permissions

$ ls –l README
-rw-rw-r-- 1 issa teachers 9080 Oct 1 8:26 README

This file can be read and written by


people in group teachers, but it cannot be
executed.

November 17, 2009 201


Examining Other Permissions
Characters 8,9, and 10 in the access mode
identify permissions for others:
$ ls –l README
-rw-rw-r-- 1 issa teachers 9080 Oct 1 8:26 README

This file can be read by people outside


group teachers, but it cannot be changed
or executed

November 17, 2009 202


Changing Permissions
Symbolic method
To change access mode :
$ chmod [-R] mode file…
Changes the access mode of files and directories
-R option: Change permission to directory and all
files and subdirectory inside it content

November 17, 2009 203


Changing Permissions
Symbolic method
Examples: try this example
chmod u+x file (or dir) , chmod o-w file(or
dir)
chmod g+wx,o=r file (or dir)
chmod u=rwx file (or dir)

November 17, 2009 204


Changing Permissions
Numeric method
Uses a three-digit mode numbers
First digit specifies owner’s permission
Second digit specifies group permission
Third digit represents other’s permission

Permissions are calculated by adding :

November 17, 2009 205


Changing Permissions
Numeric method
Examples:
chmod 755 file1 (dir1)
chmod 666 file1(dir1)

November 17, 2009 206


umask
Only applies to newly created files and directories
Used to alter the permissions on all new files and
directories by taking select default file and directory
permissions away
Will never be used to modify the permissions of existing files
and directories
Read and write for all is the default (666) for files and
777 for directory
Non-privileged user’s umask is 0002 and the root’s
umask is 0022

November 17, 2009 207


umask
Non-privileged user’s umask is 0002 and
the root’s umask is 0022
File will have permissions of 664
 Default Mode 666
umask -002
New File Mode 664

November 17, 2009 208


Performing a umask 007 calculation

209
Special Permissions
Special permissions: a fourth permission set (in
addition to user/group/other), Applicable in four
cases:
SUID (set user ID) for an executable, Processes are
granted access to system resources based on user
who owns the file.
SGID (set group ID) for and executable, Same with
SUID except group is affected.
SGID a directory: Files created in that directory will
have their group set to the directory's group.

November 17, 2009 210


Special Permissions
The sticky bit was used on files in the past
to lock them in memory
Today, the sticky bit performs a useful
function only on directories:
Sticky bit for a directory, If set on a directory,
then a user may only delete files that he owns
or for which he has explicit write permission
granted, even when he has write access to the
directory. (e.g. /tmp )
Special Permissions

November 17, 2009 212


Setting Special Permissions
(continued)

Representing special permissions in the mode

213
Numeric representation of regular and special
permissions

214
SUID Permissions(example)
When you login, your login shell process’ values are your user
ID and group ID
E.g., if you run passwd (owned by root), THE user ID is your ID, not
root; then how can it update /etc/passwd file owned by root ?
SUID bit enables this functionality
When an executable file with set user ID (SUID) permission is executed,
command run with permission of the owner of the command, not
executor of the command
File permission of /usr/bin/passwd is r-s--x—x
The SUID can only be applied to binary compiled programs

November 17, 2009 215


Files sytsems
Disk drives are divided into partitions
Partitions are formatted with filesystems
alloying users to store data
Default filesystem: ext3, The Third Extended
Linux Filesystems
Other common filesystems:
 ext2 , msdos, FAT, NTFS
 Iso9660(typically used for CDs)

November 17, 2009 216


Files sytsems(continued)

Filesystem has three main structural


sections:
Superblock: Contains general information
about the filesystem
 e.g., number of inodes and data blocks
Inode: Describes a file or directory
Data blocks: Data making up contents of a file

217
Inode
An inode tables contains a list of all files in an ext2 or ext3
filesystem
An inode (index nodes) is an entry in the table, containing
information about a file (the metadata), including:
File type, permission, link count, UID, GID
The file’s size and various time stamps
Pointers to the file’s data blocks on disk

One inode is associated with each file.


The system uses inodes as the definition of a file.

November 17, 2009 218


Directory
The computer’s reference for a file is the
inode number
The human way to reference a file is by
file name
A directory is a mapping between the
human name for the file and the
5 apples
computer’s inode number
4 oranges
7 home
2 .

November 17, 2009 219


cp and inode
The cp command:
 allocates a free inode number, placing a new
entry in the inode table
Create a directory entry, referencing the file
human file name to the inode number
Copies data into new file

November 17, 2009 220


mv and inode
If the destination of the mv command is
on the same file system as the source, the
mv command:
Creates a new directory entry, with the news
file name
Deletes the old directory entry with the old file
name
Has no impact on the inode table (except for a
time stamp) or the location of the data on the
disk: no data is moved!

November 17, 2009 221


rm and inode
The rm command:
Decrement the link count, thus freeing the
inode number to be reused
Places data bocks on the free list
Removed the directory entry
Data is not actually removed, but will be
overwritten when the data blocks are used
by another file

November 17, 2009 222


Linking Files
Symbolic link: One file is a pointer or
shortcut to another
Hard link: Two files share the same data

223
Symbolic (or Soft) links
ls –i for displaying inode number
A symbolic link point to another file
ls –l display the link name and the
referenced file
$ ls –l pf
lrwxrwxrwx 1 issa issa 11 Oct 1 8:26 ps/etc/passwd

 File type: l for symbolic link

Syntax
ln –s filename [linkname]
November 17, 2009 224
The structure of symbolically linked files

225
Hard links
Do not work with networked file systems, any
mounted devices, or any other file system
Only exist on same disk and partition as original
file
One physical file on the filesystem
Each link references the file’s inode
File is present in the filesystem as long as at
least one link remain
Syntax
ln filename [linkname]

November 17, 2009 226


Hard links
To see which files are linked—check inode
numbers
Two files with same inode numbers—
identical files
Any changes made to one file - reflected in
second file (true because files are linked)
To create links to files in different
directories first give read, write, and
execute permissions to other users

November 17, 2009 227


The structure of hard linked files
locate Command
Fastest way to search for file/s in entire
directory tree
 locate looks in pre-defined database

 Wildcards can be used with locate


command
 If database not updated cannot locate
files even if files are in system
find command
find command
Locates specific file or group of files
 Does not rely on a database
 Searches directory tree for files
meeting criteria specified
Searches recursively
Wildcards can be used in filename
statement

Ch 2 230
find command
 Syntax
find <dirs> [conditions] [action]
Recurses down in file tree in dirs
Optionally executes command on
each line of output
<Ctrl> + C is quick way to break
into command and stop it from
executing
November 17, 2009 231
some find options

Ch 2 232
Finding Examples
Example:
find . -print
 find
all files in the current directory (and all
subdirectories) & display the results
find . -name “*.c” -print
 find all files in the current directory (and all
subdirectories) with the extension .c & display
the results

November 17, 2009 233


Finding Examples
find / -name myfile -print
 Thiscommand tells the find command to
look inside the / directory and every
subdirectory to look for a file or directory
with the name myfile and to display each
match it finds

 find . -name “foo*” -amin -10 -print


 Thiscommand tells the find command to
look inside the current directory and every
subdirectory to look for a file with name
begin with foo that have been accessed in
the last 10 minutes and to display each
match it finds
Finding and processing Files
-exec action execute a command
 Syntax
find <dirs> [conditions] -exec cmd {} \;

“Found” files are passed to cmd as arguments


{} is a place holder for the filename
The escaped semicolon delimit the generated
commands
Finding Examples
Example: (for student)

find . -size +5000k


find . -name "*.tmp" -exec rm {} \;

November 17, 2009 236


whereis Command
 ls, locate, and find commands
used to locate files of interest

 whereis command
locates/displays locations of a
program, source, and manual pages
for a specific command

Ch 2 237
whereis Command
whereis command
 Faster than find command since
search path is built in
 More specific than locate
command
 Searching for files that are
programs
whereis
KEY CONCEPTS:
 Most binary Command programs
located in the /usr/bin directory
 Most documentation located in
/usr/share/man directory
 Cannot execute a command unless it
is in your search path
 Must have permission to execute a
command
File Compression

Results in smaller file size


Text files can be compressed up to
75%
Binary files usually don’t compress
much
File Compression
 gzip
 Compresses a file or files
 Compressed file renamed filename.gz
 Syntax: gzip [options] [files]
See option: –l -d
 gunzip
 Uncompresses a file or files
 Takes all of gzip’s options
 Syntax: gunzip [options] [files]
File Compression
 bzip2
 Compresses file/files
 Compressed file renamed to filename.bz2
 Syntax: bzip2 [options] [filenames . . . ]

 bunzip2
 Used to uncompress file/files
 Syntax: bunzip2 [options] [filenames . . .]
File Compression

zcat
Reads compressed files compressed
with gzip and writes them to
standard output
 Identical to gunzip –c

 Syntax: zcat [options] [files]


File Compression

Sample compression commands (for


student)
gzip termcap
gzip -v termcap
gunzip -c termcap.gz | wc –l
gunzip termcap

November 17, 2009 244


File Compression

KEY CONCEPTS:
 file no longer exist in home directory with
original name
 To see size of file when uncompressed pipe
output from zcat to wc command
File seen in red—compressed/archived file
 Can see contents of .gz file (must be text
file) with zcat command
Archiving Tools
Tape archive (tar) utility: One of oldest and
most common backup utilities
Can create archive in a file on a filesystem or
directly on a device
Accepts options to determine location of archive
and action to perform on archive
Archiving Tools
tar:
Used for archiving file/files
Often compressed
Easier to back up, store, and transfer
Used to create single file that when
unpacked creates a directory structure
 Software that has been processed by tar
and compressed by gzip usually has
extension .tar.gz, or tgz
Archiving Tools
Syntax:
tar [options] [tarfile] [other-
files]

tar cvf archive_name files


c create a new archive
v produce verbose messages
f archive_name is the name of new file
Options do need a leading dash

November 17, 2009 248


Inspecting Archives
Syntax
tar tf archive_name.tar

tar tvf archive_name.tar

First form display a list of all files in the archive


The v cause a long listing of each file in the
archive

November 17, 2009 249


Extracting an Archive
Syntax
tar xvf archive_name.tar
The archive will be extracted in the current
directory
Change to the target directory first
Files maintain their hierarchy relative to
the current directory
Compressing archives
Often tar archive are compress
tar can compress/uncompress archives
Compression switches- use during creation
and extraction
 z for gzip compression
 j for bzip2 compression

November 17, 2009 251


tar with Compression

file1 tar gzip

.tar .tar.gz

sub-
directory

November 17, 2009 252


tar to Unformatted Floppies
Floppies can used like tape drives
Low level format required
File system not needed
Use tar to write to the floppy
/dev/fd0 is the destination
Floppy cannot be mounted
Example:
$ tar czvf /dev/fd0 mydir

November 17, 2009 253


Standard Input and Output
Linux provides three I/O channel to
processes

Standard input (0): keyboard is default


Standard output (1): terminal windows is
default
Standard error (2) : terminal windows is default
Redirecting Input and Output
standard input, output, and error can be
reconnected to alternate locations
Shell redirection operators allow standard I/O
channels to be redirected to/from a file
Pipes allow standard I/O channels to connected
to the input or output of programs
Redirecting Output
In order to study redirecting standard
output, and error, we will use the find
command.
find /etc –name passwd
This command will search for all files
named passwd in /etc and its subdirectory
By default both the standard output and
standard error are displayed on the screen.

November 17, 2009 256


Redirecting Standard Output
Redirecting standard output with >
 find /etc –name passwd > findresult
standard error is still displayed on the screen.
If the target file of file redirection with >
already exists, the existing file will be
overwritten
To append data to an existing file, use >> to
redirect instead of >

November 17, 2009 257


Redirecting Input and Output
Redirecting Standard Error
Redirect standard error with 2>
Example : redirect standard error to a file:
 find /etc –name passwd 2> finderrors
Standard outputs still displayed on the
screen.
To append data to an existing file, use 2>>
to redirect instead of 2>

November 17, 2009 259


Redirecting Standard Error
Can redirect standard error to a
device called /dev/null
 Example: Redirecting error
message in find command
find / -iname gedit 2> /dev/null

November 17, 2009 260


Redirecting Both Standard
Output and Error
Redirection of standard output and standard error
can be performed simultaneously
 find /etc –name passwd 2> error > result

Each I/O channel can be redirected to different files,


or the same file:
 find /etc –name passwd > alloutput 2>&1
Or find /etc –name passwd &> alloutput

November 17, 2009 261


Redirecting Input
Redirect standard Input with <
Some commands only operate on standard input
tr doesn’t accept filenames as arguments- it require its
input to be redirected from somewhere
tr ‘A-Z’ ‘a-z’ < .bash_profile
This command will translate the uppercase character in
bash_profile to lowercase

November 17, 2009 262


Using pipes To connect
processes
Pipes (the | character) let you redirect output
from one command to become input to another
command
ls /usr/lib | less
The mail command takes the message contents
as standard input
ls –l | mail –s “here the listing” issa

November 17, 2009 263


tee
Let you tee a pipe: redirect output to a file
while still piping it to another program

set | tee set.out | less


Output from set command is written to file
set.out while also being piped to less

November 17, 2009 264


tee
Let writing to output and simultaneously
 date | tee file1 file2
Thu Jun 10 11:10:34 CEST 2007
 cat file1
Thu Jun 10 11:10:34 CEST 2007
 cat file2
Thu Jun 10 11:10:34 CEST 2007
 uptime | tee -a file2
11:10:51 up 21 days, 21:21, 57 users, load average: 0.04, 0.16, 0.26
 cat file2
Thu Jun 10 11:10:34 CEST 2007
11:10:51 up 21 days, 21:21, 57 users, load average: 0.04, 0.16, 0.26
String Processing Tools
head
head command display first few line (default : 10
lines) of text in a file
head /tmp/output.txt

Use –n or --lines parameter to change number


of line displayed
head –n 20 /tmp/output.txt

266
String Processing Tools
tail
tail command display last few line (default : 10 lines) of
text in a file
tail /etc/passwd
Use –n or --lines parameter to change number of line
displayed
tail –n 5 /etc/passwd
Use –f to follow the end of a text file as it changes
tail –f 5 make.out
Used to watch log files

267
String Processing Tools
wc
“word count” – also counts lines and characters
wc story.txt
39 237 1901 story.txt
Use –l for only line count
Use –w for only word count
Use –c for only character count

268
String Processing Tools
sort
Sort text to stout –original file unchanged
sort [option] file(s)
Common option:
-r Reverse sort to sort descending
-n Numeric sort
-f Ignore case of characters in strings
-u unique (remove duplicate lines in output)
-t ‘x’ Use x as field separator
-k pos1 sort from field pos1

269
String Processing Tools
sort
$ cat b
fish
dog
animal
bird

$ sort -r b
fish
dog
bird
animal

270
String Processing Tools
sort
Sort numeric file as text
$ cat c
5412 this line should go last
998 this line should go second
50 this line should go first
999 this line should go third

$ sort c
50 this line should go first
5412 this line should go last
998 this line should go second
999 this line should go third

271
String Processing Tools
sort
Sort numeric file as numbers
$ cat c
5412 this line should go last
998 this line should go second
50 this line should go first
999 this line should go third

$ sort -n c
50 this line should go first
998 this line should go second
999 this line should go third
5412 this line should go last

272
String Processing Tools
uniq
Remove successive, duplicate lines in a file
Can use in conjunction with sort to remove all
duplicated (or use sort –u)
Use –c to count number of occurrences of
duplicate data

273
String Processing Tools
uniq
Just sorted: sort | uniq:

$ cat a | sort $ cat a | sort | uniq


bird bird
bird dog
dog fish
dog fly
fish
fish
fly

274
String Processing Tools
cut
Display specific column of file data
cut –f4 result.dat
Common option:
-f Specifies field or column
-d Specifies field delimiter (default is TAB)
cut –f3 –d: /etc/passwd
-c Cuts by characters
cut –c2-5 /usr/share/dict/words

275
String Processing Tools
cut
Example – output second word on each
line:
Delimiter: space “ “
Fields: 2
$ cat a
the quick brown fox
jumped over a quick brown fox
$ cut -f 2 -d ' ' a
quick
over

276
String Processing Tools
cut
Example – output characters 1-3, 5, 7-end
$ cat a
the quick brown fox
jumped over a quick brown fox
$ cut -c 1-3,5,7- a
theqick brown fox
jume over a quick brown fox

Example for student:


cut –f1 -d: /etc/passwd | sort -r | less
277
String Processing Tools
tr
tr command:
 Translates and/or deletes characters from
standard input, writing to standard output
 Takes input only from standard input
 Syntax is tr [options] string1 [string2]
Example:
 tr ‘A-Z’ ‘a-z’ < .bash_profile
This command will translate the uppercase
character in bash_profile to lowercase

278
String Processing Tools
paste
paste - merge line of files
Syntax:Paste file1 file2

Most useful when combining files with


columns of information

279
Version Comparison with
diff
Compares two files for differences
diff area.c /tmp/area.c
33c33
< x = y + 2;
----
> x = y +4;
33c33 indicated line where files differ
< indicates line in first file
> indicates line in second file

280
Formatting a
Document with pr
pr utility program:
 Converts text files into a paginated,
columned version
 If no files specified, pr read standard
input
 By default, pr formats files into single-
column pages of 66 lines
 To print in formatted form—pipe
formatted document to lpr
 Syntax: pr [options] [arguments]

Ch 7 281
Formatting a
Document with pr

282

You might also like