This is Lab 01 for Physics 2235, Fall 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.
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!
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 leveloneCheck 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.)
man lsscroll through some of the options with arrow or space . To exit type q or Ctrl-D
ls --helpshould 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 leveloneThen 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 leveloneWhy 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 ../../..
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 pathto/file2where 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
cp pathto/file1 .You can also specify the path to the file you are copying to your current location
man cpPush 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.
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.
Some general instructions for this system are:
Two common pitfalls of this system are:
Now, please perform the following:
submit p2235 Lab01 MyLab01.txt
submit p2235 Lab01You should get a notice that your file has been received.