Functional Problem Solving (CSC 151 2014F) : Labs

Laboratory: Getting Started with Linux


Summary: This laboratory reviews some mechanics related to the use of the Computer Science Linux Network for CSC151. Specifically, this lab gives you the opportunity to explore (or at least configure):

Please don't be intimidated! Although this lab contains many details which may seem overwhelming at first, these mechanics will become familiar rather quickly. Feel free to talk to the instructor or with a CS tutor if you have questions or want additional help!

Logging In

Short Version

  • On the computer in front of you, you should see a small window that asks you to log in. If you don't see such a window, try hitting a key on the keyboard or clicking the power button on the monitor.
  • From the menu labeled Default Xsession, choose Xfce session instead. (You won't need to do this part again.)
  • Enter your user name. Press the Enter key.
  • Enter your password (which won't appear on the screen). Press the Enter key.
  • Get help if those previous two steps don't work.

Detailed Version

To use any of the computers on Grinnell's Linux network, one must log in, identifying oneself by giving a user name and a password. You will have received a Linux user name and password from the instructor if you did not already have one. If you have not received a Linux user name and password, or if you have forgotten either one, please tell your instructor.

When a Linux workstation is not in use, it will display a login screen with a space into which one can type one's user name and, later, one's password. (If the workstation's monitor is dark, move the mouse a bit and the login screen will appear.) This window belongs to xdm, the Xwindows Display Manager.

Before you log in, you should specify which window manager you want to use. Find the drop-down menu labeled Default Xsession. Click the triangle for the drop-down menu and choose Xfce session instead. move the mouse. In the future, xdm will remember Xfce as your preferred default, so you will not need to do this again.

Now, move the pointer onto any part of the box containing the login box. Type in your user name, in lower-case letters, and press the Enter key. The login screen will be redrawn to acknowledge your user name and to ask for your password; type it into the space provided and press Enter. (Because no one else should see your password, it is not displayed on screen as you type it.)

At this point, a computer program that is running on the workstation consults a table of valid user names and passwords. If it does not find the particular combination that you have supplied, it prints a brief message saying that the attempt to log in was unsuccessful and then returns to the login screen -- inviting you to try again. Consult the instructor or the system administrator if your attempts to log in are still unsuccessful.

The Linux/Xfce Window Environment

Short Version

  • You'll see something that looks somewhat like Microsoft Windows, but also somewhat different.
  • Icons at the bottom of the screen can be used to start programs.

Detailed Version

Once you have logged in, a control panel will appear at the bottom of the screen. Some other windows also may be visible in other parts of your screen. All of these areas are managed by a special program, called a window manager. On our network, login chores and other administrivia are handled by a program or operating system, called Linux, and the primary user interaction is handled by a window manager, called Xfce.

Practice with a Terminal Window: Changing Your Password

Short Version

  • Click on the icon that looks like a computer screen. (If you have no such icon, click on the icon of the small creature over a blue X that appears in the lower left corner of your screen. Then, select System and Terminal.) A window will appear that will let you type.
  • Type passphrase and hit the Enter key to change your password. You will be prompted for your old password and your new password. (The letters you type will not appear.)
  • Type exit and then hit the Enter key to close the window.

Detailed Version

While we can run several programs directly, we will need to invoke others by name. The computer program that reads and responds to such invocations is called the shell, and your interactions with the shell takes place in a window generated by a program called a terminal emulator, or terminal for short.

You may already have a Terminal window on screen. If not, look for an icon of a computer monitor near the lower-left corner of the screen. If you see this icon, move the pointer over the icon and click the left mouse button once to launch the Terminal.

If you do not see a Terminal icon, then move the pointer onto the applications menu icon at the bottom left of the panel (in Xfce, it looks like a creature on a blue X) and click once with the left mouse button. The applications menu will pop up. Move the mouse over System, then Terminal Click the left mouse button once to launch the Terminal.

In the terminal window, you will see a shell prompt -- the name of the workstation on which the shell is running, followed by a dollar sign. This prompt indicates that the shell is ready to receive instructions.

You type in such instructions using the keyboard. Move the mouse pointer into the Terminal window and click the left mouse button to make the window active. Notice that the window frame changes color following the click, indicating that the window has become active.

To get rid of the Terminal window, press Ctrl/D. That is, hold down either of the keys marked Ctrl, just below the Shift keys, and simultaneously press the D key. (On our workstations' keyboards, the keys marked Ctrl (“control”) and Alt (“alt” or “meta”) are somewhat like Shift keys, in the sense that they modify the effect of other keys that are pressed simultaneously.) The shell program interprets Ctrl/D as a signal that you have no more instructions for it and halts, and the terminal emulator closes the window automatically once the shell stops running. Alternatively, you may close a window by moving the mouse to the x at the top-right of the window, and clicking the left mouse button. Finally, you can usually type exit to close a terminal window.

It is a good idea to change the password associated with your account shortly after you receive it and every few months thereafter. The program that one uses to change one's password is “passphrase”.

Choose a new password. Make it something that you can easily remember, but not an English word or a name, since it is easy for system crackers to break in by guessing your password if you choose it from one of those categories. We'd also recommend that you choose a password of more than eight characters (a few words can be good - spaces are allowed).

Open a terminal window, select the window by clicking the left mouse button in it, and type the word passphrase. The password program prompts you once for your old password -- the one you logged in with -- and twice for your new password. Note that nothing will appear when you type your password. To ensure that no one eavesdrops on your password (or even the length of your password), the workstation leaves the cursor in place while you are typing passwords.

If you give your old password correctly and the two copies of your new password match, the program substitutes the new password for the old one in the table that the login program consults. The old password is discarded and will not be recognized in subsequent logins. (If the attempt to change the password fails for any reason, however, the old password is retained.)

A typical interaction to successfully change a password looks like this:

bourbaki$ passphrase
Changing NIS account information for user on hurd.cs.grinnell.edu.
Please enter old password:
Changing NIS password for user on hurd.cs.grinnell.edu.
Please enter new password:
Please retype new password:

The NIS password has been changed on hurd.cs.grinnell.edu.

bourbaki$ 

After running the password program, the shell takes over again and issues another prompt. You can invoke as many programs as you like from the shell, one after another, before pressing Ctrl/D or exit to leave the shell.

Iceweasel/Firefox

Short Version

  • Start Iceweasel by clicking on the picture of the small white creature grasping a purple sphere.
  • Agree to any dialog boxes that appear. They shouldn't appear again.
  • Learn how to get to the front door for this class.

Detailed Version

While some materials for this course will be available in paper, almost everything for this course (including electronic versions of paper materials) will be available on the World Wide Web. In this class, we use a version of the Firefox browser called Iceweasel. Almost all of the materials for this course will be distributed over the Web. To use Iceweasel to view materials, such as this course's syllabus and this lab, you may follow these steps:

First, prepare to use the World Wide Web by clicking on the Iceweasel icon (the picture with small white creature holding a purple sphere). Iceweasel is a version of Mozilla Firefox renamed to accommodate trademark issues. More info on the relationship between Firefox and Iceweasel can be found at http://en.wikipedia.org/wiki/Naming_conflict_between_Debian_and_Mozilla. We will generally use the names interchangeably.

If you do not see the Iceweasel icon, then move the pointer onto the applications menu icon at the bottom left of the panel (in Xfce, it looks like a creature on a blue X) and click once with the left mouse button. The applications menu will pop up. Move the mouse over Internet, then Iceweasel Click the left mouse button once to launch Iceweasel.

The first time you run Iceweasel on our network, two message boxes might appear.

  • One box might ask you to consent to the terms of a licensing agreement.
  • One box might request permission to create some configuration files in your home directory.

You should approve of any requests by clicking on the appropriate word. The pop-up boxes then disappear; you should not see them on subsequent uses of Iceweasel.

Initially, Iceweasel displays a World Wide Web document containing some default information. You should switch to the page http://www.cs.grinnell.edu, which is an entry point to the Computer Science Department's Web site.

We expect that most of you are already familiar with a Web browser. If not, please consult with one of us or with one of your colleagues.

To find material for this course, click on the “Curriculum” link in the menu on the left side. A new link for “Current courses” should appear. Click that. Find the entry for this course, Functional Problem-Solving, Section 01, and click on it to locate the front door for this course. Next, click on the Schedule link to view the current draft of the semester's schedule.

You can also connect to the Web page for this class by selecting Open Web Location from the File menu and then entering http://www.cs.grinnell.edu/~rebelsky/Courses/CSC151/2014F/.

Iceweasel Options

Short Version

  • Select Preferences from the Edit menu and update your home page to something reasonable like this course's front door or the Outlook Web Access page.
  • Quit and restart Iceweasel to verify that your new home page appears. If you see something other than your home page (e.g., the Grinnell College home page), then do the following:
    • Close Iceweasel.
    • Right-click on the Iceweasel launcher icon in the system tray (lower left of screen).
    • Choose "Properties" from the menu.
    • You will probably see the url http://www.grinnell.edu as part of the command. Delete this url!
    • Close the Properties dialog and try launching Iceweasel again. You should see your homepage.

Detailed Version

Each Linux user can configure Iceweasel to reflect her or his own preferences. Between logins, these preferences are stored in a file in the user's home directory; when Iceweasel is started during a later session, they are reinstated from that file.

Every user of Iceweasel in this class should establish a base page, a starting point for browsing. Here are the Uniform Resource Locators or URLs of some good choices:

To establish your base page, within Iceweasel, bring up the Edit menu from the menu bar and select the Preferences operation. A pop-up window appears, allowing you to configure many features of the general appearance of Iceweasel. Choose the Main option, if it has not been chosen already. The rectangle labeled Home Page contains the URL of some document that serves as the default. Replace the contents of this rectangle with the URL of your choice. (This does not have to be a permanent change; you can change your mind about this configuration at any time within Iceweasel.)

To erase the current contents of the Home Page Location(s) box, move the mouse pointer to the left of the first character in the box, press the left mouse button and hold it down, and drag the mouse pointer rightwards until the entire URL is displayed in reverse video, white letters on a black background. Then release the left mouse button and type the new URL; the old one will vanish as soon as you start typing. Once you have entered the new URL, move the mouse pointer onto the button marked OK at the bottom of the pop-up window and click on it with the left mouse button.

You can, of course, simply navigate to the page you want to use as your home page and then click on Use Current Pages.

You may note that the button says “Pages” (plural) rather than “Page” (singular). Since Iceweasel permits tabbed browsing (that is, you can have “tabs” within the same window that you switch between), you can have a home set of tabs. Particularly obsessive people might want to set up a sequence of tabs with say, links to labs, readings, and beyond.

Note that some folks have a default launcher for Iceweasel that is configured to start the web browser on a specific page, regardless of the home page you choose. If you don't see your new home page when you restart Iceweasel, then use the instructions in the "short version" above to change the configuration of the launcher.

Enabling Scripts

As you may know, there has been a rise in malicious programs (scripts) that reside on Web pages. For that reason, our system administrator has installed the NoScript plug-in which, by default, disallows scripts from every site.

However, many common services on campus, including Outlook Web Access and PioneerWeb, rely on scripts. Hence, we recommend that you enable scripting for sites in the grinnell.edu domain.

  • Navigate to a location in the grinnell.edu domain (such as http://office365.grinnell.edu).
  • You should see text at the bottom of the screen that says “Scripts Currently Forbidden”. You'll also see a symbol in the lower-left-hand corner of your window that looks like an S with a red slash through it. (If you don't see this text or symbol, this means that the NoScript plug-in is not installed. You can install it by visiting http://noscript.net/getit, or just skip over the next steps.)
  • Click on the Options... button. That button should bring up a menu.
  • Click on Allow grinnell.edu.

The GNU Image Manipulation Program (GIMP)

As you've probably heard by now, algorithms for creating and manipulating images are a central central theme of this course. The program that we are using to do image manipulation is called The GNU Image Manipulation Program, typically referred to as GIMP. Of course, we also need a language in which to express those algorithms and an environment in which to write those algorithms. GIMP comes with a language, called Script-Fu, for writing algorithms. Unfortunately, the environment for writing programs in GIMP is, to put it politely, rough. In response, we've built some tools that allow you to script GIMP using DrRacket, a novice-friendly program development environtment.

Your first task in getting the GIMP running correctly is to add an icon to the panel. (Almost as importantly, once you figure out how to add a GIMP icon, you will also be able to add other applications that you want to use.)

Short Version

  • Click and drag to copy the application launcher for the GNU Image Manipulation Program from the applications menu to the panel.

Detailed Version

Most user interface systems provide a convenient way to access commonly-used applications. In Xfce, we often add such applications to the panel. To add an application launcher to the panel, we can drag it from the applications menu into the panel. (There are also other ways to add application launchers to the panel, but this is the easiest one.)

  • Move the pointer onto the applications menu icon at the bottom left of the panel (in Xfce, it looks like a creature on a blue X) and click once with the left mouse button. The applications menu will pop up.
  • Find the Graphics menu and move the pointer over it.
  • Move the pointer over the menu item for the GNU Image Manipulation Program. Don't click yet!
  • Press the left mouse button and hold it down.
  • Drag the GIMP icon down to the area next to the applications menu icon. wait until a green plus sign appears over the GIMP icon and a blank space appears for the new icon.
  • Finally, let go of of the mouse button. You should see a new GIMP application launcher appear in the panel.

Of course, you should make sure that all of that worked. Click on the GIMP icon to see if the application starts. Then quit.

If you want to put the GIMP launcher in a different place on the task bar, you can right-click on the icon to move it.

Starting DrRacket

Most students should find that they already have a DrRacket launcher installed. It's a red and blue circle with a lambda in the middle. If your education did not include the Greek alphabet, a lambda looks a bit like an upside-down y.

If you don't have a launcher for DrRacket, you'll need to create one using similar instructions to those above. You can find DrRacket in the applications menu under Development.

For a variety of reasons, we have two versions of DrRacket installed in our system. The default version came with our operating system, and is a bit older, but it remains the default. The launcher uses the default version. However, for the course, we would prefer that you use the newer version. Hence, you need to reconfigure the launcher to use the new version.

  • Right click on the DrRacket launcher.
  • Select Properties. A Launcher window should appear with a line that reads “DrRacket - IDE for Racket”.
  • Double click on the DrRacket item. A new Edit Launcher window should appear.
  • Replace the current command with /opt/racket/bin/drracket.
  • Click Save. The edit window should close.
  • Click Close in the Launcher window. That window should close. You're done reconfiguring the launcher.

Once you have the DrRacket launcher configured, start and quit DrRacket to make sure that you are able to do so. We'll start using DrRacket in the near future.

Configuring Your Account for the Course

As we noted earlier, we use some custom software to make your work a bit easier. You'll need to set up that software. (Sorry, no explanations this time. Just magic incantations.)

  • Open a terminal window.
  • Type /home/rebelsky/bin/csc151-setup
  • Close the terminal window. You're done.

Working with Multiple Desktops

If you've kept all those windows open, you'll notice your screen is getting a bit crowded. Fortunately, a tool called the workspace switcher lets you uncrowd your windows by moving them among multiple desktops.

Short Version

  • Find the workspace switcher icon in the workspace toolbar.
  • Click on the switcher to move to a different desktop.
  • Drag windows within the switcher to move them to other desktops.

Detailed Version

In the toolbar at the bottom of the screen, you should see an icon that looks like a box containing four smaller boxes. (If you don't see it, ask for help.) This is the workspace switcher, a tool that lets you keep your application windows on several different desktops or workspaces.

The upper-left-hand box represents the desktop you are working on right now. It contains a number of still smaller boxes of varying shapes and sizes, which represent the windows you have open. When you move or resize the a window on the desktop, you should see the window's representation in the switcher move as well. Give it a try by wiggling one of your windows around.

Now, click in one of the other three boxes. You should see a new, blank desktop with no windows on it. Where did they go? If you look at the switcher, you'll see they are still in the desktop you started on. Switch back to that desktop.

You can also use the switcher to move windows from one desktop to another. Find the switcher again and identify the box that corresponds to your Iceweasel/Firefox window. Click that box and drag it a little ways to the right, onto the next desktop. The window should disappear from the first desktop. If you click onto the desktop to the right, you should see it there.

In this class, you'll usually need to work with multiple windows: The DrRacket window for your programs, various GIMP windows containing tools and images, and a web browser to read the laboratory exercises and reference materials. As you get settled in over the next few weeks, consider how you might use the switcher to help you organize your workspace efficiently.

By default, the workspace switcher presents four workspaces arranged in two rows of two each. If you want to change this configuration, right-click on the workspace switcher and select Properties to change the number of rows. Clicking on Workspace settings... will let you change the number of workspaces.

Finishing Up and Logging Out

If you've successfully logged in, changed your password, started Iceweasel, selected your base page, created an icon for the GIMP, started the GIMP, created an icon for DrRacket, configured your account, and played with multiple desktops, you've completed the lab and you can finally stop.

Short Version

  • To log out, click on your username at the lower right corner of the screen, and select Log Out.
  • Do not turn off the monitor or computers.

Detailed Version

When you are done using a workstation, you must log out in order to allow other people to use it. To log out, move the pointer onto your username, at the lower right corner of the screen, and click the left mouse button. A menu will pop up giving several options. Move the pointer onto the words Log Out at the bottom of the menu and click the left mouse button. A confirmation dialog will appear, giving you 30 seconds to change your mind. Click the Log out to log out immediately. The Xfce window manager vanishes, and after a few seconds the login screen reappears; this confirms that you're really logged out.

Please do not turn off the workstation when you are finished. The Linux workstations are designed to operate continuously; turning them off and on frequently actually shortens their life expectancy. We are working on finding ways to ensure that their power consumption is low when they are on but unused.