Espresso: A Concentrated Introduction to Java
Summary: We introduce (or re-introduce) the Unix operating system, particularly the key features necessary to compile and use Java in the Grinnell College Mathematics Local Area Network (MathLAN).
Prerequisites: None.
Disclaimer: Although I use the term Unix
throughout this document, the ideas apply equally well to Linux
, the variant of Unix we use in MathLAN.
Contents:
One of the central pieces of any computer is the operating system. The operating system typically controls the programs that runs on the computer, manages the disks and other devices on the computer, and generally shields the user from the inner workings of the computer.
Most computers provide some form (or forms) of user interface that permits people to give commands to the computer (e.g., start a program, rename a file, determine who else is using the computer). The user interface communicates these commands to the operating system, which then performs the commands (or extracts information that the user interface needs). Although many people consider the user interface part of the operating system, it is really an add-on to the operating system.
There are two basic kinds of user interfaces: graphical user interfaces, in which you interact with the computer through icons, menus, and such, and textual user interfaces, in which you interact with the computer by typing commands in a terminal window.
Although you can (and will) perform many actions on our Unix systems through the graphical user interface, there are many things that I would prefer that you do through the textual user interface, and some that you must do through the textual user interface, at least in this class.
You can create a terminal window on our systems by clicking the little picture of a computer screen that appears in the command bar at the bottom of the screen. When you open a terminal window, you should see a prompt of some form (usually a percent sign or a greater-than sign).
Once the terminal window is open, you can type a variety of commands, which we will soon discuss. The simplest command is to type the name of a program, along with any information the program needs to run. For example, to run the Java compiler on the file Hello.java, we would write
% javac Hello.java
Similarly, to list all the examples in the examples directory for this class, we would type
% ls /home/rebelsky/Web/Courses/CS152/2006S/Examples/
Since life tends to become complicated if you have to put all of your files in one place, Unix permits you to create a hierarchial set of directories (file folders). For example, I have a directory for each class I teach and within that directory I have other directories (subdirectories) for homework, readings, outlines, and so on and so forth. Unix shows directory hierarchies by separating each directory with a slash.
When you are working in the terminal window, Unix has a notion of a present working directory. Commands that affect files use the files in the present working directory by default.
Users also have a home directory (the starting point of their explorations). In the MathLAN, this directory is /home/yourusername. You can refer to files with their short name (relative to the present working directory) or with a full name (starting with /home/yourusername or whatever is appropriate).
pwdlsls directoryless filecd directorycd ..mkdir directorychmod options filechmod a+r filechmod go-r filechmod a+x directorychmod a+r directorycp sourcefile targetcp filename newfilenamecp filename directorymv filename newfilenamemv filename directoryman commandSometimes commands are somewhat unwieldy to type. Unix permits us to add aliases that simplify typing. For example, suppose you regularly run the program /opt/jdk1.5.0/bin/javac, which is clearly a lot of stuff to type. You can enter the command
alias jc="/opt/jdk1.5.0/bin/javac"
From now on, any time you type jc, the terminal interprets
it as the longer form.
You can put aliases in a file called /home/yourusername/.bashrc and the computer will remember them more-or-less permanently.
You now know how to create directories, to change permissions, to determine and change your working directory, and other administrative tasks. However, you do not yet know how to create and change files. We typically use a text editor for making and editing files. Unix provides a wide variety of text editors.
For our work, we will focus on gedit, a simple text editor. Those of you who have used an editor in the past should find it fairly straightforward. You will typically start gedit by typing
gedit filename
Tuesday, 25 January 2005 [Samuel A. Rebelsky]
Wednesday, 26 January 2005 [Samuel A. Rebelsky]
cp, mv, and man commands.
Monday, 29 August 2005 [Samuel A. Rebelsky]
Tuesday, 24 January 2006 [Samuel A. Rebelsky]
This page was generated by
Siteweaver on Thu Mar 30 15:24:33 2006.
The source to the page was last modified on Tue Jan 24 09:20:04 2006.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Espresso/Readings/unix.html.
You may wish to
validate this page's HTML
;
;
Check with Bobby