UNIX Introduction History - Development started in 1969 - Ken Thompson original scientist working on the project - To devlop a typesetting system (to get approval from his bosses) - MULTICS: a multi user OS at MIT - UNIX is just a variation that came from MULTICS - Dennis Ritchie got on the project. He developed C - UNIX was rewritten in C - C is a small language: easy to write a compiler for C - UNIX which is written in C is a very protable operating system - UNIX was a very small and very easy to understand - UNIX is perhaps the most popular OS which runs on a machine anywhere from a PC to largest computer available - Original UNIX was from AT&T - Berkeley Software Distribution (BSD) created their own flavor of UNIX - Now we have ULTRIX (DEC), AIX (IBM workstations), several other companies such as SUN, SGI, also use UNIX as their primary OS - For PCs, popular UNIX releases include SCO UNIX and Linux - Linux is free and most popular. Devloped by Linus .... from Finland - Ritchie and Thompson went on to win the highest prize in COpmuter Science called Turing Award for UNIX - Today's UNIX is a lot more complex than the original UNIX - X Window provides Graphical User Interface for UNIX - Motif, Openwindows platforms some of the popular GUIs for UNIX - Many of the DOS extensions are copied from UNIX To obtain the outline or any other course related material: - http://satara.auc.on.ca/pawan/ follow the link for UNIX class and put a bookmark Most of our contact with UNIX is through a command interpreter There are several command interpreters - Bourne Shell (sh) - c shell (csh) - Bourne Again Shell (bash) - tcsh csh's answer to bash - A sample session including date, who and finger commands - $ or % prompt is the default prompt for sh - date gives you current date and time - who gives you a list of users currently logged in - finger also gives you a list of users - information from finger includes your username, actual name the terminal you are using, how long you have been idle when you were logged in, where you logged in from Internet addressing - Every user on internet can be identified using her username and the ip address. - ip address can be in form of numbers or somewhat meaningful names - All the ip addresses are translated to numbers - However it is difficult to remember numbers, so most ip adresses have a host name followed by the domain name - For example, eagle.auc.on.ca - eagle is the host name - auc.on.ca is the domain - tbird.auc.on.ca - satara.auc.on.ca - All of these addresses are translated to numbers using a name server - The command nslookup allows you to get the ip numbers for an internet address - finger command followed by username gives you detailed info about the user - finger command can be used to get information about a user over internet finger username@internet.address - If you wanted to get list of all the users on an internet site: finger @internet.address - In the same domain, you can omit the domain name. - From eagle, you can say finger lingras@tbird UNIX provides the basic mail command - mail allows you to send mail to any user on the internet mail username@internet.address Ex. mail lingras@tbird.auc.on.ca - interface for the mail command is not user friendly - There are different interfaces to the mail command - mailx (not much improvement) - elm, pine (used at AUC) - Use the command pine to access the pine mail interface - Full screen, menu-driven easier to use mail interface - To send a message you use the compose command - In To: field you have to have a valid internet address. Cc: field is optional - Attachment field allows you to attach binary files - Pine messages are typed in using an editor called pico = The most famous editor in UNIX is vi. It is very powerful and very user-unfriendly. - I recommend that you start with pico. - vi was perhaps the first full-screen editor. Most of the idiosyncrasies of vi come from the hardware limitations. Getting help in UNIX environment - man command is used to get help - man man to get help on man command itself - ls command allows you to get directory listing Directory structure is hierarchical - The root is called / - Each directory can contain files and other (sub)directories - Gives us a tree-like structure - Complete path for a directory can be specified starting from root and specifying all the subdirectories in the path separated by a / Ex. /usr/home/lingras/2904 The above path is absolute path If I were in the directory /usr/home/lingras and specified a path called 2904. Then it is relaive path. The current path, i.e. /usr/home/lingras is automatically used to precede 2904. The above method uses a path relative to the current directory. - cd, mkdir, rmdir - cd changes the directory to the - mkdir makes a directory given by the - rmdir removes the directory given by the - pwd gives you the path of the current directory - Most of the commands provide options For example, ls -l gives you long listing first column has ten bit info about type of the file d for dir remaining nine bits specify access info for owner,group,world r - read, w - write, x - execute use of octal numbers is the best for speciying permissions Options are indicated by using a - sign followed by the option option a gives all the files in the directory option -F gives a type of the file / at the end means a dir * at the end means an executable file - cp allows you to copy a file cp file1 files - mv allows you to rename a file mv file1 file2 - cat command prints the file on the screen - more is more useful than cat - lp prints the file to the printer - (Look at Table 1.1) try wc, grep, head, tail, cmp, diff - UNIX directory structure is not a real tree - A file can exist in more than one directory - ln command is used to establish a link to existing file tbird/usr/home/lingras/2904 40 >ls -l total 19 drwx------ 2 lingras faculty 1024 Jan 1 12:49 charlie/ -rw------- 2 lingras faculty 5943 Jan 3 21:31 intro drwx------ 2 lingras faculty 512 Jan 3 21:30 test/ tbird/usr/home/lingras/2904 41 >cd test tbird/usr/home/lingras/2904/test 42 >ls intro tbird/usr/home/lingras/2904/test 43 >ls -l total 16 -rw------- 2 lingras faculty 5943 Jan 3 21:31 intro tbird/usr/home/lingras/2904/test 44 >rm intro tbird/usr/home/lingras/2904/test 45 > tbird/usr/home/lingras/2904/test 45 > tbird/usr/home/lingras/2904/test 45 >ls -l total 0 tbird/usr/home/lingras/2904/test 46 > tbird/usr/home/lingras/2904/test 46 >cd .. tbird/usr/home/lingras/2904 47 >ls -l total 18 drwx------ 2 lingras faculty 1024 Jan 1 12:49 charlie/ -rw------- 1 lingras faculty 5943 Jan 3 21:31 intro drwx------ 2 lingras faculty 0 Jan 3 21:34 test/ - As the above session shows we can use the ln command to make links to a file from several directories - That means the file exists in several directories - Second field in the long listing shows the number of links to the file - rm deletes a file - rm reduces number of links by one - when number of links to a file is down to zero the file is physically removed - There are two special directory entries - . stands for the current directory - .. stands for the parent directory - Every directory has at least two links (why?) - If a directory has five subdirectories, how many links will it have (why?) - ln command cannot be used to create a link to another directory because it will result in cycles It is possible to create soft links to directories by using ln -s. Soft links are not real links. wascana/extra/pawan/test 43 >ls -l total 9 -rw------- 2 pawan 0 8281 Mar 26 13:47 a_net lrwxrwxrwx 1 pawan ta 8 Jun 16 11:01 bin -> /usr/bin wascana/extra/pawan/test 44 >ln -s ../.cshrc wascana/extra/pawan/test 45 >ls -l total 9 -rw------- 2 pawan 0 8281 Mar 26 13:47 a_net lrwxrwxrwx 1 pawan ta 8 Jun 16 11:01 bin -> /usr/bin wascana/extra/pawan/test 46 >ls -al total 12 drwx------ 2 pawan ta 1024 Jun 16 11:05 . drwxr-xr-x 29 pawan 0 2048 Jun 16 10:57 .. lrwxrwxrwx 1 pawan ta 9 Jun 16 11:05 .cshrc -> ../.cshrc -rw------- 2 pawan 0 8281 Mar 26 13:47 a_net lrwxrwxrwx 1 pawan ta 8 Jun 16 11:01 bin -> /usr/bin Creating the accounts using vipw - Password information is stored in the file /etc/passwd - Many systems provide a shadow password file for general user - Superuser can edit the file using the command vipw - Most systems provide a menu driven utility to maintain list of users - If you have to create a massive number of accounts at once (For example, student accounts), you may have to write your shell scripts. - We will look at the structure of the passwd file and also create accounts for all the users bash# cd /extra bash# md city bash: md: command not found bash# mkdir city bash# cd city bash# mkdir burt enzo valerie rob evelyn brenda susan don bash# ls brenda burt don enzo evelyn rob susan valerie bash# ls -l total 8 drwx------ 2 root 0 1024 Jun 16 11:25 brenda drwx------ 2 root 0 1024 Jun 16 11:25 burt drwx------ 2 root 0 1024 Jun 16 11:25 don drwx------ 2 root 0 1024 Jun 16 11:25 enzo drwx------ 2 root 0 1024 Jun 16 11:25 evelyn drwx------ 2 root 0 1024 Jun 16 11:25 rob drwx------ 2 root 0 1024 Jun 16 11:25 susan drwx------ 2 root 0 1024 Jun 16 11:25 valerie bash# ls -1 brenda burt don enzo evelyn rob susan valerie bash# ls -1 | awk '{print "chown",$1,$1}' chown brenda brenda chown burt burt chown don don chown enzo enzo chown evelyn evelyn chown rob rob chown susan susan chown valerie valerie bash# ls -1 | awk '{print "chown",$1,$1}' | sh bash# ls -l total 8 drwx------ 2 brenda 0 1024 Jun 16 11:25 brenda drwx------ 2 burt 0 1024 Jun 16 11:25 burt drwx------ 2 don 0 1024 Jun 16 11:25 don drwx------ 2 enzo 0 1024 Jun 16 11:25 enzo drwx------ 2 evelyn 0 1024 Jun 16 11:25 evelyn drwx------ 2 rob 0 1024 Jun 16 11:25 rob drwx------ 2 susan 0 1024 Jun 16 11:25 susan drwx------ 2 valerie 0 1024 Jun 16 11:25 valerie bash# - Modify /etc/group file to add the following line city::201:brenda,burt,don,enzo,evelyn,valerie,rob,susan bash# cd /extra bash# chgrp -R city city bash# ls -lR city | more total 8 drwx------ 2 brenda city 1024 Jun 16 11:25 brenda drwx------ 2 burt city 1024 Jun 16 11:25 burt drwx------ 2 don city 1024 Jun 16 11:25 don drwx------ 2 enzo city 1024 Jun 16 11:25 enzo drwx------ 2 evelyn city 1024 Jun 16 11:25 evelyn drwx------ 2 rob city 1024 Jun 16 11:25 rob drwx------ 2 susan city 1024 Jun 16 11:25 susan drwx------ 2 valerie city 1024 Jun 16 11:25 valerie - chgrp to change the group - chown to change the owner - R option in chgrp and ls was used to apply the command recursively