1 / 21

Why UNIX?

Why UNIX?. Superior Initial Design Multi-user, Multiprogramming, Protected mode, Many Support many Devices Written to optimize the use of memory and maximize efficiency Remained consistent to its original design Not driven by profit motives Source code compatible across platforms

Download Presentation

Why UNIX?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Why UNIX? • Superior Initial Design • Multi-user, Multiprogramming, Protected mode, Many Support many Devices • Written to optimize the use of memory and maximize efficiency • Remained consistent to its original design • Not driven by profit motives • Source code compatible across platforms • Other Operating Systems • IBM MVS: initially designed for a batch punch card environment with proprietary monitors • DOS: initially ran on very single user, limited memory computers. Multiprogramming was added on as an afterthought. UNIX downside: Geared for power users using a command line interface

  2. OS Benchmarks (A bit dated)

  3. Why C • Fast • Designed to produce code nearly as fast as assembly code. • Designed to be able to support Operating System development. • Portable • Recompiling will cause code to work across platforms • POSIX provides a standard OS interface • Powerful: Able to perform low level functions • Small: C code is smaller than other high level languages • Popular: C is a very popular programming language Downside: With power comes danger. You have to know what you are doing Downside: Not object oriented. You have to be disciplined

  4. Language Comparisons • Assembly – small, fast, not portable • C – almost as small and fast, portable • Fortran, Pascal – Slower, specific purpose • C++, PL1 – Complex, larger and slower • Java, Basic – Byte oriented, even slower • Scripting languages – interpreted, slow Memory Use Example Note: JIT technology makes byte code languages more speed competitive

  5. History • 1960s was the era of batch processing • Punch cards, paper tape, Magnetic tape • System operators • Multics attempt at an OS • general purpose, multi user, time sharing • project died: technology of the time could not support the effort • 1969 – AT&T Bell Labs (Ken Thompson) writes first version of Unix in BCPL • 1972 – Dennis Ritchie creates "C", UNIX written in C • 1984 – Richard Stallman starts the free Software Foundation (FSF) with goal to develop a free version of UNIX (GNU – Not Unix) • 1991 – Linus Torvalds writes Linux Kernel (GNU+ Kernel) • 2000 – User Friendly UNIX (Mac OS X) interface • Academia likes UNIX based systems; they are free

  6. "Pigs get fat, Hogs get slaughtered" • AT&T develops UNIX at Bell Labs • Berkeley gets a copy and makes enhancements • AT&T commercializes UNIX and makes it proprietary • Richard Stallman was an AI researcher at MIT • He objected to the trend towards proprietary software. • He formed GNU (GNU's not UNIX) • GNU to replace the UNIX shells and utilities • Berkeley objected to AT&T licenses, and developed BSD • Andrew Tananbaum created Minimal Unix (MINIX) • Linus Torvalds (CS student) coded the Linux kernel • Open source produces lots of high quality software • No open source movement implies no Internet

  7. UNIX Structure • The Kernel is the part of the OS always in memory • Includes • File system • Device manager • memory management • process scheduler • well defined interface • GUI: Point and click (many wrappers to the X-Window interface) • Shells: command line Users GUI's Shells Kernel Hardware

  8. Shells • A command-line interface that allows users to directly access operating system capabilities • There are more than one shells possible in UNIX: csh, bash, tsch, ksh, etc • Text only commands, without using the mouse. “Finger never leaves keyboard.” • Groups of commands can be strung together in unique ways to make difficult tasks possible, without creating specialized programs

  9. sh (bourne shell) small good scripting capability popular with system administrators csh (c-shell) extends sh uses a c-like syntax created by Bill Joy popular with UNIX users bash "bourne-again" shell extends sh with some features form csh The linux default We will use bash tcsh extension of csh Comparison between shells

  10. Where do we find a UNIX • Virtual “Linux” servers provided by IT • Log In (Putty program) creating a secure shell (SSH) with your standard username/password • See a shell prompt (>, &, $, etc.) • Type your command • The shell will execute the command and return with another prompt • Mac/OS provides a UNIX-like system • You can install LINUX on windows systems using a dual boot • You can install CYGWIN on a windows system

  11. The Shell language • Remember • Shell commands are case sensitive • The general form of commands are • Syntax: <cmdName> [-flags] [args] Note: <> indicates something that is required, [] indicates something that is optional Example: >echo –n I love UNIX • > is the shell prompt • echo is a UNIX command • -n is a flag • I love UNIX are three arguments (space separators). • This command outputs the arguments: I love UNIX • The –n inhibits a new line after the output Display prompt  Enter command from command line  execute/process command

  12. Some basic commands >clear clears the screen >who lists the users currently logged in >logout or >exit (Exit is recursive) exit the shell, and wait for another log in >echo whatever I want outputs the data to the right >man <manName> display UNIX manual for the command, manName Note: Use ctrl c to abort commands (abbreviation ^c)

  13. Shell Variables • Example:$<varName> • The shell has some built in variables $TERM represents the terminal type $SHELL represents which shell is active $USER user name $PATH places to look for executables • What do you suppose the following does? >echo I have a $TERM with $SHELL shell • Printenv outputs environment variables, set outputs environment and shell variables Environment variables: those common to all shells

  14. The File System • The file system is a hierarchical tree structure of regular files and directories (folders) • Within the file system, there are individual files for programs and data, and directories that contain other files • Directory Examples • The root directory is / (analogous to c: on Windows) • A users home directory is ~ • /faculty/harveyd/public_html/classes/cs367/ppt Important: File names are case sensitive. Name only with numbers, letters, and underscores. Punctuation characters can conflict with shell commands

  15. Explore Linux (partial directory list) • /root : super user’s home directory • / : system root directory (like Window’s c: ) • /tmp : temporary sharable files available to all users • /bin : executables required for kernel • /sbin : executables requiring super user access • /etc : system configuration files • /var : system changeable files • /opt : optional installs • /home : contains all user’s home directories • /mnt or /media : mount points • /dev : system devices • /boot : contains linux kernel • /usr/bin : applications coming with distribution • /usr/sbin : applications installed later

  16. File Commands >cd Change directory Example using 'absolute' pathnames (cumbersome) /faculty/harveyd/public_html or ~/dir1/dir2/dir3 Example using relative pathnames >cd ~ (go to the users home directory) >cd public_html (public_html directory relative to working directory) >cd .. (change to parent directory above the working directory) >pwd Displays the 'absolute' pathname from the root with '/' separatorsNote: >cd . refers to the current y Note: The shell variable $PWD contains what pwd displays

  17. more/ less and cat commands >cat <filename> Display the contents of the file Problem: too much to display Solution: >more fileName Explanation: more is a program that displays one page at a time and then waits for you to enter a command Explanation: less is an enhancement to more (“less is more”) Note: The man command uses more commands, and displays a page at a time

  18. List contents of a directory • List all files that match the pattern >ls <pattern> … <pattern> • A pattern can be: a combination of letters, asterisks, and question marks. • Asterisks mean any sequence of characters • ? is any single character • Example: *cat?dog* refers to any file name having the word cat separated by one character frm the word dog anywhere in the file name • [abc] means any single character between the brackets (but cannot use / or . characters in the list. • Flags (refer to the man command for a complete list >ls –l lists files in a long format >ls –a lists all files including hidden ones (starting with a period) >ls –alorls –a –l lists files combining the flags man <anycommand> gives information how to use it

  19. File links • Hard link (ln myFilemyLink) • Points directory to the file’s data • We can delete either the file or the link • The actual data is removed when the last link is removed • It is illegal to link to directories • Symbolic links (ln –s myfilemySymbolicLink) • References file’s directory entry by name • myfile does not even need to exist (link broken) • Deleting a link, never deletes the file • Equivalent to Windows shortcuts • Circular links cause errors when access is attempted

  20. Additional Commands • Rename file: >mv <oldName> <newName> • Copy file: >cp <file> .. <file> <destination> • Secure copy to remote computer: • scp <file>...<file><destination • Example: scp cat.c harveyd@sou.edu:drop • Delete file: >rm <file> .. <file> • Make a directory: >mkdir <directory> • Execute allowed as superuser: >sudo command • Which version of a command: >which <command> • Type of command :>type <command> • Who’s logged in: >whoami • Detailed documentation: >man <command> • Brief description: >whatis <command> • Description of shell built-in commands: info <command> Note: Most commands have many flags. For example –r is often used to access all subdirectories (ex: rm –r <dir>

  21. More on flags • cp –vfirl or rm –rifv --help • Note that we can string multiple flags together • v = verbose, f = force, i = interactive, r = recursive, l = link instead of copy • Most also have long english type versions preceded by double dashes. For example: cp –recursive • ls –dlaRr • d = directory (not contents), l = long form, a = all files, R = recursive, r = reverse order • mkdir –p (create parent directories if not found) • man –k term (same as apropos) to find all entries related to term

More Related