eHow launches Android app: Get the best of eHow on the go.

About

Unix Command Tutorial

Contributor
By Kristen Leigh Grubb
eHow Contributing Writer
(0 Ratings)

Although there are graphical user interfaces available for Unix systems, it is still common to type commands at the terminal window. If you are coming from a Windows background, this may be a very strange environment for you. Due to the large number of Unix commands, this tutorial will not cover individual commands; instead it will give you an overview of the command structure and how commands can be used. For a list of common Unix commands, see the Resources section, below.

    General Features

  1. A Unix command generally consists of a single word comprised of alphabetic characters. The Unix commands are also case sensitive and usually lowercase. The Unix designers created Unix for their own use, not the world at large, so the commands are comprised of the minimum number of keystrokes. That is why many Unix commands are simply between two and four letters in length, and even if they are longer, they are usually not dictionary words.
  2. Command Structure

  3. Commands are made up of the actual command and its arguments. The arguments are further broken down into the command options and other arguments. The options are predetermined for each command and can be found when reading the command documentation.
    The other arguments are usually file names. The arguments must be separated from the command and each other with whitespace (spaces and tabs). The whitespace can usually be one character or many, but it must be there. Also, the options are preceded by a minus (-). They can be separate or combined.

    For example, in the command:

    tar -xvf example.tar

    the command is "tar", the options are "-xvf" and the file name is "example.tar". You can also write the command as:

    tar -x -v -f example.tar

    This command extracts an archived tar file.
  4. Command Usage

  5. Unix commands are rather flexible in their usage. You can enter the commands in a variety of ways, as in the example above; you can combine them; and you can exceed the width of the terminal line. You can even type a new command before the previous command has finished executing.

    There are different ways to combine commands based on the output that you want. If you simply want to run one command, then to run the next you can combine the commands with a semicolon (;) between them. For example, the following commands change the current directory to the "/etc" directory and print the contents of that directory:

    cd /etc; ls -a

    You can also combine the commands in a way that redirects the output into a text file. The following example places the output of the example above and places it into a text file called "etc.txt":

    cd /etc; ls -a > etc.txt

    Although your commands will often be just a few characters long, there are times when the arguments will span more than the 80 characters on the terminal line. As long as you don't press "Enter" until you are finished with the command, the command will still work just fine.

    Sometimes the execution of the command will take a long time. During this time, there will be no command prompt at which to type the next command. However, Unix has a buffer that will hold any commands that you type until the previous command is finished, then execute the next command. You will not see the command you are typing, so be sure to type correctly.
  6. Command Documentation

  7. The Unix developers understood that there was no way anyone could remember all the Unix commands and all the options for each command. So they created the command documentation or man (manual) pages. This documentation is available on every Unix system unless specifically removed by the system administrator. You access the man pages at a command prompt by typing the command "man <command>". The man pages can be rather dry to read, but they are the best place to find all the information you need about a command. They often provide extensive usage examples.
Subscribe

Post a Comment

Post a Comment Post this comment to my Facebook Profile

Related Ads

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics