* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Introduction
Survey
Document related concepts
Security-focused operating system wikipedia , lookup
Process management (computing) wikipedia , lookup
Library (computing) wikipedia , lookup
MTS system architecture wikipedia , lookup
Commodore DOS wikipedia , lookup
Burroughs MCP wikipedia , lookup
Berkeley Software Distribution wikipedia , lookup
Plan 9 from Bell Labs wikipedia , lookup
History of Unix wikipedia , lookup
Comparison of command shells wikipedia , lookup
Transcript
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 UNIX system kernel Utilities 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 Logging in a UNIX system (continue.) login: getty UNIX SYSTEM KERNEL login: getty getty login: 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: login login: UNIX SYSTEM KERNEL 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 : 1. 2. 3. 4. 5. 6. 7. 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: $ /bin/sh login: UNIX SYSTEM KERNEL /usr/lbin/ksh /usr/data/bin /dat_entry login: Med password: $ 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 getty init sh init login Login cycle (continue.) Developed by Stephen Bourne Shell name Utility Bourne shell sh Korn shell ksh David Korn C shell csh Bill Joy 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 mv arguments oldfile newfile $ echo Smile, you are in Bridgeport City Smile, you are in Bridgeport City Smile, $ you echo arguments are in Bridgeport City 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 file name substitution on the command line $ list=ls $ ls Carthage Damas $ $list Carthage Damas * ? [] Variables and File Name Substitution (continue.) • Examples $ ls Documents $ Memos mail personal Variables and File Name Substitution (continue.) $ echo * Documents Memos mail personal $ arguments echo Documents Memos mail personal Variables and File Name Substitution (continue.) $ ls Documents mail Documents: a.doc mail: p1 $ p2 c.doc p1 p11 Input/Output Redirection < << Input Here Document Output Output > >> • Examples $ wc -l list 2 list $ wc -l < list 2 $ Input From a file Read From Shell Script Direct to a File Append to a File Input/Output Redirection (continue.) wc wc arguments -l users 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 cat file1 file2 ... cd directory1 cd /usr/bin cd clear cp file1 file2 cp file1 file2 ... dir ls ls /usr/bin lpr file1 lpr file1 file2 ... more file mkdir directory mv file1 file2 mv file1 file2 ... dir mv dir1 dir2 Concatenate or type out a file Type out a number of files Change current directory to directory1 Change current directory to /usr/bin Change back to your home directory Clear the current screen Copy file1 to file2 Copy a number of files to a directory List the files in the current directory List the files in the /usr/bin directory Print file1 out Print a number of files out Look at the content of a file with paging, use ‘q’ to get out Create a directory Move file1 to file2, like rename. Move a number of files into a directory Move or rename a directory Basic Unix commands (continue) • rm file rm file1 file2 .. rm -r directory • rmdir directory Remove a file Remove a number of files Remove a directory include the sub-directory Remove a directory Unix commands vs DoS DOS Command Unix Command Descriptions CD CHKDSK CLS COPY DEL DIR MD MORE PRINT RD RENAME TYPE cd du clear cp rm ls mkdir more lpr rmdir mv cat Change directory Disk usage Clear the current screen Copying files Removing files or directories File listing of directories Create a directory Type out a file with paging Print out a file Remove a directory Moving files around Type out files 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