Högskolan i Halmstad
Halmstad University - For the Development of Organisations, Products and Quality of Life

Getting Started with Linux for the labs - Reference

1. Log into the computer using your student ID, welcome to redhat Linux

At this point you will see the GUI shell of redhat. This is very much remiscant of windows and how to operate this should be clear. You can do elementary file and directory handling here, as well as starting various programs and of course logging out.

There should be an icon on the desktop somewhere saying "home" (or likewise). Thats the network folder where some of you have dumped a lot of senseless stuff.

2. Free up storage on your network folder if needed

I heard that you only have 15 MB of storage, and you will need to have at least 5 MB free for the programs to run properly, so you should clear up stuff there now. After you have deleted stuff, dont forget to empy the trash bin, located on the desktop.

For doing thes excercises we will want to work mostly from a terminal window.

3. Open a terminal window by programs->accesories->Terminal

Now you see a terminal window in front of you. You will work alot in this window, so get used to it (some useful commandsexternal link). At the prompt it says which server you are logged into (probably STRAY). By typing:

pwd

you can list the current path. This is the location of your home directory, the very same place were you have previously dumped stuff (network folder), and the place that point 2 above was refering to.

4. Set up some appropriate sub folders for the course

In your home directory, you will want to make some directories for the current course. Maybe "AlgoData" is a good name. This is done by:

mkdir AlgoData

assuming that the current directory is your home directory. After you have made the directory, you can change to it by

cd AlgoData

Under AlgoData, you can make another directory specific for the excercise (like e1, e2, e3 etc.). whatever folder you intend to be working in, create it, and make sure it is your current by changing to it using "cd"

5. Start Firefox from the terminal

The way you will mostly want to start programs form the terminal is by typing the name of the program followed by a "&". Start up firefox web browser like this by typing at the prompt:

firefox &

You should get aquainted with the TAB button. It is an auto complete function, that will speed up your work considerably. instead of typing "firefox &", type only "fire" and hit TAB. The terminal window will autocomplete this for you, into "firefox" (you should still put a & at the end of it before executing). The reason we put a & at the end of the program name is because that way, the program will not freeze up the terminal window. If we do not put a &, then the terminal window will be dedicated to displaying the output of the program we started.

6. Start a text editor from the terminal

next you should a text editor, which will be the program where you will do the editing of your java code. I recommend using gedit. For power users, there is emacs, and you can also use nedit. Its all up to you, and it wont affect in any way the final program. For starting gedit:

gedit &

7. How to work

At this point, your network folder should have enought space left on it, and your current folder in the terminal should be the one you created(type "pwd" at the prompt to check this). You should have 1) the terminal, 2) firefox and 3) an editor running(e.g. gedit).  These are the 3 things you will need, and nothing more. To get started, just go to the lab page where .java files are available (PRE-excercisesexternal link). right click a link to a java file, and save as. select the directory you created. If you double click the file you downloaded in redhat, then it will open it with the editor emacs. This editor is superb, but probably NOT FOR YOU. Instead, open the file manually from the menu in the editor that you have chosen(gedit probably). Now you can do changes in the file if you like. Dont forget to save your file when you are ready to compile it.

8. Compiling and running Java

You compile your program by typing

javac MyBrandNewSplendidProgram.java

if this compiles with no errors, then a file called:

MyBrandNewSplendidProgram.class

is created. This is your executable (assuming you have a main function in the class). You execute your program by typing:

java MyBrandNewSplendidProgram

NOTICE the difference between "javac" to compile, and "java" to run. Of course, typing

java MyBrandNewSplendidProgram

takes along time to type. If you type only

java MyB

and hit TAB, then you dont have to write out the full name, but it is filled in automatically.

Page editor: Stefan Karlsson
Page last updated 2010-03-26
Halmstad University  |  Box 823  |  S-301 18  Halmstad, Sweden  |  Tel: +46 35-16 71 00  |  registrator@hh.se |  Visiting address: Kristian IV:s väg 3