Chapter 4. Some Basic Utilities
4.1. Analysis
In the previous chapter it might seem like we did not accomplish very much. A lot of energy was expended
redesigning the root disk, but the functionality is basically the same as in the initial prototype phase. The root
disk still does not do very much. But we did make significant improvements when it comes to space savings.
In this chapter we will put that extra space to good use and start cramming the root disk with as many utilities
as it can hold.
The first two root disks we built only had shell built−in commands like echo and pwd. This time it would be
nice to have some of the commonly used external commands like cat, ls, mkdir, rm and such on the root
disk. Keeping this in mind we can define the goals for this phase as follows:
Retain all of the functionality from the previous root disk.
•
Add some of the commonly used external commands.
•
4.2. Design
4.2.1. Determining Required Commands
The first question that might come to mind is, "How do we know which commands are needed?" It is possible
to just start with cat and ls then install other commands as we discover a need for them. But this is terribly
inefficient. We need a plan or a blueprint to work from. For this we can turn to the Filesystem Hierarchy
Standard (FHS) available from http://www.pathname.com/fhs/. The FHS dictates which commands should be
present on a Linux system and where they should be placed in the directory structure.
4.2.2. Locating Source Code
The next logical question is, "Now that we know what we need, where do we get the source code?" One way
to find the answer to this question is to check the manpages. We can either search the manpages included with
one of the popular GNU/Linux distributions or use one of the manpage search engines listed at
http://www.tldp.org/docs.html#man. One thing that should tip us off as to where to find the source code for a
particular command is the email address listed for reporting bugs. For example the cat manpage lists
bug−[email protected]. From this email address we can deduce that cat is part of the textutils package from
GNU.
4.2.3. Leveraging FHS
So let's look at the FHS requirements for the
/bin
directory. The first few commands in the list are cat,
chgrp
, chmod, chown and cp. We already know that cat is part of GNU's textutils. Using the next few
commands as keywords in a manpage search we discover that we need GNU's fileutils package for chmod,
chgrp
, chown and cp. In fact quite a few of the commands in
/bin
come from GNU's fileutils. The date
command also comes from a GNU package called sh−utils. So a good way to tackle the problem of finding
source code might be to group the commands together by package as shown below.
The BASH shell −− echo, false, pwd, sh, true
•
GNU textutils −− cat
•
Chapter 4. Some Basic Utilities
16