CSC 161 Grinnell College Fall, 2011
Imperative Problem Solving and Data Structures

Basic Linux Commands and Capabilities — 3


This laboratory exercise continues the previous lab to discuss more Linux utilities and prepare you for compiling with the robots.


This lab continues work with the following basic capabilities and commands.

Topic Category Subtopics Linux Commands
Permissions user, group, world ls -l
setting permissions chmod
start up .bashrc, .bash_profile, umask, alias
Myro Setup Myro .bash Setup
Compiling the Long Way

Before progressing further in this lab, be sure you have completed the readings for this lab.

The Terminal Window

As with the previous lab, most work for this lab involves experimentation with a terminal window.

Directory and File Commands

The Linux Directory/File Hierarchy

In this section, we will explore part of the Linux file hierarchy.

Directory and File Permissions

The following steps ask you to review the permissions for your account directories and adjust them for this course.

  1. Move to your home directory and obtain a "long" listing of the files present using the commands:

       ls -l

    (The cd command without parameters takes you to your home directory.)

    Interpret the meaning of each part of the directory and file listings.

Setting Permissions

For CSC 161, it seems likely that you will want others in the class to be able to read your labs, since you are collaborating with others on that material. However, you do not want others to be able to read your supplemental problems. These steps set up this framework.

  1. Move to your home directory. Then allow others to read (but not change) your login directory with the command:

       chmod 755 .

    Next allow others to read (but not change) files in your labs directory:

       chmod 755 labs

    Now use the ls -l -a command to check that others can read your home directory and the labs subdirectory, but no other directories.

    Team up with another class member to check which directories of theirs you can read.

  2. Now suppose you set your home directory with the command:

       chmod 711 ~
    1. Can others obtain a listing of your home directory?
    2. Can others obtain a listing of your labs subdirectory?

    Consider what access you want others to have to your home directory and set it accordingly. Unless you want to protect a file against your own inadventent editing, you likely will want to retain 7 at the beginning of the chmod permission list.

Setting Terminal Defaults

  1. Review the material present in the .bashrc file in your home directory. Be sure you can explain the purpose of the alias commands.

Myro Setup

Setting Up Your .bashrc File

Although the following instructions may seem confusing to you right now, it will make more sense as the semester progresses. These next steps are necessary for you to be able to program with the Scribbler 2 throughout the course.

  1. Add the following lines to the bottom of your .bashrc file:

    ### MYRO LIBRARIES ###

    ## Myro C -- When using ##
    # include the location of the MyroC header #

    # include the location of the MyroC shared library object file #

    # make the libraries know to the execution environment #



You have just added three variables which will allow you to compile cleanly with the robots. Now, when we start using the robots, you'll be ready to compile and run your programs! Make sure to restart your Bash shell (terminal) so that all the updates are applied. You can also use the command: $ source .bashrc

Now we'll explore statements you just pasted into your .bashrc file in more detail.


This tells the compiler where to look for the MyroC header files (which is a big list of robot functions).

  1. C_INCLUDE_PATH="$C_INCLUDE_PATH:~walker/Myro/include/MyroC"


This tells the compiler where to look for the MyroC libraries (which tells the computer how to do the robot functions listed in the MyroC header files).

  1. LIBRARY_PATH="$LIBRARY_PATH:~walker/Myro/lib"


This tells the operating system where to look for the libraries when it's running your programs.

  1. LD_LIBRARY_PATH="$LS_LIBRARY_PATH:~walker/Myro/lib"


This statement exports all of your new environment variables into any future instances of your Bash shell.


By setting these environmental variables here, the computer will know where to find these packages when you work with the Scribbler 2 robots.

Reminder: Complete Evaluation Form

When you have finished this lab, be sure to fill out its evaluation form in the "Lab Evaluation" section for CSC 161 on Pioneer Web.

This document is available on the World Wide Web as

created 13 July 2011 by Henry M. Walker
last full revision 19 July 2011 by Erik Opavsky and David Cowden
minor editing 24 August 2011 by Henry M. Walker
last revision 28 August 2011 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at