UNIX Tools G22.2245

Download Report

Transcript UNIX Tools G22.2245

UNIX Tools
G22.2245-001, Fall 2000
Danielle S. Lahmani
email: [email protected]
Lecture 1
2000 copyright Danielle S. Lahmani
Texts
• Required Texts:
– The UNIX operating System, 3rd edition, by
Christian and Richter, Wiley Professional
Series
– Learning Pearl, 2nd Edition, by Pearl and
Christiansen
2000 copyright Danielle S. Lahmani
Recommended Texts
• 1. UNIX in a Nutshell, Gilly, O'Reilly,
– ISBN 1-56592-001-5
• 2. The UNIX Programming Environment, Kernighan,
Pike, Prentice Hall Software Series, 1984,
– ISBN 0-13-937681-X
• 3. The New Kornshell Command and Programming
Language, Bolsky , Korn , Prenctice Hall, 1995,
– ISBN 0-13-182700-6
2000 copyright Danielle S. Lahmani
Recommended Texts (Cont’)
• 4. The UNIX C Shell Field Guide, Anderson and
Anderson, Prentice Hall, 1986, ISBN 0-13-937468-X
2000 copyright Danielle S. Lahmani
Course Administration
• Assignments
– 4 homework sets
– 1 exam
– 1 project (groups of 2 people), deliverables
discussed in lecture 2.
2000 copyright Danielle S. Lahmani
Computer accounts
• Students in need of Sun accounts, please
send email to [email protected] and
specify :
– name,
– student id number,
– and CS graduate course number(s) registered.
• Status of accounts will be posted outside
room 424 WWH.
2000 copyright Danielle S. Lahmani
Course Mailing List
• Please subscribe to the course mailing list.
To do so, register at
http://www.cs.nyu.edu/mailman/listinfo/g22_
2245_001_fl00
• To multicast an email to the class, email to
[email protected].
2000 copyright Danielle S. Lahmani
Course Materials
• Please check regularly course home page:
http://cs.nyu.edu/courses/fall00/G22.2245001/index.htm
• Course syllabus, for reading, homework and
project assignments:
http://cs.nyu.edu/courses/fall00/G22.2245001/syllabus.html
2000 copyright Danielle S. Lahmani
Homework Policies
• Due Date:
• 2 weeks after date given, before class starts.
• email to assigned TA.
• Penalty
• no late homeworks will be accepted.
• cheating: zero, and F on course on next occurrence
• Goal:
• homeworks corrected and answers posted within 2
weeks.
2000 copyright Danielle S. Lahmani
Course Overview
• Fundamentals of the Unix Operating
System.
• The UNIX file system
• The UNIX process management.
• The UNIX shells: (Korn and C shells), shell
programming and shell scripts
2000 copyright Danielle S. Lahmani
Course Overview (Continued)
• Filters and utilities: find, grep, awk, sed
and others.
• PERL programming language.
• Backup utilities: tar, cpio and others.
• Development Tools: Make, sccs, etc...
2000 copyright Danielle S. Lahmani
Course Overview (Continued)
• System management utilities: fsck, mount,
df, dd, cron, etc.
• Networking utilities: rlogin, telnet, ftp, ssh,
NFS
• Security and System backup,
• Performance tools and system tuning.
• Overview of the UNIX kernel.
2000 copyright Danielle S. Lahmani
What is UNIX?
“Unix is a general-purpose, multi-
user,interactive, operating system”
Dennis Ritchie
2000 copyright Danielle S. Lahmani
Unix Features
• Hierarchical file system for information
management
• compatible file, device, and inter-process
I/O
• system command language selectable on a
per-user basis (shell)
• over 100 subsystems (utilities)
2000 copyright Danielle S. Lahmani
Unix Features (continued)
• Support for creation/modification of
processes and files
• communication between processes and
peripherals on same/different machines
• high degree of portability, available on a
wide range of platforms
2000 copyright Danielle S. Lahmani
UNIX Innovations
• high degree of portability
• pipe: connection between the output of one
program to the input of a second program
• concept of a software tool: program that
addresses a single function.
• Shell: command line interface that is also a
programming language
• modularity
2000 copyright Danielle S. Lahmani
Unix Success
•
•
•
•
•
•
•
•
over 50 Million Users today
open source code
cooperative tools and utilities
multi-user and multi-tasking abilities
excellent networking environment
portability: written in C
modularity and empowerment
rich set of APIs for programmers
2000 copyright Danielle S. Lahmani
Unix System Structure
user
shell and utilities
kernel
hardware
2000 copyright Danielle S. Lahmani
Unix Philosophy
• Provide small tools that when combined
together, (via pipes), provide a whole
environment.
• different from integrated environment such
as MAC and Windows
2000 copyright Danielle S. Lahmani
Unix Operating System
Environment
• More command driven and less graphical
than Mac or Windows
• Multiple commands dominate the screen
• Many applications run at the same time
• X Window System provides graphics
2000 copyright Danielle S. Lahmani
Unix History: The Early Years
• Brian Kernighan, called it Unics as a pun
on the name Multics.
• 1969: first developed in Assembly by Ken
Thompson,
• 1973: rewritten in C by Ken Thompson and
Dennis Ritchie
• 1974: licensed to Universities for
educational purposes
2000 copyright Danielle S. Lahmani
Unix History
1980s
• UNIX is workhorse for high-tech
applications
• Sun introduces the personal workstation,
with graphics and networking running
UNIX
• many UNIX factions
2000 copyright Danielle S. Lahmani
Unix History: 1990s and beyond
• Many factions merge
• Unix is mainstream
• Internet explosion leads to exponential
growth
• LINUX
2000 copyright Danielle S. Lahmani
Popular Variants of Unix
• SCO UnixWare
– based on SVR4.2MP, support for large files
– B2 security hooks
• Sun Solaris
– based on SVR4, network centric, support SPARC , intel
32-bit and 64-bit architectures
• HP-UX
– 64-bit support
• LINUX: free version, leading market share
2000 copyright Danielle S. Lahmani
Differences between Unix and
Windows NT
UNIX System V
–
–
–
–
Windows NT
multi-tasking
multi-user
POSIX compliant
> 4MB memory
– process driven OS
– open source
– multi-tasking
– single user
– not fully POSIX
compliant
– > 12 MB memory
– event driven OS
– not an open source
2000 copyright Danielle S. Lahmani
The LINUX operating system
• 1991, Linus Torvalds initial development of
Linux
• today, lion share of UNIX market
• free of charge
• IBM to use Linux in Internet Software
( New York Times 1/10/2000)
2000 copyright Danielle S. Lahmani
The UNIX File System
• Unix Treatment of files
– a file is a sequence of bytes
– no structure imposed by the system
– system file types:
• regular file
• directories:provides mapping between names and
files themselves
• special files: used for peripherals or devices
2000 copyright Danielle S. Lahmani
UNIX file system Definitions
• Hierarchical file system
– rooted tree composed of files and directories
• Unix File system characteristics:
–
–
–
–
–
–
hierarchical
consistent treatment of file data
ability to create/delete files
dynamic growth of files
protection of file data
treatment of peripheral devices as files
2000 copyright Danielle S. Lahmani
Unix File System Definitions
• filename:
– sequence of characters other than slash
• pathname:
– sequence of directory names followed by a
simple filename, each separated from the
previous one by a /
2000 copyright Danielle S. Lahmani
UNIX file system naming
Conventions
• Absolute pathname
– pathname begin with /, search of file begins at
the root of the entire tree
• Relative pathname
– pathname does not begin with /.
– Search of file begins at process’s current
working directory.
2000 copyright Danielle S. Lahmani
UNIX file system naming
shorthand
.
..
Generic name of current dir
Generic name of parent of current dir
2000 copyright Danielle S. Lahmani
Sample File Tree
/
tmp
usr
foo
dmr
wm4
.profile
2000 copyright Danielle S. Lahmani
etc
bin
who
date
Where are important files?
•
•
•
•
•
•
•
•
•
/bin /usr/bin
/dev
/etc
/lib, /usr/lib
/tmp
/usr, /var
/home /users
/usr/include
/usr/man
Unix cmds (read as binary)
files for peripherals.
admin files
libraries for C, C++ programmers
temporary files
prog files and user files
users’s home dir
include files for C, C++ prog
online manual pages
2000 copyright Danielle S. Lahmani
File Attributes
•
•
•
•
•
Stored in the file I-node
File’s ownership: user and group
file permissions: read, write, execute
file modification times
file type: regular, directory, link, symbolic
link, special file
2000 copyright Danielle S. Lahmani
Utilities for Manipulating file
attributes
•
•
•
•
chmod
change file permissions
chown
change file owner
chgrp
change file group
only owner or super-user can change file
attributes
• upon creation, default permissions given to
file modified by process umask value
2000 copyright Danielle S. Lahmani
File Permissions
• Three types of permissions:
• read, process may read contents of file
• write, process may write contents of file
• execute, process may execute file
• three sets of permisions:
• permissions for owner
• permissions for group
• permissions for other
• access checks made against process’s
effective ids
2000 copyright Danielle S. Lahmani
Chmod command
• Symbolic access modes
• example: chmod +r file
• Octal access modes
octal
read
write
execute
0
1
2
3
4
5
6
7
no
no
no
no
yes
yes
yes
yes
no
no
yes
yes
no
no
yes
yes
no
yes
no
yes
no
yes
no
yes
2000 copyright Danielle S. Lahmani
Directory permissions
• Same types and sets of permissions as for
files
– read: means process may a read a dir (i.e., list
files)
– write: process add/rm files in dir
– execute: process can “search”, access files, in
dir or subdir
2000 copyright Danielle S. Lahmani
Common Utilities for Managing files and
directories
•
•
•
•
•
•
•
•
•
•
pwd
cat, ed, vi, emacs…
ls
rm
mv
cp
ln
mkdir and rmdir
lp:
wc
print process current dir
create files
list contents of directory
remove file
rename file
copy a file
create a hard link to a file
create and remove dir
print a file
counts the words in a file
2000 copyright Danielle S. Lahmani
Getting Help on UNIX
• man/xman: display entries from UNIX
online documentation
• whatis, apropos
• Manual entries organization:
–
–
–
–
–
–
1. Commands
2. System calls
3. Subroutines
4. Special files
5. File format and conventions
6 Games
2000 copyright Danielle S. Lahmani