Taking Control with the PC Command Line

How to Use a Common Command Line on a Linux or Windows Computer

© Mark Alexander Bain

Jun 30, 2009
Taking Control with the PC Command Line, Mark Alexander Bain
The Linux command line is a powerful place to be, and that power is available to a Windows user as well. Now everyone can take complete control of their own computers.

The Linux command line is a place that the majority of computer users will never have been to. However, it is a place well worth visiting. That's because it gives the Linux user a vast array of powerful tools which are otherwise invisible to them. For example they can:

  • manage and manipulate files
  • compress and decompress files
  • search files for strings
  • see what processes are running
  • find out how much disk spaces is being used and which files are using that space

And the Windows user needn't feel left out, although they will need to install the ”Cygwin environment (see Cygwin: a Linux-like Environment for Windows ) to obtain the full range of tools available to the Linux user.

Getting to the Linux Command Line

The command line is a simple GUI (Graphical User Interface) and is accessed by.

  • running a terminal (or console) application (such as xterm) on Linux
  • running the Cygwin Bash Shell on Windows

The user can then use this to enter and run commands (as shown in figure 1 at the bottom of this article).

Finding Out What's Available

One thing that new Linux (or Linux-like) command line users will find interesting (if not a little disconcerting) is the naming of some of the commands. Some are self explanatory:

  • whoami – outputs the current user id
  • who – lists every logged on
  • file – returns a file type
  • find – searches for a file
  • env – displays the system environment variables

However, some command names are more obscure:

  • grep – searches a file for a string
  • tar – compresses a file (or files)
  • gawk – processes file contents

At this point there are two crucial commands that the user needs to be aware of:

  • man – the Linux manual pages
  • info – the Linux information documents

The user can, therefore obtain information on a command by typing (for example:

man grep

or

info grep

In this case the user would be able to read about the usage of the grep command (as shown in figure 2). And it's also worth knowing that key words (or phrases) can be searched for. For example:

man -k search

or:

info – k search

will return all subjects relevant to that key word (as can be seen in figure 3). However, the man search facility does tend to be more limited than the info search.

Joining Commands Together

Each of the Linux commands is very useful in it's own right, for example:

  • ps – lists all running processes
  • ps -W – lists all running processes on a Windows pc
  • wc – counts the lines, words and characters in file
  • wc -l – counts the lines in a file

However, they are made even more useful when joined together. And that's where the pipe comes in. The pipe sends the output of one command to the input of another. For example, the user can combine ps and wc to calculate the number of processes running on a Windows computer:

ps -W | wc -l

And so, by turning to the command line and combining Linux's in-built commands, the user can take control of every aspect of their computer's activities.


The copyright of the article Taking Control with the PC Command Line in Command Line Programming is owned by Mark Alexander Bain. Permission to republish Taking Control with the PC Command Line in print or online must be granted by the author in writing.


Taking Control with the PC Command Line, Mark Alexander Bain
Figure 1: A Linux Type Console, Mark Alexander Bain
Figure 2: The Linux Manual Entry for Grep, Mark Alexander Bain
Figure 3: Linux Information Documents Search, Mark Alexander Bain
 


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo