CIT 370 Homework #4 answer key
1. The Linux OS commands are primarily made up of individual programs (e.g., ls,
rm, sed, grep, etc). Compare the commands that you find in /bin and /usr/bin.
Why is there this division of files and what types of files would you expect to find
in /bin as opposed to /usr/bin?
/bin consists of Linux commands like cd, rm, mkdir, etc, and /usr/bin consists of
Linux applications software. The division is in part logical, to subdivide OS
kernel commands from applications software, and in part historical because /bin
was intended to fit on a single disk for installation purposes.
2. There are some peculiar programs to be found in Linux. For each of the programs
below, briefly state what the program does and then attempt to come up with a
reason for why you might use it.
a. false – this program just returns the value false. It can be used in shell
scripts or other circumstances where a programmer wants a false value
returned, perhaps during software testing.
b. seq – this program returns a sequence of integer numbers. Again, this
might be used in a shell script, for instance to assist in creating a file
where each line is numbered.
c. sleep – this program literally puts a process to sleep, that is, it suspends the
process for some time. This is useful when you want to surrender CPU
usage to other processes, or when a process should wait for some
circumstance to arise.
3. As a system administrator, you will often have to edit text files (if you look in
/etc, you will see a number of such files). Since you might be logging in
remotely, you would have to use one of the text-based editors, vi, emacs, ed.
Provide a reason why you would use any one of these. For instance, why would
you use vi over emacs or ed? Why would you use emacs over vi or ed? Why
would you use ed over vi or emacs? You will have to research ed as we did not
discuss it in class or the notes.
The primary use for vi is to edit small files particularly when you want to do it
quickly as vi will start up more quickly than emacs. Emacs on the other hand is
far better when editing large files such as book chapters, technical papers, or large
programs. Emacs features a macro facility to help with editing as well as features
like parenthesis and bracket matching when editing program code. The ed
program is an ancient line editor and useful only in situations where you want to
edit an entire line of a document, somewhat like what sed does. I personally
prefer emacs and will use it whenever I am doing anything but creating a small
text file or doing simple editing, in which case I will use vi.