Lab 3: More UNIX:
Provide your answers in the spaces next to the questions. To begin, create
a directory lab3/ in your home directory, then cd to it.
- (0 points) Download (save link/page ) the file rasmol
to your home directory. This is a program to visualize biomolecules.
- (2 points) Download (save link/page ) the file 1BDD.pdb to your home directory. This is a biomolecule - a protein.
- (1 point ) Type ./rasmol 1BDD.pdb Why doesn't the viewer window open?
What needs to be done to fix the problem?
chmod +x rasmol
- (1 point) Now do ./rasmol 1BDD.pdb, go to "Display" pull-down menu and select
"Cartoons". How many helices (these look like thick matress springs)
does your protein have?
3
- (1 points) In the above command, did you use a relative or absolute path
to rasmol. (*for unix buffs:) Why it may not generally be a good idea to just do
rasmol 1BDD.pdb in this situation?
Relative. (* for unix buffs:) You use ./file to make sure
you execute the file in the directory you are in, and not in the "usual"
place like /usr/bin or /usr/local/bin,
where one keeps executables. The two may be different (e.g. different versions of the same code )
- (0 points) Create a directory structure under lab3 as follows
(the names with a / are directories and all others are files).
Take care to pay attention to the indentation, which reflects the nesting
of subdirectories.
- midwest/
- eastcoast/
- illinois/
- northwestern
- indiana/
- purdue
- notredame
- westcoast/
- california/
- berkeley
- stanford
- rockies/
- (2 points) By mistake, the midwestern states and their universities have been listed under
eastcoast. We are now trying to move the misplaced directories and their contents
together to the correct location, so that the directory structure looks like:
- midwest/
- illinois/
- northwestern
- indiana/
- purdue
- notredame
- eastcoast/
- westcoast/
- california/
- berkeley
- stanford
- rockies/
Write a mv command to achieve the desired effect. Note that the mv command implicitly
recurses through the given arguments so you can move entire directory trees (in contrast,
the cp and rm commands require the -r option to recursively copy to a new location or
recursively delete from a given location).
Before answering this question, first cd into the lab3 directory. Then type your mv
command from here. Write your command here below.
mv eastcoast/* midwest
- (4 points) Once again assume that you are now in the lab3 top-level directory. Write ls commands to list :
- the universities (not states or regions) that have the character ÔnÕ in them.
ls */*n*
- the universities (not states or regions) that start with the character ÔnÕ.
ls */n*
- the universities (not states or regions) that have at least three vowels.
ls */*[aeiou]*[aeiou]*[aeiou]*
- the states (but not their contents).
ls -d */*
You can assume that states are those directories at the second level of nesting.
The regular expressions that you concoct must perform their intended roles in any directory
system, not just for the example directory system given here. You are also not allowed to
solve the questions yourself and explicitly list the answers in the ls command.
- (2 points) Create two files called oldfile and newfile. Put some random text in each of
them. Make sure the contents are different so that it will help you in debugging and
understanding what is to follow. Then explain what each of the following four commands
below do.
(In answering this question, it will help you to inspect the contents of the relevant files
both before and after the command is executed, so that you can systematically try to infer
what is going on.)
- cat oldfile
simply dumps the contents of "oldfile" on the terminal.
- cat oldfile newfile
takes two arguments, dumps the contents of
"oldfile", followed by the contents of "newfile", on the terminal.
- cat oldfile > newfile
dumps the contents of "oldfile" but not on
the terminal. The ">" part of the command, redirects it to the file
"newfile", so that "newfile" now contains the contents of "oldfile".
In other words, this is the equivalent of a UNIX 'cp' command.
- cat > newfile
is just like the previous command but there are no
arguments to cat. Let us do a 'man cat' to see what it means to run
'cat' without arguments. You will see that this simply takes input
from the terminal and prints it back onto the terminal. When you type
this command, you will notice that UNIX is 'waiting' (for your input).
Keep typing something and press "Ctrl-D" to exit. Now, when you do a
'cat newfile' you will see that we have essentially created 'newfile'
and written into it.