UWA logo

School of Computer Science
& Software Engineering
Computer Vision 233.412

An Introduction to Linux

The aim of this document is to get you started with the basics of Linux. It is assumed that you are familiar with the Windows or Mac environments.

Booting up Linux and logging in

Our computers can be booted up in Windows 2000 or Linux. If your machine is running Windows 2000 you will need to reboot the computer by pressing the keys Control-Alt-Delete simultaneously. You will then be presented with the option to log in under Windows 2000 or to shutdown and restart the computer - select the latter. After resetting itself the computer will prompt you for the operating system you wish to use, select Linux. When you eventually get the login prompt enter your username and password.

You will now be logged in and the KDE desktop environment to Unix started up. On the bottom left of the screen you will find the Red Hat icon. This is equivalent to the Windows 'start' button. Clicking on this will open up a number of menus giving you access to various applications.

On the left of the screen you will see an icon of a folder labeled 'Home Directory'. If you double click on this the Konquerer file manager window will open up. This will be similar to Windows Explorer and you can use this to find files, and copy, move, rename and delete files. You can also use Konquerer as a web browser. Typing http://www.csse.uwa.edu.au into the location field will take you to the Department's home page. All course materials are found off the 'Undergraduate' Link. An alternative browser is Mozilla which can be launched from the icon on the bottom taskbar.

Logging Out

It is important that you remember to log out when you have finished your session. Click on the 'start button' and select logout. The computer will then return to the login window.

If you want to reboot the computer and start Windows 2000 you should select shutdown from the login panel, and then select restart.

Some Basic Unix

In the Macintosh and Windows environments you can 'double click' on a program's icon to start it. Under Unix you run a program by typing in its name along with any arguments that it may use. As people don't seem to like typing long program names many Unix program have short (and sometimes cryptic) names. In Unix files are organized in directories which are equivalent to Windows or Macintosh 'folders'. File types are usually denoted by their endings. For example a file with a '.java' ending normally indicates that it is java source code, a '.m' ending indicates a MATLAB source file.

Basic Commands:

Commands are entered into console windows (like the MSDOS prompt window). Open a console window by clicking on the computer monitor icon on the bottom tool bar. When you open a console window you will be placed in your home directory. This is the directory in our system where you will keep your files.

The basic operations that you want to perform in any operating system are file copying, renaming and deleting, the ability to move between directories/folders, and the ability to list the contents of a directory/folder.

On-line Help:

From a console window you can find out about any Unix command/program using the manual command
> man program_name
> man ls              - will tell you about the ls command
If you don't know the name of a command you can try looking for manual entries via a keyword
> man -k keyword   This will list all programs that man thinks might
                   be relevant to your keyword (often more than you want)
eg. try
> man -k print

Developing MATLAB programs under Unix

MATLAB version 6 provides a nice integrated development environment under Linux. When you invoke MATLAB by typing
 >matlab &          (I suggest you run it in background)
a large window will pop up (eventually!). This will contain 3 sub-windows; a command window, a command history window and a launch pad window.

The launch pad window allows you to browse and launch existing MATLAB programs by double clicking on them rather than typing their names into the command window. The command history window records all your commands, previous commands can be edited and reused by double clicking on them. However, previous commands are always accessible to you from the command window via the arrow keys or (Control-P).

I practice I prefer to close the command history and launch pad windows, and only use the command window.

Editing M files

MATLAB source files are known as 'M files', they are simply text files that have a name with a '.m' ending. The main MATLAB window has a file menu which allows you to open a new M file or open an existing one. This pops up MATLAB's text editor which is straightforward to use.

emacs

You do not have to use MATLAB's text editor to create M files. There are many text editors available under Unix. You may choose to use 'emacs' (though you are welcome to use any other if you wish). Emacs is a very powerful editor and is widely used. You can also configure it so that it recognises MATLAB files and performs appropriate syntax highlighting.

Many programs 'understand' common emacs command for modifying text. For example, Netscape, the console window, and the MATLAB command window will respond to basic emacs commands.

For example to create and edit a file called script1.m you would type the following command in an console window

  > emacs script1.m &   ( run emacs in background)
In the emacs window you can then type in a simple MATLAB script. To save your program select 'Save Buffer' under the 'Files' menu. (You can also save the file by typing Control-x-s, that is type x and s while holding the control key down)

For more information on how to use emacs you can select 'Emacs Tutorial' from the 'Help' menu. It will take you about 15 minutes to run through the tutorial.

When you type in a program, save it, and then try to run it in MATLAB you will inevitably have an error. You will get a message giving the line number in the file where the error occured. To fix the problem go to your emacs window and edit the file. There is a shorthand way to get to a desired line, type Esc g. At the bottom of the emacs window you will be prompted for the line to go to - go there and fix your error(s). Save the corrected file (Control-x-s). Move to the console window running MATLAB and try again...

Go to the Vision Course How To page to see how you can configure emacs so that it recognises MATLAB files and performs appropriate syntax highlighting.

Experiment, have fun...

Don't forget to log out