Introduction to UNIX

12
Introduction to UNIX Geraint Vaughan

description

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. - PowerPoint PPT Presentation

Transcript of Introduction to UNIX

Page 1: Introduction to UNIX

Introduction to UNIX

Geraint Vaughan

Page 2: Introduction to UNIX

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

Page 3: Introduction to UNIX

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

Page 4: Introduction to UNIX

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

Page 5: Introduction to UNIX

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

Page 6: Introduction to UNIX

Editing a file 2You 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)

Page 7: Introduction to UNIX

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.

Page 8: Introduction to UNIX

Deleting files and directories

1. rm filename deletes a single file2. rm * deletes all files in a directory: * works as a

wild card, representing any file3. rm file?? Deletes all files in the current

directory with names like file01, filexx: ? is a wild character

4. rmdir sub removes subdirectory sub; rm –R sub removes sub and any subdirectories or files it contains.

Page 9: Introduction to UNIX

Directory ListingTo 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 with Unix 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

Page 10: Introduction to UNIX

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

Page 11: Introduction to UNIX

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

Page 12: Introduction to UNIX

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