Assignment Using Fundamental Unix Commands

 

Using Unix effectively in command mode means mastering the use of certain commands. There are certain high-frequency commands all users should learn. A case could be made for this particular list.

As an exercise in using these commands, please execute the command sequence given below. Do so on the remote unix machine, not a different one. Before doing so, there are three preparations you must perform. And there is accompanying reading.

Preparations

1) the commands assume the presence within your home directory of certain files. They're not there. So you have to put them there. Your home directory is a directory whose name is your user name. And it is a subdirectory of the directory /home. So if your user name is david, that of your home directory is /home/david. In the examples below "david" is used, reflecting the supposition that it is the user's username. In your case, please substitute for "david" your actual particular username instead. This exercise presupposes a certain subdirectory named taxonomy within your home directory. Please place it there now by unpacking it from a tar file (here's how) if you have not done so previously.

2) you need to "tape record" yourself while doing this exercise. You will then turn in the "tape" as your assignment submittal. Actually it's the script command that records your session into a file (here's how), and the resulting file is what you'll turn in.

3) create an "assignments" subdirectory in which to turn in your work if you have not already done so. Here's how.

The assignment itself

Be careful to type each command just as shown (with the above-noted directory name exception) preserving the sequence shown. Each command is there to demonstrate its effect to you, so please pause alertly after each command and focus attention on any evidence you can see showing what the command did. Be sure you understand what each command did as you move through the sequence.

script [what's this one for?]
cd
cd taxonomy
ls
ls -l
ls -R
ls -R | less [while in less, try pressing Enter, then spacebar, then up/down arrows; q to quit out of less]
cd animal
ls
ls -l
ls -R
cd fish
ls -l
cat salmon
cat trout
cat salmon trout
cat salmon trout > salmontrout
cat salmontrout
ls -lt [which file is listed first? why?]
find /home/david -name salmon -print
find /home/david -name corn -print
cd
ls
ls -a
cd taxonomy
cd animal
ls
cd fish
cp salmon /home/david/taxonomy/animal/mammal
cd /home/david/taxonomy/animal/mammal
ls
rm -i salmon
ls
cd
ls -R | grep ro [what do all the listed lines have in common?]
ps
ps ax
ps ax | less [remember, q to quit when finished perusing]
cd
cd taxonomy
pwd
rm -rf *
ls [where are all the files?]
cd /home/david
rmdir taxonomy
[press ctrl-D at this point to stop script from recording any further]

You are now in your home directory and it contains a freshly created file named "typescript." Change its name to "fundamentals" and then move it into your "assignments" subdirectory. These two steps both utilize the mv command, in its 2 different modes (renaming, and relocating). Do it as follows:

mv typescript fundamentals
mv fundamentals assignments

The first command renames rather than relocates because "fundamentals" is not the name of an existing subdirectory. The second command relocates rather than renames because "assignments" is.

You are now done. The "fundamentals" file you just created reposes in the /home/<your-username>/assignments directory. Thus, I'll find it and grade it. Make sure it's there because if not you have not turned anything in.

Tutorial websites

Here are a couple of intro-to-Unix websites. Their explanation of the individual commands may be helpful.

http://www.math.utah.edu/lab/unix/unix-tutorial.html

http://www.ee.surrey.ac.uk/Teaching/Unix/