Getting Started


Logging On

Since Unix is a multi-user system, each individual user must identify themselves to the system for exclusive access to their accounts (and all corresponding files). This is done with a unique username and an associated password. Typically, your user name is assigned to you by a system administrator; your password being initially set by the administrator as well. Your password can then be changed (by you) at a later time (see the passwd command).

To begin the login process, a user must establish a connection to the machine they wish to login into. If the machine is physically near by, this may be as simple as powering the machine on and entering your username and password.

However, sometimes Unix systems are physically remote from the user, so the user must connect to the system using another method. One common way to do this (across a variety of different hardware systems) is using a remote connection application such as telnet, or more preferably a secure application such as ssh 1. This connection application will consist of a program running on the local (client-side) machine as well as a program running on the destination (server-side) machine. Once the connection application is started, the user can then enter the qualified name (or IP address) of the remote machine to begin the connection session.

Once the connections are made and the session is established, the user should see something similar to the following:

   Red Hat Linux release 7.3 (Valhalla)
   Kernel 2.4.18-3 on an i686
   login:
At this point the user types their user name at the login: prompt followed by pressing the Enter key (denoted by [Enter]). Once this is complete, the user will see the Password: prompt, whereas the user enters their account password followed by the Enter key (see example below). Note that the password characters will not be displayed when typed. For security reasons, most systems will not display any characters when a password is entered, as opposed to ***** or the like being displayed. Why is this important?
   Red Hat Linux release 7.3 (Valhalla)
   Kernel 2.4.18-3 on an i686
   login: mthomas [Enter]
   Password: 
As previously mentioned, remember to always, always keep the following in mind.

Once you have successfully logged into the system, you will see one or more characters on your screen. This character string is referred to as the command prompt or shell prompt. Following the command prompt is where the user types in (submits) commands to the system. The prompt may be a simple single character such as a $ or %, or it may be something more complex such as the following:

   [/home/mthomas]$
which would serve to indicate a users current location in the file system heirarchy.

1 The preferred secure application for remote connections is the secure shell application (ssh), assuming this application is installed on your system. If an ssh application is not present on your system, a very good, free ssh application is PuTTY (see www.putty.org).


Logging Off

Logging off of a Unix system is fairly straight forward, and can be accomplished in several ways.

The first way which should always work is by holding down the Ctrl key and pressing the character d key at the same time. This is commonly referred to and written as a [Ctrl-d] sequence.

Another technique that will typically work is by typing the command exit at the command prompt followed by the [Enter] key.

While there are other ways to exit from a Unix system, these two are the most common and should serve your needs adequately. While it may be common practice today to exit from some systems by turning the power off, this is not the case with Unix and this practice should be avoided. Also note that if the connection to the Unix machine was made using an application program such as a secure shell application (ssh), this application will also need to be terminated. It is also worthy to note that if using a connection application such as ssh, it is not advisable to just terminate the application without logging off, since it is not guaranteed the the login connection will be terminated.


On-line Manual

Before beginning the discussion of Unix commands and command format in general, let's discuss where to find information about commands on a Unix system.

Information about interacting with a Unix system is found in the on-line manual, or as they are commonly referred to, the man pages. Information about most (if not all) commands and topics are found in the man pages.

