| CSC 161 | Grinnell College | Fall, 2011 |
| Imperative Problem Solving and Data Structures | ||
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 | |
| C_INCLUDE_PATH | ||
| LIBRARY_PATH | ||
| LD_LIBRARY_PATH | ||
| export | ||
| Compiling the Long Way |
Before progressing further in this lab, be sure you have completed the readings for this lab.
As with the previous lab, most work for this lab involves experimentation with a terminal window.
In this section, we will explore part of the Linux file hierarchy.
The following steps ask you to review the permissions for your account directories and adjust them for this course.
Move to your home directory and obtain a "long" listing of the files present using the commands:
cd 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.
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.
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.
Now suppose you set your home directory with the command:
chmod 711 ~
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.
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.
### MYRO LIBRARIES ###
## Myro C -- When using libMyroC.so ##
# include the location of the MyroC header #
C_INCLUDE_PATH="$C_INCLUDE_PATH:/home/walker/Myro/include/MyroC"
# include the location of the MyroC shared library object file #
LIBRARY_PATH="$LIBRARY_PATH:/home/walker/Myro/lib"
# make the libraries know to the execution environment #
LD_LIBRARY_PATH="$LS_LIBRARY_PATH:/home/walker/Myro/lib"
export C_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH
######################
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).
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).
LIBRARY_PATH="$LIBRARY_PATH:~walker/Myro/lib"
This tells the operating system where to look for the libraries when it's running your programs.
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.
export C_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH
By setting these environmental variables here, the computer will know where to find these packages when you work with the Scribbler 2 robots.
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
http://www.walker.cs.grinnell.edu/courses/161.fa11/modules/module-getting-started/lab-linux-basics-3.shtml
|
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 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |