PHYSICS 2235
Lab 01

This is Lab 01 for Physics 2235, Spring Semester 2018. As will be typical for this class, it begins with a series of exercises to reinforce the new topics for the day. It concludes with a mandatory assignment problem set to be submitted by the end of the lab. The submission instructions are given with today's problem set.

Exercise 0.

These exercises assume you have opened an x-terminal on one of the physics department servers, as demonstrated by the instructor. You must have a web browser open too, or you wouldn't be reading this!

Exercise 1.

Open an xterm and determine your "working directory" (think of this as your location in the linux file structure) by typing "pwd" (present working directory) at the prompt. If you have just logged on to your machine or have just opened an xterm application, this directory is your "home directory". (Here it is assumed that your working directory is set to your home directory.)

The result of "pwd" may be a little messy, but after the last slash character "/", you should see your username, after which your home directory is named. This long-ish thing, maybe of the form /u/stu/p2235/myname, is called the "full path name" for your home directory.

Next, create a "subdirectory" called "levelone" using

mkdir levelone
Check that this was successful by typing "ls" (the list command). Try some of the variants of the ls command:
ls
ls -l 
ls -lt
la -lrt 
ls -d level*
ls -d level??
ls -d level???
(These might be more useful once you've accumulated some more files in your directory.)

The options available after a linux command (like -l or -t) can in general be found in the manual page for each command. To access the man page for the comman ls for example type:
man ls 
scroll through some of the options with arrow or space . To exit type q or Ctrl-D
ls --help
should also work. scroll up with your mouse to read about the command and it's options.

Now, move to directory "levelone" by typing the "change directory" command

cd levelone
Then type "pwd" to verify that you have moved your working directory to "levelone".

Type "ls". The directory should have no files in it, as this command will indicate. Create a new subdirectory (within dir "levelone") called "leveltwo". Change your working directory to this new subdirectory and type "pwd". Notice that linux directory levels are delimited by the slash ("/") symbol.

Try moving back to directory "levelone" using

cd levelone
Why does this fail? Answer: the cd command, when used in the manner just shown, thinks you want to change to subdirectory of leveltwo called levelone. However leveltwo has no subdirectories; indeed it has nothing in it.

Return to your home directory using "cd" and the "full path name", that is, the thing that was printed out by the pwd command when your working directory was your home directory (e.g., /u/stu/p2235/myname).

Note, in linux, all full path names begin with a "/". In the examples above with the "levelxxx" (using directory names which were not preceded by a "/"), you specified a "relative path name", that is a directory whose location is determined relative to your current location in the file structure.

Actually, you can get to the top of the whole linux file structure by typing

cd /
Type "pwd" and an "ls" to see what file or directories reside here. Don't mess with these! Return to your home by using a sequence of "cd" commands with relative path names, e.g.,
cd u
pwd
cd stu
pwd
...

Since getting to your home directory is so fundamental, there are a bunch of ways to do it. The easiest is typing just "cd" all by itself.

Try using the special "~" character.

cd ~
cd ~/.
(The "." means the current directory, and in this context says "go to the home dir ("~") and then stay there ("."))".

Note that other users' home directories can be accessed with the "~" symbol. For example, the p2235 class account has a home directory of ~p2235, so try

cd ~p2235
ls

Finally, you should acquaint yourself with ways to move up the file hierarchy. Two periods, "..", will move you up one level. Experiment with this; also try

cd ../..
cd ../../..

Exercise 2.

This exercise has to do with file manipulation. Use the "cp" command to copy the file "file1" from the ~p2235/examples directory to your home directory. The syntax for "cp" is

cp file1 file2
where file1 is a filename and file2 is a pathname (either a filename or a directory). For more details on how to use it (or other shell commands), type
man cp
Push the space-bar to scroll down the "man page".

Do an "ls" to make sure the copy worked. Look at the file with the "more" or "less" command. (When done, typing "q" gets you back to your shell.) Also, look at it with the "cat" command.

Move ("mv") file1 to the filename "filea".

Copy all files of the form "file?" from directory ~p2235/examples to your home directory. (As a good habit, you should use "ls" to see which files are in that directory before you copy them over....)

Use "cat" to see what is in these files. Also try out the "grep" command:

grep jjjj file1
grep Editor file?
grep baboon file*

Finally, remove these files with the "rm" command:

rm file1
rm -f file2
rm file?

Note the (possibly risky) use of the "-f" directive in the second line.

Exercise 3.

The purpose of this exercise is to introduce you to the emacs editor.

Start up emacs from your shell using

emacs &
(or use the mouse buttons on your X-term). Note the ampersand indicates that emacs should run "in the background" and should not tie up your shell command line.

Use the pull-down menu bar options ("Buffers" "Files" etc.) to open a new file called "file1". Try typing text into the file's "buffer" and saving it. Then, type "cat file1" on your shell's command line and see that the file was saved as expected.

You should also take the emacs tutorial (see the "Help" pull down menu). This will show you how to free yourself from using the mouse when you are editing. For example,typing Ctrl-X and Ctrl-F opens a file which emacs uses to create a "buffer" that can be edited. If the file already exists, it will be loaded into your buffer.Ctrl-X and Ctrl-S saves your current buffer to the file, and Ctrl-X Ctrl-C exits emacs.


Mandatory Assignment, due to today.

Problem 1

The assignments, exams, and projects for this course will be submitted electronically using the submit command. The purpose of this problem is to practice using this command. Email will be sent to your physics department account with your grade for the assignment as well as any grader comments.

Some general instructions for this system are:

Two common pitfalls of this system are:

  1. Submitting files with names that do not exactly match what the assignment requires. In linux, remember that file names are case-sensitive.
  2. The grade report will be sent to your physics department computer account, the same account from which you must submit the assignment. If you use another email system (gmail, yahoo...) you will not receive the report unless you select email forwarding by creating a ".forward" file in your home directory which contains your email address of choice.
Discuss these points with the instructor/TA if you have any questions.

Now, please perform the following:

  1. Using Exercise 3 above as a guide, create a file called exactly
    MyLab01.txt
    
  2. In this file, write a one-paragraph account of what you did for your winter break. Save this file and exit emacs.
  3. Submit your file for grading with the command:
     submit p2235 Lab01 MyLab01.txt 
  4. Check your submission with the command:
     submit p2235 Lab01 
    You should get a notice that your file has been received.
  5. Await your grade report via email (may take a few days...)





Back to main Physics 2235 page