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: - Login to your eagle account - telnet satara - user name will be lynx and password is lynx - Follow the first link that brings up the home page - Follow faculty of computer science link, follow Pawan Lingras link, follow COSC 2904 - Brings you to the directory for 2904 - The outline file is called outline.htm 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) - Look at page 3 for a sample UNIX session - $ 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 - For more information on pine, see the TAs in Room 315. - 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 idiosynchrosies 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. - See page 24 for a pictorial representation of a typical directory structure - 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 Options are indicated by using a - sign followed by the option Table 1.1 on page 22 gives you more info on some of the essential file and directory handling commands and the corresponding options - 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 and try wc, grep, tail, cmp, diff - UNIX directory structure is not a real tree - A file can exist in more than one directory rd/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 dorectories by using ln -s. Soft links are not real links.