CS 124, Spring 2014
Pre-lab: Introduction to Linux

Welcome to CS 124, Introduction to Programming. In this course, you will learn how to write computer programs in the Java programming language. In the labs for this course, you will be using the Linux operating system. This "pre-lab" is a short introduction to Linux. You can read more about Linux at HWS at math.hws.edu/about_linux.

There is one short exercise for you to complete for this pre-lab. You will create a text file and copy it into a folder that you will use regularly for homework that you submit for this course. You should try to do that before you leave Gulick 208 today. I will give you a token few homework points for completing this assignment.

Getting Into and Out of Linux

Linux, Windows, and Mac OS are operating systems that provide your basic interface to the computer. The computers in Gulick 208 are usually running the Windows operating system, but they are also set up to run Linux instead. There are actually many versions of Linux. The one we are using is called "Linux Mint."

To get into Linux, restart the computer if it is running Windows, or start the computer if it is turned off. (To restart, hit Control-Alt-Delete to get to the login screen. Then, use the small "power button" menu on the bottom-right of the login screen and select Restart.) As the computer starts up, there is a point where you are given a choice between "Windows" and "Linux Mint". Press the down-arrow key once to select "Linux Mint", and press return. You have about 30 seconds to do this. After a short time, you will see a Linux login screen.

Log in using the Linux user name and password that were assigned to you. (Your Linux user name is the same as your user name for email and for the campus network, but the password is different.)

Note: When you are finished using Linux, you should always restart the computer so that it will boot back into Windows. You can do this by selecting the icon on the bottom left of the Linux applications menu, then selecting Restart in the dialog box that pops up. You do not have to wait around for the restart to complete.

Some Configuration

You will see the following "Welcome Screen" the first time you log on to Linux. You will want to close it, but make sure to uncheck the box labeled "Show this dialog at startup" or you will have to close it every time you log in:

Click the "Menu" at the lower right corner of the screen to get to the Applications Menu, as shown at the right. This contains many programs that you can explore when you have the time. Now, click the third icon down on the left to open the "Cinnamon Settings" dialog so that you can change a few settings. I suggest the following: Go to the "Desktop" settings, check "Trash icon visible on desktop" and uncheck "Computer icon visible on desktop". Go to "Hot Corner" and uncheck "Hot corner enabled." But this is up to you.

More important, use the Application Menu to open a "Terminal" by clicking the fifth icon down from the top of the menu on the left. (Note: you can drag this icon into the panel, next to the word "Menu" as I did in the picture on the right to make it easier to open the Terminal in the future. You can also find Terminal in the Applications Menu under "Accessories".)

The Terminal is where you will do most of your work, at least for the first part of the course. The Terminal is a "command-line interface." You type commands to the computer, and the computer carries them out. As it executes the command, it might show output from the command in the Terminal. When the computer is ready to accept a command, it prints a prompt in the terminal.

Getting Started on the Command Line

You should be working in a Terminal. Here are a few commands you should use now. Type them exactly as shown, and press return after typing the command:

There are many more commands that you can use on the terminal. They will be introduced as they are needed. You can learn more in the "Command Line" section of the About Linux page, http://math.hws.edu/aboutlinux/commandline.html

Setting Up and Using Gedit

You will use gedit for Java programming, and you should make some changes to the gedit configuration to make it more suitable for writing programs. To do this, start up gedit again, by giving the command gedit in a terminal. Then, select the "Preferences" command from the "Edit" menu in the gedit menu. Change the settings in the "View" pane and in the "Editor" pane as follows:

Gedit Preferences Settings Dialog

That is, you want to check "Display Line Numbers", uncheck "Enable Text Wrapping", check "Highlight Matching Brackets", set "Tab Width" to 4, check "Insert Spaces Instead of Tabs", and check "Enable Automatic Indentation".

(The reasons for all this are that line breaks and indentation are important in programming. You don't want the editor to insert extra line breaks, and you will need to see line numbers. The rest of the changes will help you keep the indentation of the program regular. Checking "Highlight Matching Brackets" is optional but can be useful.)

Turning in Your Work for this Pre-lab

Quit from gedit so that you can work in the terminal again.

I would like you to copy the lab0 directory that you made to a location where I will be able to access it, since I don't have easy access to the files in your home directory. You will submit your work by copying it into a directory named /classes/cs124/zz9999, except that instead of typing "zz9999" you should type your own user name. This long name is a "full path name" that tells the computer exactly where to find something, no matter what current directory you are working in. The full path name /classes/cs124/zz9999 tells the computer "staring from the top of the file system (/), go into the directory named classes, then go into the directory named cs124, and find the file or directory named zz9999. (In this case it's a directory.) The full path name for your home directory is something like /home/zz9999.

Use the following commands in a Terminal to submit your work:

In future labs, you will create lab directories and submit them for grading in much the same way.

If you finish all of this before the class period ends, feel free to explore some of the programs in the application menu. One thing that you might do is start up the Firefox web browser and add the course web page, http://math.hws.edu/eck/cs124, to the Bookmarks.

Working Outside of Lab

This section is for your future reference. You will need to do a lot of programming work outside of lab. You have many options for working on Java programs on your own. Here are some things that you can try.