120 likes | 351 Views
Introduction to UNIX. Geraint Vaughan. What is UNIX?. Command-line operating system (not point-and click) Designed for ‘experts’ Lots of different variants – e.g. LINUX, DEC UNIX, SUN UNIX……….. Used extensively for serious applications in physics Case-sensitive – CAT is different from cat.
E N D
Introduction to UNIX Geraint Vaughan
What is UNIX? • Command-line operating system (not point-and click) • Designed for ‘experts’ • Lots of different variants – e.g. LINUX, DEC UNIX, SUN UNIX……….. • Used extensively for serious applications in physics • Case-sensitive – CAT is different from cat
Logging on Start network access connect to central Log on using your usual id and password Make a new directory for the FORTRAN-90 course mkdir fort90 Change to directory fort90 cd fort90
Creating a new file cat (‘catalogue’) lists a file on the screen. You can use cat to create a new file like this: cat > myfile Type first line Type second line ……. Ctl-d
Editing a file 1 There are many text editors in Unix, but they are generally rather difficult to use. The most widely-available is emacs. On central the emacs interface is very easy to use but it seems to have a different interface on each computer To use emacs type emacs filename and use the intuitive interface
Editing a file 2 You can also use the windows notepad program if you prefer Start word processing notepad Notepad should start in your M: drive; change directory to fort90 File open Enter file name and edit (You can also create new files with notepad but beware: Windows always adds .txt as a file extension. You then have to use the UNIX command mv to rename the file. Alternatively, create the file first in UNIX with the name you want (e.g. myprog.f90), and edit in Notepad)
Listing a file on the screen For a short file you can use cat filename For longer files this will scroll off the top of the screen. To see a screenful at a time use more filename, using carriage return or space bar to advance the pages more is quite a clever program – for instance typing 500f when the program pauses will advance 500 lines, 100b will go back 100 lines and /string will move forward to the next occurrence of that string.
Deleting files and directories • rm filename deletes a single file • rm * deletes all files in a directory: * works as a wild card, representing any file • rm file?? Deletes all files in the current directory with names like file01, filexx: ? is a wild character • rmdir sub removes subdirectory sub; rm –R sub removes sub and any subdirectories or files it contains.
Directory Listing To see which files you have in a directory: ls (for current directory) or ls sub for subdirectory To get more information (e.g. date of creation, ownership) ls –l or ls –l sub This illustrates the use of options withUnix commands: -x where x is a letter or combination of letters, e.g. ls –a List all files, including system files ls –R List all files in this directory and its subdirectories
Copying and renaming files cp file1 file2 copies the contents of file1 to file2 mv file1 file2 renames file1 as file2 Moving between directories cd sub moves to a subdirectory sub cd .. Moves to the next directory up cd ../otherdir/newsub moves across to another directory (note /) cd by itself returns you to your home directory
Printing a file The basic print command is lpr filename. However, this will send your output to a central printer somewhere and you won’t be able to find it. Normally you will use a laser printer which expects Postscript pages. To send a Postscript file to these printers use a command like lpr –Puserarea postscriptfile To send a normal (ASCII) file you must use a2ps –Puserarea textfilename (College help sheet 58) A list of printers should be in each terminal room
Finding more information There is a huge amount of on-line information about Unix. Some useful places to start: College help page http://www.inf.aber.ac.uk/publications/documentation/h1.asp Departmental web page (information for current students) http://www.aber.ac.uk/physics/unix_cmds.shtml