These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Entering Commands I

Classnotes | UNIX01 | RecentChanges | Preferences

Showing revision 1
When you enter commands into a shell interface, you will typically see a command prompt similar to this:
 [hart@einstein hart]$

The basic format of these lines is as follows:

 user@hostname path [$|#]

where

  • user is whatever user you are logged in as.
  • hostname is the hostname of whatever computer you are logged in to.
  • path is the path of your current working directory.
  • $ or # determines whether you are logged in as a normal user ($) or an administrator (#).

Thus, in our example above, user "hart" was logged into the machine "einstein" and was sitting in the "hart" directory. The "$" indicated that user "hart" was not and administrator.

This command prompt is actually programmable, and you can make it look however you desire (including using colors). Here are some example alternative command prompts from various UNIXes:

From Debian GNU/Linux?:

 sam@rygel:~/work$

From Sun Solaris:

 (Fri/Jul/11)-(11:26PM)-(\l:root@tux4kids)-(/opt/home/shart)
 #

Entering Commands

To run a program or enter a command, you simply type it at the command line. For example, if I were to run the Mozilla web-browser from the command line, I would type (excluding the shell prompt):
 $ mozilla

This command would start Mozilla and occupy the console. If I were to pass a control character to the running program (such as "CTRL-C", or "interrupt") then the program would deal with it. However, I would not be able to type any additional commands in the console. The reason for this (as we shall see when we examine pipes) is because the shell is really just piping the output from the running program to the console.

If you wanted to run a program in the background (meaning that the program does not lock the console), you would append the "&" symbol:

 $ mozilla &

Be careful using the "&" as some very simple CLI commands do not run well in the background.

Basic Commands

We will now examine some of the more common commands and programs which you can run from the command line. Many of these do have correlations with commands in DOS or CP/M, however all of them have more rich options and abilities.

ls

The ls command is the one which you should become the most familier with. It "lists directory contents". The DOS equivalent is "DIR". Simply typing "ls" will produce a short, truncated, listing of the files and directories inside your current working directory. It will not display any hidden files or directories by default.

If you want a more extensive listing of files and directories in your current working directory, then you will want to run something similar to:

 $ ls -la

Where the "l" option indicates you want a "long" listing, and the "a" option indicates you want to see all of the files (even the hidden ones and implied "." and ".." directories).

If you would like to see all of "ls"'s options, then issue a

 $ ls --help

Compatability Note: In recent versions of Red Hat, the "ls" program has been broken!


Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions | View current revision
Edited July 12, 2003 3:48 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.