Logo Reproduction Colours red and black on white backgroun School of Computing & Information Systems Unix Guide Mono positive black on white background 2013 Mono negative white only out of any colou
2 Unix Guide Contents Introduction... 3 Your Unix Account Ethics Guidelines Unix Hosts... 4 Accessing Your Account... 4 About X-windows... 5 Mouse buttons under X-windows Starting the X-Server on Mac OS X Starting the X-Server on Windows 7 Logging in via X-Windows... 6 The Gnome Desktop... 7 Editing Text Files... 8 Logging out of Gnome... 8 Changing Your Password... 9 The Unix File System... 10 Directories Hierarchy and Structure Pathnames Filesystems Your Home Directory The Unix Shell... 12 Command Line Editing Commonly Used Unix Commands... 13 The Unix Manual Pages... 16 Copyright 2013 School of Computing & Information Systems, University of Tasmania
Unix Guide 3 Introduction This document is an introductory guide to Unix for School of Computing & Information Systems students - it shows you how to log in and begin using the School's Unix systems. The document is not presented as a tutorial - rather it introduces relevant topics for subsequent exploration by the reader. Your Unix Account All Computing & Information Systems students are provided with a Unix account, which is maintained as long as you remain enrolled. Non-CIS students (that is, students enrolled in other courses who are taking units offered by the School of Computing & Information Systems) are allocated a Unix account only where required for study purposes. These accounts are closed at the end of each semester. Your Unix account is usable for general Unix computing requirements, but is also accessible as general file-storage space from the School s Windows and Macintosh systems. In 2013, all students are allocated a quota of 50 megabytes. This is NOT your main file-storage space, which is located on the Macintosh file-servers liffey (Launceston) and huntley (Hobart). This space is considerably larger than the space available in your Unix account. If you know your central account username and password, you can activate your account at one of the School s self-help kiosks. Alternatively, visit the School's Help Desk in Launceston or Hobart for help activating your School account. Ethics Guidelines As a user of the School s computing facilities, you are expected to act responsibly. It is a condition of use that you agree to abide by the Ethics Guidelines. Failure to comply with these guidelines may result in your access to School systems being restricted or revoked.
4 Unix Guide Unix Hosts The School has two Unix hosts for student use lawson and alacritas. Both are Dell PowerEdge 2950 servers. These systems run CentOS Linux as a virtual machine. Student accounts are allocated to one of these two systems based on location. Lawson is located in Launceston and is used by students based in Launceston. Alacritas is located in Hobart, and is used by students based in the south of the state. If you travel between the two main campuses, you can log into your primary account at the other campus. Accessing Your Account You can access your Unix account in a number of ways. You can establish a command-line connection from another computer using the ssh client. You can establish a full-screen GUI connection using X-server software running on Windows or Mac OS. You can mount your Unix account as a fileshare on a Windows or Macintosh desktop. The simplest method is to use an ssh client from a Macintosh or a PC. This provides you with command-line access, which is limited but available from almost anywhere in the internet (provided you have access through the University s VPN tunnel see http://www.its.utas.edu.au/vpn for additional information). This document is primarily concerned with access using the X window system, which requires an X-terminal, or an X-server running on a PC or a Macintosh. X- windows provides a more feature-rich access method, although access is restricted to systems on the University intranet.
Unix Guide 5 About X-windows X-windows is a windowing system for Unix (and other systems) that provides a graphical user interface similar to that provided by the Apple Macintosh and Microsoft Windows. Programs running on the Unix system are known as X-windows clients, and these display their output on an X-windows server somewhere on the network. The X-windows server may be a dedicated device (in which case it is usually known as an X-terminal), or it may be a software application running on another operating system such as Windows or Mac OS. All PCs and Macs in use in the School have X-server software installed. Although X-windows is the underlying protocol used by many Unix-based windowing systems, system vendors often add extra functionality and their own look-and-feel. On our systems, the user interface is known as Gnome. Mouse Buttons under X-windows X-Windows works best with a three-button mouse. The buttons are used as follows: The left-most button is the select button, and is used to activate, select, open, close, resize and move windows and to make choices from menus. The middle button is the adjust button. It is rarely used but its main function is to deselect a selected object, or to select an additional object. The right-most button is the menu button, and is used to provide contextual menus on selected items (like right-click on Windows). Starting the X-Server on Mac OS X To connect to a Unix host using the X-server software installed on the School s Mac OS X systems, click the Shortcuts folder in the Mac OS X dock, scroll to the X-Windows option and choose one of the hosts on the list.
6 Unix Guide Starting the X-Server on Windows 7 To connect to a host using X-Windows on a PC, from the Start icon choose All Programs CIS Resources (Campus) (option) and select one of the options from the list: for Hobart students: for Launceston students: Logging in via X-Windows When the X-server has started, you should see a login box prompting you for your username. Type your account name and press enter. Next, you'll be prompted for
Unix Guide 7 your password. Type this in and press enter. After a short pause, you'll see the Gnome desktop: The GNOME Desktop The Gnome Desktop The Gnome desktop is similar to the Windows and Mac OS Desktops. It provides the user with a working area that allows access to their files and also to many of the commonly used applications and utilities on the system. The desktop can be customised, but the procedure is outside the scope of this document. Gnome provides two panels. The one at the top of the screen allows you to open applications (eg. a text editor or word processor), or perform actions (eg. logout). The panel at the bottom of the screen allows the user to swap between open windows (applications) and use 4 virtual desktops.
8 Unix Guide Editing Text Files In Gnome, the easiest editor to use is known as gedit - the Gnome text editor. You can start gedit using the Applications menu on the Gnome top panel (shown on the right) it is similar to the Notepad editor in Microsoft Windows. If you are logged into the system using ssh (for example, from outside the University, or from a Macintosh or a PC that doesn't have the X-Win32 software installed), then the Gnome editor cannot be used. Instead, you must use an editor that runs in a regular terminal environment. In these situations, you can edit files using the vi or joe. Most beginners find vi difficult to use because of its command structure, lack of inbuilt help, and various operating modes. Despite this, vi is available on most Unix-like operating systems. If you can learn to use it (even at a basic level), then you can edit files on just about any Unix system you're ever likely to use. Joe is a simpler editor to use, and features built-in help. It is not installed by default on most Unix systems, so you can't rely on it always being available. The School's Help Desk can supply handouts describing how to use vi and joe. Logging out of Gnome When you've finished your Unix session, be sure to log out so that other users do not have access to your files. To log out of Gnome, choose Log Out from the System menu on the Gnome top panel. Gnome will ask you to confirm (or cancel) the logout.
Unix Guide 9 Changing your School Password To change your School password, open a web browser in one of the School s labs, and visit the page: https://password.cis.utas.edu.au/ You will be presented with two buttons. One allows you to change your School password to something different. The other allows you to reset your School password to be the same as your central password. Whichever method you choose, the change will be propagated to the various systems in use within the School, including the Unix server, the Windows domain controllers, the Mac OS X authentication servers, the printing systems, and the tutorial allocation system. This new password will not be propagated to servers run by other schools or entities such as IT Services. You can also reset your password at one of the School s self-help kiosks, or you can visit our help desks. Changing your Central Password To change your central password, open a web browser in one of the School s labs, and visit the page: https://password.its.utas.edu.au/ If you change your central password here, the change will not be pushed on to your school accounts. You must visit the School s password change page (as described above) to change your School password. You can also change your central password by visiting the service desk in the Library.
10 Unix Guide The Unix File System A file is a basic unit of the Unix operating system. Documents, commands (executable files), and devices (e.g. a printers or disk drives) are all treated as files by the system. Unix provides commands for creating, editing and deleting files. Directories A directory is a special file that contains ordinary files and/or other directories (a directory can be thought of as a folder). Directories that reside in other directories are called subdirectories. As with ordinary files, Unix provides commands for creating subdirectories, moving them around, and deleting them. There are also commands to move files from one directory to another. Hierarchy and Structure Assume a regular file called apple is located within the directory fruit that is located within the directory foodtypes. The location of the file apple then is represented like this: /foodtypes/fruit/apple The first or root directory on a Unix system is called (slash). The slash is also used to separate directory names but it is referring to the root directory only when it occurs at the beginning of a pathname. Pathnames The pathname for the file apple is /foodtypes/fruit/apple. A pathname gives the name of a file (apple) plus its location (/foodtypes/fruit/). Pathnames are used to locate files. For example if the file apple was an executable program and the current directory was foodtypes, to run you would need to type: fruit/apple However if the current directory was /foodtypes/fruit and you wanted to run the program you would only need to type:./apple
Unix Guide 11 The difference is that in the first instance the file is not in the current directory so you need to tell the system where the file is. Filesystems The Unix filesystem is a hierarchical collection of many directories and files. Your home directory and all the files and directories within it are part of this large system, but you do not have access to all the files on the system. When typing filenames and pathnames, a number of abbreviations may be used as follows:. A period can be used to refer to the current working directory... Two successive periods refer to the directory "above" the current working directory (that is, the parent of the current directory). If the current working directory is /foodtypes/fruit and you want to make /foodtypes the current working directory, enter the command: cd..? The question mark matches to any single character in a filename. For example, if you want to copy all files with five letter filenames that commence with the four letters appl from the current directory into the directory foodtypes, you would enter the command: cp appl? /foodtypes * The asterisk refers to any group of characters. If you want to copy all files from the current directory into the directory foodtypes, enter the command: cp * /foodtypes Take care using the asterisk with destructive commands (such as rm). Your Home Directory The area on the Unix file system where you can store files is called your home directory. The full path of your home directory is typically: /u/students/username
12 Unix Guide The Unix Shell To use the shell, you need to have a terminal window open. In Gnome, click the Terminal icon in the Gnome top panel. When you have command-line access to a Unix-based host system you are running an application known as the shell. The shell is a program that allows you to manipulate files and execute (or run) other Unix applications and utilities. There are a number of shells available for Unix systems, and the default shell on lawson and alacritas is called bash. There are two types of commands that each shell understands - Unix executable files (located in various parts of the filesystem) and built-in commands, which are provided by the shell itself. Some of the executable commands are discussed in the next section of this document. The shell's built-in commands provide additional functionality for the user when interacting with the system. This additional functionality includes command-line editing, job control and I/O redirection. Command Line Editing The tc-shell allows you to recall and edit previously entered command lines using the cursor keys. You can also recall previous commands with the following commands: history displays a list of the previously entered commands.!n (where n is an integer) will repeat the previously entered nth command (from the history list).!! re-executes the last command. command!$!string executes command using the last argument of the previously executed command. This can be useful when you need to reference the same file in successive commands, eg: vi file.c cc!$ re-executes the most recent previously entered command which began with the text string.
Unix Guide 13 There are many other features of the tc-shell that are useful to more advanced users. Information on these can be found in the on-line manual page for the tcsh. Commonly Used Unix Commands cat format examples Concatenate (or join) two or more files to produce a third. May also be used to display the contents of text files on the terminal. cat file1 file2... > outputfile cat file cat testfile display testfile on the terminal cat a b > c creates file c by joining the files a and b (a and b are not affected) cd Change to another directory. format cd directoryname examples cd /etc change to the /etc directory cd return to your home directory cd.. change to the parent of the current directory cp format examples Copy a file. cp file1 file2 cp fred1 fred2 copies fred1 to fred2, erasing any existing file called fred2 lp format examples Print a text file on the default printer. lp filename lp fred2 prints the contents of fred2
14 Unix Guide ls Lists the files and subdirectories in a directory. format ls [-altf] examples ls list in multi-column format ls -l list with additional information such as file size and owner ls -al as with ls -l but also show hidden files ls -t list most recently modified files first ls -F append a slash to directory names man Display manual pages (information on Unix commands). format man filename examples man cat Show information about the cat command man -k "xxx" Gives the header lines of all manual entries that contain the text "xxx" in their header mkdir format examples Make a directory. mkdir directoryname mkdir letters makes a new directory in the current directory called letters more format examples Display a file on the terminal page by page. When the display pauses, press the space bar to display the next page, or press 'q' to quit. more filename more fred display the file fred one page at a time mv format examples Changes the name of a file or its location. mv oldfilename newfilename mv fred jack if an existing file called jack exists, it is deleted and then the file fred is renamed jack
Unix Guide 15 pwd format Show the current working directory. pwd rm Delete a file. format rm filename examples rm fred deletes the file fred from the current working directory rmdir format examples Remove a subdirectory (only if it is empty). rmdir directoryname rmdir letters deletes the subdirectory called letters The Unix Manual Pages Online documentation for any Unix command can be accessed via the (manual) command. For example, to find out how to use the command, you would type: % man cat The system will respond by displaying the appropriate page from the online manual pages, one page at a time. press the return key to advance one line press the space bar to see the next page Press 'B' to go back one page press 'Q' to quit to the shell The man command has options that make it possible to search the online manual for keywords. To find out more, enter the following from the shell prompt for a description of the man command itself. % man man
16 Unix Guide Corrections This document is periodically revised. Corrections and suggestions for additional content are welcome, and should be made at the Technical Services Help Desk.