Transcript Ch01_new
PRIME VIEW, INC.
1
History, a brief overview
•
•
•
•
•
•
written by Ken Thompson and Dennis Ritchie (Turing Award 1983)
developed at Bell Laboratories, USA, derived from multics (1969)
Thompson developed a new programming language 'B'
Ritchie enhanced 'B' to 'C' and helped develop 'UNIX'
Two flavors,
SYSTEM V (Commercial, run by AT&T) and
BSD (Educational, run by Bell Labs)
Recent developments are graphical interfaces, MOTIF, X Windows, Open View
A free UNIX system called LINUX is also available for download from the Internet or
available on CD-ROM. More of UNIX history - see appendix.
PRIME VIEW, INC.
2
What is UNIX
UNIX is a multi-user multi-tasking multi-threaded highly portable time-sharing
networked operating system utilizing shared memory. The job of an operating system is
to orchestrate the various parts of the computer -- the processor, the on-board memory, the
disk drives, keyboards, video monitors, to perform useful tasks.
Main features:
• multi-user
more than one user can use the machine at a time
supported via terminals (serial or network connection)
• multi-tasking, more than one program can be run at a time
• hierarchical directory structure, to support the organisation and maintenance of files
• portability
only the kernel ( <10%) written in assembler. This meant the operating system
could be easily converted to run on different hardware platforms ranging from
PCs and Macs to Cray supercomputers
• tools for program development, a wide range of support tools (debuggers, compilers)
The philosophy behind the design of UNIX was to provide simple, yet powerful utilities
that could be pieced together in a flexible manner to perform a wide variety of tasks. The
UNIX operating system comprises three parts: The kernel, the shell and the standard
utility programs, and the system configuration files.
PRIME VIEW, INC.
3
Kernel
schedules programs
manages data/file access and storage
enforces security mechanisms
performs all hardware access
Today you can find several flavors of the UNIX operating system (also known as the "kernel").
AT&T's original version evolved into System V (pronounced "system five").
The version that AT&T licensed to the University of California at Berkeley is called BSD (Berkeley
Software Distribution). It is now the de facto standard in the academic community, (i.e., it's free).
Other versions are also available from commercial vendors: Sun's Solaris, SCO and Microsoft's
XENIX, IBM's AIX, DEC's ULTRIX, Apple's A/UX, and the free Intel-based Linux. Kernel
executable file is usually named unix (System V origin) or vmunix (BSD origin).
Configuration files
The system configuration files are read by the kernel, and some of the standard utilities. The UNIX
kernel and the utilities are flexible programs, and certain aspects of their behavior can be controlled
by changing the standard configuration files. One example of a system configuration file is the
filesystem table "fstab" , which tells the kernel where to find all the files on the disk drives.
PRIME VIEW, INC.
4
Shell
Users rarely use UNIX directly, however. The utility
software that interprets a user's commands for the
kernel is called the shell. Here too, there are several
flavors.
The original and most common shell is the Bourne
shell (its prompt is the "$").
The C shell ("%" or "") is newer and provides an
extensive command language similar to the C
programming language.
The Korn shell (also "$") attempts to combine the best
of both earlier shells.
More than one shell is often available to users on a
UNIX system.
Utilities
file management (rm, cat, ls, rmdir, mkdir)
user management (passwd, chmod, chgrp)
process management (kill, ps)
printing (lp, troff, lpr)
program development tools
PRIME VIEW, INC.
5
Summary of Basic DOS Commands
help | more
displays all commands available to user.
dir
lists names of files and subdirectories in a directory.
cd
displays the name or changes current directory
mkdir
creates a directory
del
deletes one or more files
copy
copies one or more files to another directory
rmdir
deletes a directory
move
moves files and renames files and directories
time
date
displays or sets the time
displays or sets the date
echo
displays messages or turns command-echoing on/off
exit
quits the program or command interpreter
PRIME VIEW, INC.
6
Logging In
There are three main ways to connect to UNIX machine (node)
- direct terminal connection
- network terminal connection using dumb or X-terminal
- network terminal connection using a “smart” terminal (PC)
Terminal Emulator - a program running on your PC and representing it to UNIX server
as a terminal of known type. In our case we have NT application called “Reflections”
Once you are connected, UNIX will prompt you for your login name. Type your unique
userid (student1, student2, student3,... student0) assigned to you. At the password
prompt, type your password - all users have the same password: "nyc123". (Your
password will not be printed on the screen.)
Try different types of connection:
- telnet (windows standard tool in accessories)
- Reflection/telnet
- telnet from unix prompt
- ftp
Use "ps" command and "who" command to find out about connections.
PRIME VIEW, INC.
7
Setting Passwords
If you are using a temporary password, you should change it immediately. It is also a good
idea to change your password periodically. Unlike your login name which may be known
by many people, only you should know your password. Make your password 6 to 8
characters long. Make it hard to break by combining capital letters, lowercase letters, and
punctuation. Avoid using family names, pet names, words found in dictionaries, birth
dates, anniversary dates, and obvious numbers (drivers license, license plate, phone). Do
not use common words, even if you add a number to the password (e.g., Gandalf, red3,
scottX, etc.).
Changing Your Password
To change your password, type: passwd. UNIX will prompt you for your old password, then your
new password. UNIX will then ask you to retype the new password to confirm it. Once you've
confirmed it, your new password will be in effect. Use it the next time you log in.
PRIME VIEW, INC.
8
Summary of Basic UNIX Commands
Below is a reference list of the UNIX commands you will use most often and that are necessary for a
basic use of UNIX.
command -flag(s) argument(s)
man (manual)
man command
man -k keyword
displays help or manual documentation.
displays manual information for the specified command
displays 1 line synopsis of each manual
section referring to the keyword
ls (list)
ls
ls -l
ls -al
provides a directory listing.
lists a directory in columns
gives a fuller listing including file permissions,
size, date created
similar to the above but includes "dot"/hidden files
cd
cd
cd
cd
cd
returns you to the home directory
moves up one directory level
moves up two directory levels
moves to named subdirectory
(change directory)
..
../..
subdirectory
mkdir (make directory)
mkdir subdirectory
creates a directory within the current directory
PRIME VIEW, INC.
9
rm (remove)
rm filename
rm -i filename
rm
rm -r
cp
cp
cp
cp
(copy)
file1 file2
file1 directory
file1 file2 directory
rmdir (remove directory)
rmdir dir1
mv
mv
mv
mv
mv
(move)
file1 newname
directory newname
file1 directory
file1 directory/newname
deletes files*
deletes the named file
deletes named file after prompting to make
sure you wish to remove it
deletes (removes) files
recursive remove, can delete files and
directories
copies file1 to file 2
copies file 1 to named directory
copies file1 and file2 to named directory
deletes directory within the current
directory (if directory is empty)
moves or renames one or more files.
renames file1
renames directory
moves file to named directory
moves file1 to named directory and renames
*BE EXTREMELY CAREFUL with rm and never use rm* ! there is no undelete command!
PRIME VIEW, INC.
10
date
displays date and time.
echo
prints its arguments on the screen.
passwd
changes login password.
PRIME VIEW, INC.
11
Exercises with UNIX Commands
1.
Try to get help on the following commands:
pwd, ls, cd, cat, cp, mv, echo, ps, who
2.
3.
4.
5.
Make a new directory called “projects”
Run “ls” to confirm your directory was created
Run “ls –l” to view long view of your directory
Find out which other “flags”, if any, are available with the “ls” command and
try to run them.
6.
7.
Run the “pwd” command.
Run “cd projects” and run the “pwd” command again. What is the change?
8.
9.
10.
11.
12.
13.
14.
Create a new subdirectory called “logs”.
Run “cd logs”.
Run “ls -l; pwd”.
Run “cd ..”
Run “pwd”
Run “cd”
Run “pwd”
PRIME VIEW, INC.
12
15. Go back to your “logs” directory.
16. Run “who” command.
17. Place the contents of the “who” command into a file called “users.log” by running
“who > users.log”
18. Using command “wc” count number of words in “users.log”
19. Get help on the “type” command.
20. Run “type users.log” to view the contents.
21. Create another file called “myfiles.log” using one of the commands you already
know. (use “ls” or one of its forms)
22. View the contents of the “myfiles.log”
23. Go back to your “projects” directory.
24. Try to view your log files from the “projects” directory without having to change
directories.
25. Try to rename and delete one of the files.
26. Try to copy one of the files to the local directory. (you may need to find out what
is the current working directory with command “pwd”).
27. Copy “logs” directory into “archives” directory, (you may need to create the
directory first).
28. Try to remove the “logs” directory without having to delete its contents.
29. Copy all files from the “archives” directory into your working directory in one
shot.
30. Use man pages to get information on “-p” flag of the “mkdir” command. Try it.
PRIME VIEW, INC.
13
Useful links for this course.
History:
http://www.paralogos.com/DeadSuper/
http://www.computer50.org/mark1/photogallery.html
http://perso.wanadoo.fr/levenez/unix/
UNIX:
http://www.arch.su.edu.au/~doug/Unixhelp/DOStoUNIX_.html == DOS to UNIX, basic commands
http://www.itknowledge.com/reference/standard/0672315238/ewtoc.html == Sam's UNIX in 10 min.
http://www.isu.edu/departments/comcom/unix/workshop/unixindex.html - Idaho State Univ. Tutorial
http://wks.uts.ohio-state.edu/unix_course/ Ohio Univ. Course; book and slides
http://theory.uwinnipeg.ca/UNIXhelp/ == UNIXhelp from Univercity of Edinburg (can DOWNLOAD)
http://www.ugu.com/ == UNIX Guru Universe
http://www.ugu.com/sui/ugu/show?help.beginners -- Start here, check "Basics", "Fundamentals"
http://riceinfo.rice.edu/Computer/Documents/Unix/unix1.01.pdf -- Get reference card
http://riceinfo.rice.edu/Computer/Documents/Unix/unix1.pdf -- Get nicely formatted doc on basics
http://riceinfo.rice.edu/Computer/Documents/Unix/unix18.pdf -- UNIX scripts (csh, sh 15 pages each)
http://goforit.unk.edu/unix/part1_0.htm -- Learning UNIX by Brian Brown (Advanced): Acessments, Notes, TESTS)
http://www.usenix.org/sage/sysadmins/sysadmins.html -- Sysadmins site
http://www.uwsg.indiana.edu/usail/ -- Basic UNIX Tutorial used by many univercities (14 chapters)
http://www.oase-shareware.org/shell/index.html --- SHELLdorado = Scripts, scripts, scripts.
http://www.unixguide.net/ -- UnixGuide
http://www.elementkjournals.com/sun/ -- Inside Solaris
Free Shell access:
http://www.shellyeah.org
PRIME VIEW, INC.
14