resources are required for a task, such as a shell script. (Here, time is used to
measure the duration of elapsed time; the command that deals with civil and
sidereal time is the date command.) This command is used with the name of
another command (or script) as an argument, like this:
Click here to view code image
matthew@seymour:~$ sudo time -p find / -name conky
/home/matthew/conky
/etc/conky
/usr/lib/conky
/usr/bin/conky
real 30.19
user 1.09
sys 2.77
Output of the command displays the time from start to finish, along with the
user and system time required. Other factors you can query include memory,
CPU usage, and file system input/output (I/O) statistics. See the time
command’s man page for more details.
The top command is covered in Chapter 12, “Command-Line Masterclass,
Part 2.” It has some even-more-powerful cousins worth mentioning here.
One option for monitoring resource usage is called htop. It is not installed
by default but is available from the Ubuntu software repositories and is worth
a minute or two of your consideration when you’re familiar with top. Here
are some key differences:
With htop, you can scroll the list vertically and horizontally to see all
processes and complete command lines.
With top, you are subject to a delay for each unassigned key you press
(which is especially annoying when multikey escape sequences are
triggered by accident).
htop starts faster. (top seems to collect data for a while before
displaying anything.)
With htop, you don’t need to type the process number to kill a process;
with top, you do.
With htop, you don’t need to type the process number or the priority
value to renice a process; with top, you do.
htop supports mouse operation; top doesn’t.
top is older and therefore more used and tested.