As with any manual or reference material, before you can get information about a topic, you need to know how to look it up. In this respect, Unix is no different. You must know the name of the command before you can view the manual page for it. If you want to know how to copy files on a Unix system, you need to know what the command to copy files is (and no, it's not copy). It is here where some of the initial difficulty begins (see commands below).

Unix man pages are the key to understanding a Unix system, so do not underestimate their value!

The command to view the manual pages is man and the general syntax for using the man command is:

   $ man command_you_want_to_see_the_manual_entry_for [Enter]
For example, the command:
   $ man man [Enter]
will display the manual pages for the man command. Similarly, the following will display the manual pages for the ls command:
   $ man ls [Enter]

Commands for basic navigatation through the man pages for a specific command are as follows:

Looking at the example from above

   $ man ls [Enter]
will yield an the following typical man page (not in its entirety):


   LS(1)                                                    LS(1)
 
   NAME
          ls - list directory contents
 
   SYNOPSIS
          ls [OPTION]... [FILE]...
 
   DESCRIPTION
          List  information  about  the  FILEs  (the  current directory by default).
          Sort entries alphabetically if none of -cftuSUX nor --sort.
 
          -a, --all
              do not hide entries starting with .
 
          -A, --almost-all
                 do not list implied . and ..

          -C     list entries by columns

			



Pay close attention to the different parts of the man page, specifically the NAME of the command, a brief SYNOPSIS of the command, a DESCRIPTION of the commands options, etc. Also pay close attention to the number of required (i.e. not optional) options and/or arguments in the SYNOPSIS section. Note that brackets (e.g. [ ]) enclosing OPTIONs or ARGUMENTs indicate these are optional. In the example above, the minimun number of options and arguments is zero for each, where this will not always be the case.

Finally note that the number following the command in parentheses documents which section of the man pages the page displayed is from. In general, the following describe the manual sections:

   1 : User-level commands 
   2 : System calls 
   3 : Library functions 
   4 : Devices and device drivers 
   5 : File formats 
   6 : Games 
   7 : Various miscellaneous stuff - macro packages etc. 
   8 : System maintenance and operation commands 

Commands and Command Format

As mentioned, once the user has successfully logged into the system, the user will enter commands to accomplish the required task. Commands in Unix follow a (typically) consistent format, i.e.:

   cmd [-options] [arguments]
recall the square brackets ([ ]) indicate optional presence. Thus a command can have no options (also referred to as flags) nor arguments and stand alone, a command can have one option and zero arguments, a command can have several options and zero arguments, a command can have zero options and one argument, zero options and several arguments, or several options and several arguments, etc.

What is important to note is some commands have specific requirements as to their format, and other commands have little to no requirements at all. Also of note is that typically the order of the flags does not matter (but not always, depending upon the cmd/flags used). Also, options usually (but not always) begin with a single dash (-), and multiple options can be combined with a single dash.

Looking at some examples, following is a command with zero options and zero arguments, followed by the output of that command (note the blank line following the ls command is for clarity). What does this command do, you ask? Answer: Use the man pages!

   $ ls [Enter]

   bin   bru  etc   lib         misc  nohup.out  quota.group  root  tmp  var
   boot  dev  home  lost+found  mnt   proc       quota.user   sbin  usr
Following is a command with one option (the letter ell) and zero arguments, followed by the output of that command. What does this command/options do, you ask? Answer: ?
   $ ls -l [Enter]

   drwxr-xr-x   2 root     root         2048 Feb  3  2000 bin
   drwxr-xr-x   2 root     root         1024 Jan 26  2000 boot
   drwxr-xr-x   2 root     root         1024 Feb  3  2000 bru
   drwxr-xr-x   6 root     root        34816 Mar 25 04:02 dev
   drwxr-xr-x  36 root     root         3072 Mar 19 19:55 etc
   drwxr-xr-x  58 root     root         2048 Mar 19 19:55 home
   drwxr-xr-x   4 root     root         3072 Jan 20  2000 lib
   drwxr-xr-x   2 root     root        12288 Jan 20  2000 lost+found
   drwxr-xr-x   2 root     root         1024 Apr  9  1999 misc
   drwxr-xr-x   4 root     root         1024 Jan 20  2000 mnt
   -rw-r--r--   1 root     root            0 Jan 28  2000 nohup.out
   dr-xr-xr-x  47 root     root            0 Nov 22 09:16 proc
   -rw-------   1 root     root        19104 Mar 26 14:59 quota.group
   -rw-------   1 root     root        19072 Mar 25 04:03 quota.user
   drwxr-x---  12 root     root         1024 Mar 26 04:05 root
   drwxr-xr-x   3 root     root         3072 Jan 20  2000 sbin
   drwxrwxrwt   6 root     root         2048 Mar 26 04:02 tmp
   drwxr-xr-x  21 root     root         1024 Sep 12  1997 usr
   drwxr-xr-x  21 root     root         1024 Jan 20  2000 var
Following is a command with two options and zero arguments, followed by the output of that command. What does this command/options do? What happens if the two options are switched (e.g. -al)?
   $ ls -la [Enter]

   drwxr-xr-x  19 root     root         1024 Nov  5  1997 .
   drwxr-xr-x  19 root     root         1024 Nov  5  1997 ..
   drwxr-xr-x   2 root     root         1024 Apr  8  1999 .automount
   -rw-------   1 root     root           34 Jan 27  2000 .bash_history
   drwxr-xr-x   2 root     root         2048 Feb  3  2000 bin
   drwxr-xr-x   2 root     root         1024 Jan 26  2000 boot
   drwxr-xr-x   2 root     root         1024 Feb  3  2000 bru
   drwxr-xr-x   6 root     root        34816 Mar 25 04:02 dev
   drwxr-xr-x  36 root     root         3072 Mar 19 19:55 etc
   drwxr-xr-x  58 root     root         2048 Mar 19 19:55 home
   drwxr-xr-x   4 root     root         3072 Jan 20  2000 lib
   drwxr-xr-x   2 root     root        12288 Jan 20  2000 lost+found
   drwxr-xr-x   2 root     root         1024 Apr  9  1999 misc
   drwxr-xr-x   4 root     root         1024 Jan 20  2000 mnt
   -rw-r--r--   1 root     root            0 Jan 28  2000 nohup.out
   dr-xr-xr-x  47 root     root            0 Nov 22 09:16 proc
   -rw-------   1 root     root        19104 Mar 26 14:59 quota.group
   -rw-------   1 root     root        19072 Mar 25 04:03 quota.user
   drwxr-x---  12 root     root         1024 Mar 26 04:05 root
   drwxr-xr-x   3 root     root         3072 Jan 20  2000 sbin
   drwxrwxrwt   6 root     root         2048 Mar 26 04:02 tmp
   drwxr-xr-x  21 root     root         1024 Sep 12  1997 usr
   drwxr-xr-x  21 root     root         1024 Jan 20  2000 var
Eventually the question will be asked "How do we figure out what commands do what?" The best answer to address this is experience, and the man pages, of course. But there are some general methods to the seeming command madness, for example: The general rule is to pay close attention to the man pages and understand what you are trying to do, as well as paying close attention to what the system is telling you, no matter how cryptic this may appear (see next section).

Errors and Error Messages

Experiencing errors in Unix for the first time can be somewhat overwhelming. To begin, when nothing is output (or nothing unexpected is output) following command completion, this implies success. The system will not (typically) notify you of a successful command.

It will however, notify you immediately of an erroneous or unsuccessful command. When new to this, error notification can be somewhat confusing. Take your time and read the error message in its entirety and try to understand what the error is telling you. Also, when encountering errors in Unix, it is almost always the user who is at fault, and not the Unix system itself (unlike other, unnamed operating systems). Do not blame the system, look closely at what you are typing to identify the error.

In the following, the error message reported is that something is not found. Can you identify what is "not found"? If you pay close attention to the first part of the error message, you may notice that the ksh program is the application that is reporting the error. And if you dissect this error message further, you might understand that the ksh application is reporting the command (or program) lss is not found. This is due to lss being a typographical error and what the user intended was to type ls.

   $ lss [Enter]           
   ksh: lss: not found
In the following example, what is the application program that is reporting the error? You should note that the invalid option error is reported by the ls command, and the option it does not like is the y option.
   $ ls -y [Enter]
   ls: invalid option -- y
Finally, examine the following error. What is the program that is reporting the error? What is the error it is reporting?
   $ cp my_file1 my_file2 [Enter]          
   cp: my_file1: No such file or directory
When this command works correctly, you will simply get the command prompt back as follows:
   $ cp my_file1 my_file2 [Enter]         
   $
Notice there is no notification of any completion status, successful or not. (Note: in later sections, we will learn how to tell if a command was successful (and what that means) or not.)

Command Summary




©2019, Mark A. Thomas. All Rights Reserved.