Download unix intro

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

MTS system architecture wikipedia , lookup

Library (computing) wikipedia , lookup

Computer terminal wikipedia , lookup

Acorn MOS wikipedia , lookup

Process management (computing) wikipedia , lookup

Linux adoption wikipedia , lookup

Burroughs MCP wikipedia , lookup

Smallfoot wikipedia , lookup

Caldera OpenLinux wikipedia , lookup

RSTS/E wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Security-focused operating system wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

DNIX wikipedia , lookup

Unix time wikipedia , lookup

History of Unix wikipedia , lookup

Spring (operating system) wikipedia , lookup

Berkeley Software Distribution wikipedia , lookup

Unix wikipedia , lookup

Unix security wikipedia , lookup

Transcript
CEG 333 Introduction To Unix
Todd V. Rovito
Department of Computer Science and
Engineering
Wright State University
Intro to Unix CEG 333
Week 1
Resources used to make slides
• Dr. Travis Doom’s lecture notes CEG 333
Fall 2005.
• http://www.wikipedia.org
• Textbook: “Your Unix: The ultimate guide”
Intro to Unix CEG 333
Week 1
Why Unix?
•
•
•
•
•
For computer scientists by computer scientists
Runs on (nearly) everything
Basis for most modern Operating Systems (OS)
Required by ABIT accreditation board
CS/CEG students should be able to operate
both Windows and Unix
• In preparation for data structures, operating
systems
• Modern day super computers and clusters all
operate on some type of Unix
Intro to Unix CEG 333
Week 1
Why Linux or Open Source?
• David Wheeler has the best paper on Linux
Market Share/Performance/Reliability.
– http://www.dwheeler.com/oss_fs_why.html
– “OSS/FS has significant market share in many
markets, is often the most reliable software, and in
many cases has the best performance. OSS/FS
scales, both in problem size and project size. OSS/FS
software often has far better security, perhaps due to
the possibility of worldwide review. Total cost of
ownership for OSS/FS is often far less than
proprietary software, especially as the number of
platforms increases. These statements are not merely
opinions; these effects can be shown quantitatively,
using a wide variety of measures.
Intro to Unix CEG 333
Week 1
What is an Operating System?
Intro to Unix CEG 333
Week 1
What is an Operating System?
• Do we want all programs to have access to all instructions?
• The OS is a program that acts as an intermediary between the
application programs and the hardware resources
– All communication requires hardware resources, thus the OS is also an
intermediary between users and applications
• The purpose of any OS is to provide an environment in which:
– users can (conveniently) execute programs and access data
– application programs can (efficiently and fairly) access system
resources (processor time, memory, file space, I/O devices, etc.)
• The OS need not perform any other useful function: it is a control
environment (kernel) controls access to all resources
– All other software is an application program
– How does the existence of an OS simplify coding an app?
– Do you trust others to protect your rights and data?
Intro to Unix CEG 333
Week 1
History of Unix
• 1969 (AT&T)
– Ken Thomspon and Dennis Ritchie designed a built a small
system with an elegant file system, a command interpreter, and
set of utilities. To make UNIX portable, they rewrote the entire
system in the C language that was invented by Ritchie.
• Berkeley Unix 3/9/1978
– US law prevented AT&T from selling software so they would give
UNIX away with no support.
– BSD Unix (Berkely Software Distribution) was created to fill in
holes that AT&T left out:
• standard editor (vi),
• C Shell
• Networking Protocol Software TCP/IP
Intro to Unix CEG 333
Week 1
History of Unix
• UNIX gets Fragmented
– Sun Microsystems based Solaris on BSD
– IBM had AIX
– HP offers HP-UX
– DEC produced Digital UNIX -> Tru64 Unix
– And to make things fun we now have
GNU/Linux!
Intro to Unix CEG 333
Week 1
POSIX and the Single Unix
Specification
• At the time that Ritchie invented C no standards existed.
• First AT&T created the System V Interface Definition
(SVID).
• Then other organizations such as the X/Open group
created a standard
– Soon people were concerned about the fragmentation of Unix
standards
• Finally the POSIX (portable operating system interface
for computer environments) was developed (IEEE).
• In 2001 X/Open and IEEE joined together to make the
Single UNIX Specification Version 3 (SUSV3) which
governs most Unix systems.
Intro to Unix CEG 333
Week 1
GNU
• Recursive acronym that stands for “GNU’s Not Unix”.
• Founded by Richard Stallman in 1984.
• Intended to be a complete open/free Unix system.
– free to study the source code, free to modify the behavior of the
software, and free to publish their modified versions of the software
• Contributions include
– gcc (GNU Compiler Collection)
– Emacs
– GPL (General Public License aka copyleft)
Intro to Unix CEG 333
Week 1
GNU
• By the beginning of the 1990s, GNU had produced or
collected nearly all of the necessary components of the
GNU system
– Libraries, Compilers, text editors, Unix-like shell
• Needed the lowest level, the kernel.
• The GNU project began developing their own kernel, the
Hurd, in 1990 (after an abandoned attempt called Trix).
• Their early plan was to adapt the BSD 4.4-Lite kernel
• However, due to a lack of cooperation from the Berkeley
programmers, Stallman decided instead to use the Mach
microkernel, which subsequently proved unexpectedly
difficult, and the Hurd's development proceeded slowly.
Intro to Unix CEG 333
Week 1
Linux
• Linus Torvalds as a undergraduate student
at University of Helsinki in 1991 released
the Linux kernel under the GPL.
• People would combine GNU bash, GNU
gcc, GNU utilities, and Linux to create a
complete Unix operating system. Linux was
the missing piece for the GNU project.
• Stallman insists that all Linux operating
systems should be called GNU/Linux.
Intro to Unix CEG 333
Week 1
Linux Distributions
• The most popular GNU/Linux flavors include
Red Hat, SuSE, Debian, Slackware, and
Mandrake.
• Most distributions are shipped on multiple CDROMS and include lots of free software.
–
–
–
–
Development tools C, C++, Java,
Interpreters perl, Python, TCL
Multimedia software
Internet servers (http, ftp, ssh, game)
• All major computer vendors (except Microsoft)
have committed to support Linux.
Intro to Unix CEG 333
Week 1
Linux Books and Resources
• Just for Fun (book) Torvals and Diamond
– Biography of Linux non-technical
• The Cathedral & The Bazaar (book and internet)
Eric S. Raymond
• Free Software Free Society: (book) Richard
Stallman
• Linuxquestions.org (internet) forum for linux
users
• Tldp.org (The Linux Documentation Project)
(internet) filled with How-To Guides on
everything
Intro to Unix CEG 333
Week 1
Why do we have operating
systems?
• OS interacts with hardware and manages
programs.
• Programs not expected to know which
hardware they will run on.
• Must be possible to change hardware
without changing the programs.
• Programs can’t manage themselves.
• OS provides a safe environment for
programs to run.
Intro to Unix CEG 333
Week 1
How a program runs on a computer
• OS loads program from disk and allocates
memory and CPU.
• Instructions in program are run on CPU and OS
keeps track of last instruction executed.
• If program needs to access the hardware, OS
does the job on its behalf.
• OS saves the state of the program if program
has to leave CPU temporarily.
• OS cleans up memory and registers after
process has completed execution.
Intro to Unix CEG 333
Week 1
Getting Started
•
•
•
•
•
Log in
Editing files with vi, emacs, pico
Printing ( lpr –Pecs_russ1 <filename> )
man (man <command name>)
Warning: EVERYTHING in UNIX is casesensitive!
• Exiting:
–
–
–
–
^D End of data stream; EOF/EOT; exit/logoff
^C Interrupt
Logout Leave the system
Exit Leave the shell
Intro to Unix CEG 333
Week 1
Key Concepts
• Everything in the system is represented as a file.
• Work gets done by processes.
• Workload shared by two separate programs
(kernel and shell).
• Kernel uses system calls to do most of the work.
• All UNIX systems use the same system calls.
• C and UNIX
Intro to Unix CEG 333
Week 1
UNIX Architecture
User
Shell which executes the binary:
-cp, mv, grep, tar, who, ps
Kernel
Hardware
See page 16 of text for another view of UNIX Architecture
Intro to Unix CEG 333
Week 1
UNIX Architecture: The Kernel
•
•
•
•
Program always resides in memory.
Has direct access to the hardware.
Handles file I/O.
Manages processes, memory, and
performs all housekeeping.
• Only one copy shared by all users.
Intro to Unix CEG 333
Week 1
UNIX Architecture: The Shell
• A program or command invoked only when the
user logs in.
– “owned” by user
• Accepts user input, examines and rebuilds the
command line.
• Makes calls to the kernel for all other functions.
• At least one shell is invoked by every user, so a
system may have several different shells running
simultaneously.
• User has a choice of shells.
• Interface between the user and the kernel.
Intro to Unix CEG 333
Week 1
Structure of a command
Command [-option 1] [argument 1] [-option 2] [argument 2] …
e.g. ls –l
• Command filenames need no specific extensions.
• A command’s behavior is determined by its arguments and
options.
• Command and arguments must be separated by whitespace.
• Generally possible to combine multiple options into a single one
(like ls -l -u -t == ls -lut)
• Order of combining is generally not important (like ls -lut == ls utl)
• Case sensitive!
Intro to Unix CEG 333
Week 1
Types of commands
• External program on disk which could be:
– a binary executable (written in C, C++).
– a script file (like a shell or perl script).
• Internal command of the shell which could
be
– a builtin (like cd, pwd, etc.)
– an alias defined by the user that invokes the
disk or internal version in a specific manner.
Intro to Unix CEG 333
Week 1
UNIX identity
• The system identifies you by user and
group numbers (UID and GID)
– Automatically translated by the OS
• Commands of interest
– id, groups, whoami, pwd
Intro to Unix CEG 333
Week 1
Using man
• Displays documentation of commands, configuration
files, system calls and library functions.
• Organized in a number of sections. Commands are
found in Section 1.
• May need to use section number when entry exists in
multiple sections
(e.g. man passwd and man -s 5 passwd).
• man documentation not available for most internal
commands of the shell.
• Use man man first to know how man should be used.
Intro to Unix CEG 333
Week 1
Understanding a man page
Example: wc Syntax/Synopsis
wc [ -c | -m | -C ] [ -lw ] [ file ... ]
• Most useful information available in SYNOPSIS and
DESCRIPTION.
• When options grouped in [ ] without a |, one or more of
them can be used.
(-l, -w and -lw are valid.)
• The | signifies an OR condition. (Only one of -c, -m or -C
can be used.)
• The ... means that multiple occurrences of the preceding
item are possible. (wc can be used with multiple files.)
• EXIT STATUS indicates values returned on error.
Intro to Unix CEG 333
Week 1
File display commands
• Command/Syntax
– What it will do
• cat [options] file
– concatenate (list) a file
• echo [text string]
– echo the text string to stdout
• head [-number] file
– display the first 10 (or number of) lines of a file
• more [options] file
– page through a text file
• tail [options] file
– display the last few lines (or parts) of a file
Intro to Unix CEG 333
Week 1