Windows Administration at the Command Line



CHAPTER 1

USING THE COMMAND LINE EFFECTIVELY



Understanding Why the Command Line Is So Important

You might have been there the day that Microsoft released Windows. The original reason for this
product was twofold. First, it let users run more than one application at a time--something that
required a kludge at the DOS prompt. Second, it provided a friendly interface that made using a
computer easier. No longer did you have to remember command names; all of them appeared on
screen so you could simply select the command you wanted to execute. The first version of Win-
dows went over like a lead balloon, and the second version wasn't far behind, but by the third ver-
sion, Microsoft had something workable--something people could use to perform their tasks
without worrying about the command prompt.

Over the years Windows has delivered on its promise to make applications easier to use--at
least the applications that you must sit in front of to use. For example, I wouldn't consider going
back to a character mode word processor and I doubt very much that I'd want to write complex
applications at the command line. Unfortunately, computing activities aren't limited to those
tasks that you perform in real time in front of the display. Almost everyone has a task they must
perform in the background or at least when they aren't present. The most common task that you
should perform is backing up your data. Not only is there no need for you to be present when the
backup occurs, but using your computer can be detrimental to getting a good backup because
you should have all of the files closed. These non-interactive tasks always benefit from the com-
mand line because ease of use isn't an issue. When you perform a backup, you want it to be fast,
accurate, and repeatable.

Okay, so you can count the number of tasks you need to automate on one hand? However,
working at the command line can do a lot more for you than simply automate tasks that should take
place in the background. Have you ever searched for text within a file using the Windows GUI and
found that Windows Explorer can't locate text that you know appears within a certain folder?
Many people have and found Windows Explorer lacking. Even when Windows Explorer can find
the text, it isn't always accurate, and it's seldom fast. Interestingly enough, the command line offers
utilities that can make searching for specific files quite fast and always accurate. For example, the
FindStr utility discussed in Chapter 4 can help you locate text in any kind of file. You can even look
inside binary files such as executables for particular strings. Everyone needs to search for data and
using the command line is usually faster than working with a GUI simply because the GUI gets in
the way and slows things down.

Security has become a major issue with every cracker on the Internet seeking entry to your
machine. However, have you ever wondered what's really running on your machine? You can't tell
from the GUI. The best view you can get is Processes tab of the Task Manager that you can access
by right-clicking the Taskbar and choosing Task Manager from the context menu. Figure 1.1 shows
the output from this application.

Unfortunately, Figure 1.1 shows only part of the story at best. For one thing, all of those SvcHost
entries hide services that are running on your system, which could be anything from the driver for
your display adapter to a Windows service that is leaving you wide open to attack. However, you
can't tell what's running on your system from Figure 1.1. Figure 1.2 shows the output of the
TaskList command line utility. Suddenly you know about all of those SvcHost entries. As you can
see, a single entry can host more than a few services. In addition, you now have access to a special
number, the Process Identifier (PID). The PID lets you learn more about the application. In short,
if you really want to know what your system is doing, you have to use the command line to do it.
Don't worry too much about the TaskList utility right now, you'll find a discussion of its full capa-
bilities in Chapter 5.