390 likes | 570 Vues
Introduction to UNIX System. Learing outcomes. Introduction to Unix system Unix commands. What is a UNIX?. UNIX is an operating system An operating system is the program that controls all the other parts of a computer system, both the hardware and software. What is LINUX.
E N D
Learing outcomes • Introduction to Unix system • Unix commands
What is a UNIX? • UNIX is an operating system • An operating system is the program that controls all the other parts of a computer system, both the hardware and software.
What is LINUX • LINUX is a free UNIX-type operating system originally created by Linus Torlvads with the assistance of developers around the world. • The source code for Linux is freely available to everyone. • The commands of linux are similar to unix.
Features of UNIX • UNIX is a multi-user, multi-tasking operating system. • Multi-users may have multiple tasks running sumiltaneously. • This is different than PC operating system • UNIX is a machine independent operating system. • Designed from the beginning to be independent of the computer hardware
Introduction unix • Developed at Bell Laboratories in the late 1960s by Dennis Ritchie and Ken Thompson • Shell is simply a program that reads in the commands you type and converts them into a form that is more readily understandable by the UNIX system
Introduction (continue.) • Shell includes some fundamental programming constructs that let you make decisions, loop, and store values in variables • “Bourne” shell was written by Stephen Bourne in Bell laboratories • “Bourne” shell is the “standard” shell
UNIX System • The “UNIX system” is logically divided into two pieces: • Kernel • Utilities
UNIX System (continue.) • Kernel is the heart of the UNIX system and resides in the computer’s memory. It allocates time and memory to programs and handle filestore and comunications Utilities UNIX system kernel disks Memory
UNIX System (continue.) • Utility resides on the computer’s disk and are only brought into memory as requested. • Virtually every command under UNIX is a utility • Shell is a utility program loaded into memory for execution whenever you log into the system
Logging in a UNIX system • Terminal is connected to a UNIX system through • Direct wire • Modem • LAN • After you connect the UNIX system a login: message appears
login: UNIX SYSTEM KERNEL getty login: getty getty login: Logging in a UNIX system (continue.)
Logging in a UNIX system (continue.) • init is the UNIX system • init automatically starts up a getty program on each terminal port whenever the system is allowing users to log in • After getty displays the message login: and some types the usernames followed by RETURN, it starts up a program called login to finish the process of logging in. Then getty disappears • /etc/passwd file has one line per user
Logging in a UNIX system (continue.) login: Skan password: UNIX SYSTEM KERNEL login login: getty getty login:
Logging in a UNIX system (continue.) • After login begins execution, Password: message appears • User types the password and hits RETURN • The user name and the password will be checked against the corresponding entry in the file /etc/passwd
Logging in a UNIX system (continue.) • Every line has seven fields separated by “:”. • The fields are : • Login name • Password (encrypted form). • User ID • Group ID • User information which could be First and Last name, etc… • Home directory • Program to start up when user logs in. Usually a “shell” program
Logging in a UNIX system (continue.) • Example $ cat /etc/passwd root:x:0:1:Super-User:/:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spool/lp: uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/usr/net/nls: nobody:x:60001:60001:Nobody:/: noaccess:x:60002:60002:No Access User:/: nobody4:x:65534:65534:SunOS 4.x Nobody:/: oracle:*:101:67:DBA Account:/export/home/oracle:/bin/csh webuser:*:102:102:Web User:/export/home/webuser:/bin/csh abuzneid:x:103:100:Abdelshakour Abuzneid:/home/abuzneid:/sbin/csh $
Logging in a UNIX system (continue.) login: Skan password: $ UNIX SYSTEM KERNEL /bin/sh login: login: Med password: $ /usr/lbin/ksh /usr/data/bin /dat_entry login: login: slim password: $
After Shell starts • When shell starts up, it displays a command prompt: • $ in Bourne shell and Korn shell • % in C shell • Shell goes to sleep after every command or program followed by RETUN until the program has finished • This copied program is called a process
Login cycle init init init init getty sh init login
Responsibilities of Shell • Program Execution • Variable and File Name Substitution • I/O Redirection • Pipeline Hookup • Environment Control • Interpreted Programming Language
Program Execution • Format: program-name arguments • The shell scans the command line and determines the name of the program to be executed and what argument to pass to the program • Multiple occurrences of white spaces characters are simple learned
Program Execution(continue.) • $ mv oldfile newfile • $ echo Smile, you are in Bridgeport City Smile, you are in Bridgeport City $ mv arguments oldfile newfile Smile, you are in Bridgeport City echo arguments
Program Execution(continue.) • Shell has some built_in commands which execute them directly without searching the disk • cd, pwd and echo are built_in commands
Variables and File Name Substitution • assign values to variables $ list=ls $ ls Carthage Damas $ $list Carthage Damas • file name substitution on the command line • * • ? • []
Variables and File Name Substitution (continue.) • Examples $ ls Documents Memos mail personal $
Variables and File Name Substitution (continue.) $ echo * Documents Memos mail personal $ Documents Memos mail personal arguments echo
Variables and File Name Substitution (continue.) $ ls Documents mail Documents: a.doc c.doc p1 p11 mail: p1 p2 $
Input/Output Redirection • Examples $ wc -l list 2 list $ wc -l < list 2 $
Input/Output Redirection (continue.) wc -l users arguments wc arguments -l
Input/Output Redirection (continue.) • In the first command line, two arguments where passed to wc (word count) utility: -l and users • In the second command line, one argument is passed to wc utility: -l. This gives the indication that the number of lines appearing on standard input is to count
Pipeline Hookup • Connects to commands • Pipe characters: • | • ^ • Connects the standard output from the command preceding | to the standard input of the one following the |
Pipeline Hookup (continue.) • Example: $ who | wc -l • Counts the number of users login to the system by connecting the standard output of who to the standard output for wc
Basic Unix commands • cat file Concatenate or type out a file cat file1 file2 ... Type out a number of files • cd directory1 Change current directory to directory1 cd /usr/bin Change current directory to /usr/bin cd Change back to your home directory • clear Clear the current screen • cp file1 file2 Copy file1 to file2 cp file1 file2 ... dir Copy a number of files to a directory • ls List the files in the current directory ls /usr/bin List the files in the /usr/bin directory • lpr file1 Print file1 out lpr file1 file2 ... Print a number of files out • more file Look at the content of a file with paging, use ‘q’ to get out • mkdir directory Create a directory • mv file1 file2 Move file1 to file2, like rename. mv file1 file2 ... dir Move a number of files into a directory mv dir1 dir2 Move or rename a directory
Basic Unix commands (continue) • rmfileRemove a file • rmfile1 file2 .. Remove a number of files • rm -r directory Remove a directory include the sub-directory • rmdirdirectory Remove a directory
DOS Command Unix Command Descriptions CD cd Change directory CHKDSK du Disk usage CLS clear Clear the current screen COPY cp Copying files DEL rm Removing files or directories DIR ls File listing of directories MD mkdir Create a directory MORE more Type out a file with paging PRINT lpr Print out a file RD rmdir Remove a directory RENAME mv Moving files around TYPE cat Type out files Unix commands vs DoS
Who, When, Why, What and Where? • man cp Display on-line manual for the “cp” command man -k keyword Display manual help file related to the keyword • passwd Change your login password • pwd Display the path name of where you are • uptime Tell you how long the machine has been up and running • users Tell you who is logging in • who Tell you who is logging-in in detail • w Tell you who is logging in and doing what! • whoami Show you the owner of this account • finger user Find out the personal information of a user finger name Try to find the person’s info. by his/her name finger email-address Try to find the person’s info across the network • write user Write a message on somebody’s screen • talk user Talk to the person logging in the same system with you • talk email-address Talk to somebody logging in the network • date Display today’s time and date • cal year Display the calendar of the specified year (e.g. 1997)
References • http://info.ee.surrey.ac.uk/Teaching/Unix/ • UNIX SHELLS BY EXAMPLE BY ELLIE QUIGLEY • UNIX FOR PROGRAMMERS AND USERS BY G. GLASS AND K ABLES • UNIX SHELL PROGRAMMING BY S. KOCHAN AND P. WOOD