870 likes | 996 Views
Week-1. 1/11/2005. Topics. Unix Introduction Logging In / Logging Out Unix Commands – man, date, cal, who Unix File System Introduction to vi. Operating System. Software program that “runs” (“executes”) on a computer The most important program on the computer
E N D
Week-1 1/11/2005
Topics • Unix Introduction • Logging In / Logging Out • Unix Commands – man, date, cal, who • Unix File System • Introduction to vi
Operating System • Software program that “runs” (“executes”) on a computer • The most important program on the computer • Enables you to store information, process raw data, use application software, access all hardware etc
PC Operating Systems • A personal computer system or PC is usually a standalone machine, such as a desktop or laptop computer • A PC operating system conducts all the input, output, processing, and storage operations on a single computer
Mainframe Operating Systems • A mainframe operating system controls a mainframe system, a large computer system with multiple processors that conducts input, output, processing, and storage operations for many users • Historically, mainframe systems have been popular in large corporations and industrial computing
Network Operating Systems • A computer network combines the convenience and familiarity of the personal computer with the processing power of the mainframe • A network lets multiple users share computer resources and files • A network operating system controls the operations of a server computer, sometimes called a host computer, which accepts requests from user programs running on other machines, called clients
Unix – a network OS • Multi-user, multi-tasking OS with built-in “networking” functions • Multi-user – More than one user can access/use the computer at the same time. • Multi-tasking – More than one application/program executes on the computer at the same time.
Unix (contd.) • Unix can be used as • Dedicated server in a server-based network • Client computer in a server-based network • Client/Server computer in a peer-to-peer network. • Stand-alone workstation (not connected to any network)
Unix (contd.) • Unix is a portable Operating system – used on a variety of computers (hardware).
Networking Features of Unix • File Transfer Protocols (ftp) • Telnet (remote terminal emulation program) • Mail • Remote access
Unix History • Developed originally at Bell Labs – early 70s • Originally 2 flavors: • AT&T System V • UC Berkeley’s BSD • Currently numerous flavors: • HP-Ux, IBM-Aix, Sun-Solaris, SG-Irix
LINUX • A flavor of Unix that executes on Intel processors • Free • Developed by Linus Torvalds in Finland (1991) • Offers all features of an Unix OS on the PC
Accessing a Unix System • Unix is multi-user: supports multiple users • Every user is identified by an unique username and a password • To access a Unix system, you must have a valid username and password
Usernames • Usually all lowercase • 6-15 characters long • No special characters allowed (spaces, control characters, *, symbols) • Must be unique on the system • Assigned by the System Administrator – cannot be changed by user
Passwords • 6-24 characters long • Initially assigned by System Administrator • Can be changed by user (if allowed) • Not echoed on screen • Can be reset by the System Administrator to a new password
Lab Access • Username: acestudentN • Password: unixuserN
Unix Shell • Unix program that INTERPRETS the COMMANDS entered from the keyboard • Everything you type is a “command” • A “command” is a program that executes on the computer • Shell is a command-interpreter interprets your commands for the Operating system
Types of Shells • Bourne Shell – developed by Steve Bourne at AT&T (sh) • Korn Shell (ksh) more user-friendly than sh • C Shell (csh) same syntax as C programming language • Bash Shell – available with Linux • tcsh, zsh
Choosing a Shell • The user’s shell is assigned by the System Administrator during the creation of the user’s account. • Can be changed by the user – by just typing the name of the new shell e.g. to change to Korn shell, type ksh • Type exit to revert to previous shell
Terminology • Operating System • Shell • Command-line • Prompt
Entering Commands • Everything typed on the command-line is treated as a Unix command. • The command is NOT interpreted until you press the “Return” or “Enter” key • Unix is case-sensitive. • All Unix commands are lower-case • Unix comes with a set of pre-defined commands
date • Displays the system date and time • At the prompt, type date and press enter • Sequence • The shell interprets the command • the OS executes the program for that command • the output is displayed on the screen • the shell waits for the next command
cal • Displays the calendar for the current month • At the prompt, type cal and press enter
who • Displays the list of users currently logged into the system • At the prompt, type who and press enter
Multiple Commands • More than one command can be typed on the same command-line – the commands must be separated by a semi-colon (;) • Commands are executed in sequence: Left to Right • $ who;cal<Enter> • $ cal;date<Enter> • $who;cal;date<Enter>
Unix Commands and Options • Every command has a specific syntax. • cal is different from Cal, caL, CAL … etc • A command can be followed by “an option” to change the behavior of the command • Options are prefixed with a hyphen (-)
cal - revisited • $ cal -y
Command arguments • Some commands also accept “arguments” to be able to operate successfully • E.g. A command that displays a file needs the name of the file as an argument. • A command that deletes a file needs the name of the file as an argument
cal - revisited • The cal command can also display the calendar for a specified month and year • The cal command can take 2 numbers as arguments • 1st argument: Month (any number from 1 to 12) • 2nd argument: Year (any number from 1 to 9999)
cal (contd.) $ cal 10 2000<Enter> Displays the calendar for Oct 2000 $ cal 11 1999<Enter> Displays the calendar for November 1999
man • The man command displays information about other Unix commands. • Displays the manual pages of the command • Takes the command name as the argument • e.g. $ man cal<Enter> Displays information about the cal command • Similar to on-line Help in windows • Type :q to exit
Output of the man command • Name: - the name of the command and a short statement describing its purpose • Synopsis- a syntax diagram showing the usage of the command • Description – a more detailed description than the name item above • Options – a list of options and their purposes • See Also: other commands or man pages that provide related information • Bugs: a list of the command’s known bugs
man - examples $ man date $ man man
whatis • The whatis command displays brief information about other commands • e.g. $ whatis cal $ whatis date
passwd • The passwd command is used to change the user’s password • Syntax: passwd • Will prompt for new password twice • New password is not echoed on the screen • New password must differ from old password by at-least 3 characters
Logging out of Unix Shell • Korn/Bourne/Bash shells: type exit or Ctrl-D • C Shell type logout
Output Redirection • The output of any Unix command can be “redirected” using the redirection operators > and >> • > is used to redirect the output in the “over-write” mode • >> is used to redirect the output in the “append” mode
Redirection • Output of a command can be redirected to a file using the > operator • Original contents of the file are lost. • e.g. $ who > list_of _users
Redirection (contd.) • Output of a command can be appended to a file using the >> operator – original contents of the file are retained. • e.g. $ who > list_of_users $ date >> list_of_users
Output Redirection (contd.) • e.g. $ man cal > cal_manual.txt • $ man date > date_manual.txt • $ cal 1999 > calendar_1999.txt • $ cal 2020 > calendar_2020.txt • $ cal 2000 > calendar_2000_2002.txt • $ cal 2001 >> calendar_2000_2002.txt • $ cal 2002 >> calendar_2000_2002.txt
Viewing a file • cat – concatenate and display file • Syntax: cat filename … • Displays contents of file(s) • e.g. $ cat list_of_users
Lab Exercise • Create a file called cal_man.txt containing the man pages for the cal command • Add the current date and time to the file cal_man.txt man cal > cal_man.txt date >> cal_man.txt
Lab Exercise • Create a file called date_cal.txt containing the outputs the date and cal commands date > date_cal.txt cal >> date_cal.txt date cal > date_cal.txt date; cal > date_cal.txt date > date_cal.txt ;cal >> date_cal.txt
more • more – display file one screen at a time • Syntax: more filename … • Press space-bar for next screen • Ctrl-c or q to quit • e.g. $ more cal_manual.txt • Can display multiple files
Creating files using cat • cat command can be combined with the redirection operators to create a text file • e.g. $ cat > memo This is a memo Ctrl-D $ • Ctrl-D terminates the cat session
cat (contd.) • The cat command can also be combined with the >> operator to append to an existing text file • e.g. $ cat >> memo This is line 2 of the memo Ctrl-D $