Download presentation
1
Introduction to UNIX CS208
2
What is UNIX? UNIX is an Operating System (OS).
An operating system is a control program that allocates the computer's resources, schedules tasks, and helps the user communicate with the computer. Most popular PC operating systems: Windows 95/98/2000/XP -- proprietary, single-user OS UNIX was developed long before Windows, about 30 years ago at AT&T Bell Labs (95% written in “C” programming language).
3
UNIX Compared with other OS
Mature and stable OS Large user community Vendor-independent OS Network-portable window system (X) Runs on range of hardware (PC - Cray) Common Open System Environment (COSE) Source code is available to view and modify
4
Multi-user, Multi-tasking
More than one user can run at the same time and each user can run more than one task at the same time In Unix, each program is started as a process. A process is a program in execution. Usually only one copy of a program, but there may be many processes running the same program. Each interactive user may have: only one process in foreground may have several processes in background
5
Most Important Feature of UNIX
Most important feature of UNIX: STABILITY 30 years to get the bugs out Important in shared environments and critical applications Shared Environments Example: University Windows NT crashes at least once a day in labs UNIX servers crash about once a semester (usually due to hard disk failure) UNIX more than 100 times more reliable than Windows!
6
UNIX Versions Two main types of UNIX:
BSD (Berkeley Software Distribution)/OSF System V (developed at AT&T) Different versions of UNIX for different hardware: Sun Microsystem’s Solaris (and SunOS) Hewlett-Packard’s HP-UX IBM’s AIX SGI’s IRIX
7
Unix Operating System Structure
OS mediates between the user and the computer User Application Programs Kernel Shell Shell - Whenever you log in,you get placed in a program called a shell. You can see the shell prompt. Enter commands at the prompt. Shell acts as a command interpreter, taking commands and passing them on to the kernel. Kernel: At the core of the Unix system, loaded whenever the system is started up (booted). Manages computer resources (memory, processes, file system) manages memory and allocates it to each process schedules work done by the CPU organizes transfer of data from one part of machine to another accepts instructions from shell and carries them out enforces access permission on the file system Hardware
8
Why has Unix been successful?
UNIX is portable, because it was written in C. Provides hardware independence. Open System Underlying operating system source code is available Provides a productive environment Allows multi-tasking and sharing of data Excellent C development environment is built-in Networking capabilities are built in
9
Unix Disadvantages UNIX is not as user-friendly as some operating systems Command names are often cryptic User help is not great UNIX does not error check user commands to protect users from hurting themselves or the system Example: Request to copy a file over an existing file will overwrite the existing file with no warning.
10
Unix Disadvantages UNIX is less secure than some operating systems
Developed to be used as a software development environment, in which all users are working together cooperatively. Security was traded for more convenience and flexibility. Well-documented open code makes hacking easier. UNIX's portability also makes it less efficient on any particular hardware. Proprietary operating systems are optimized for that hardware.
11
Basic UNIX Commands
12
The Unix Prompt After you log in, and the startup files have been run, the shell will display a prompt $ Different shells and different systems have different prompts. Two common prompts are $ and #. Your prompt can be changed. A prompt (plus a cursor) tells you that the system is ready for your commands. F 1-7 PD 1-7
13
Standard Command Format
Format: command [options] <arguments> stuff in brackets is optional boldface words are literals (must be typed as is) <> enclosed words are args (replace appropriately) Commands are case sensitive (mostly lowercase) Spaces must be inserted between commands, options, arguments
14
Standard Command Format
Options (also called flags) modify how the command works (command behavior) single letters prefixed with a dash “-” combined or separated (e.g., -al = -a -l) come before arguments Arguments define the command scope Optional for some commands, mandatory for others Some commands assume a default argument if none is supplied Usually files or directories
15
Basic Commands date - Print the date and time
Wed Feb 3 12:13:07 MDT 2003 $ echo - Display command line input to screen $ echo Hi, I am your instructor! Hi, I am your instructor!
16
Commands to Manipulate Files
ls lists files in a directory (names, not the contents of files) cat, head, tail, more display files rm removes files (and directories) cp copies files (and directories) mv moves (renames) files (and directories)
17
List Files in a Directory
Format: ls [-alRF…] <file-list> -a list all files including the dot files -l long format (show file type, permissions, #links, owner, etc) -R recursive list subdirectories -F list directories with file type (trailing / *)
18
Listing Files in a Directory
BLOCK SIZE # DIRECTORIES FILE SIZE GROUP 1 drwxr-xr-x 180 root admin Oct 1 ../ 2 -rw-r--r smith fac Oct 3 file PERMISSIONS MODIFY DATE FILE TYPE FILE NAME OWNER Permission settings will be covered in a later section. For now just remember that Unix is multi-user, and with any multi-user system you need security to prevent one person from changing another person’s file space.
19
Getting Help Check the manual pages! Format: man <command>
For shell command, system programs, and library functions. Format: man <command> man –k <keywords> Man(ual) page format Name Synopsis Description (options, defaults, detail desc., examples) Files See Also Bugs
20
man Examples $ man man Displays help on the man command $ man who
Displays help on the who command $ man -k mail Checks all man pages for keyword “mail”
21
man Output Example spacebar - move forward one page
$ man ls Reformatting page. Wait... done User Commands ls(1) NAME ls - list contents of directory SYNOPSIS /usr/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file... ] /usr/xpg4/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file... ] --More--(11%) spacebar - move forward one page b – move back one page h – more commands q – quit
22
Viewing Files cat concatonate and print to screen (ctrl-s and ctrl-q to stop/start) head display first x lines of file tail display last x lines of file (both default to 10 lines) more display part of file to screen
23
Example: cat, head, tail $ cat letter Mr. Jones,
It is getting late. Please order some pizza and stop by my office. We’ll tidy up a few more things before calling it a night. Thanks! Ben $ head –2 letter $ tail –1 letter
24
Copying Files Format: cp [-ir…] file1 file2
cp [-ir…] file-list directory cp [-ir…] directory directory i for interactive. Prompt whenever a file will be overwritten. r for recursive. copy a whole directory tree.
25
cp Examples $ ls letter1 secret $ cp letter1 letter2 $ ls -F
letter1 letter2 secret/ $ cp letter1 letter2 secret $ ls secret letter1 letter2
26
Moving /Renaming Files
Format: mv [-i…] file1 file2 - Renames file1 to file2 mv [-i…] file-list directory - Moves files from current location to new directory mv [-i…] directory directory - Renames a directory
27
mv Examples $ ls letter memo saved $ mv memo memo1 $ ls -F
$ mv saved trash letter memo1 trash/
28
Deleting Files Format: rm file-list - Deletes files rm -r directory
- Deletes directory and all files and directories within it - Use with CAUTION!
29
rm Examples $ ls -F letter1 letter2 secret/ $ rm letter1
$ ls –F secret memo morestuff/ $ rm –r secret $ ls letter2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.