FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

Running Commands


Notes:

Entering commands:

Commands must be entered in lowercase. For example:
type: cal and press [return]
This displays a calendar for the current month

Correcting mistakes:

Unix is an old operating system designed to be run on many different types of terminals, some without backspace or delete keys. When you are logging in to a remote system, you may find that the backspace key does not correct your typing mistakes. The following control keys should work on any Unix system:

  1. [Ctrl-h] is the equivalent of the backspace key.
     
  2. [Ctrl-u] erases the entire line.
     
  3. [Ctrl-d] signals end-of-input or end-of-file. Usually when you enter a command, the operating system will execute the command and then display the command prompt again. If the command prompt doesn't re-appear, the system may be waiting for keyboard input; try pressing [ctrl-d] to signal end-of-file.
     
  4. [Ctrl-c] interrupts and cancels the current process. If [ctrl-d] doesn't bring back the prompt, try [ctrl-c].

Command arguments:

Many commands are used with one or more arguments. For example:

  1. cal (no arguments) prints a calendar for the current month.
     
  2. cal 2000 (one argument) prints a calendar for the year 2000.
     
  3. cal 10 2000 (10 and 2000 are both arguments) prints a calendar for October, 2000. 

Command options:

You can also specify options which modify the behaviour of a command. Options appear immediately after the command, they are usually entered as a - followed by a single letter. For example:

  1. cal -j 2000 (j is an option) produces a julian calendar for the year 2000.
     
  2. cal -y (y is an option) prints a calendar for the current year.
     
  3. cal -yj  (2 options) prints a julian calendar for the current year. 

Getting help:

The traditional unix help system is the man command. To get help about the cal command, type: man cal.

Once a man page is displayed, the following commands navigate the document:

Note: on floppix, the man command is only simulated, so the help is often terse and none of the options for the man command are available. 

Command history:

The bash shell saves all of the commands you've entered (up to some pre-defined limit). When you logout, these commands are saved in a file in your own home directory called .bash_history so that the command history is even preserved between login sessions. The command history can be used in a number of ways, but the simplest is to use the up-arrow key to recall previous commands. Once the command is displayed, you can execute it immediately by pressing [enter] or modify the command and then press [enter].

Command completion:

If you are entering long commands or filenames, you seldom have to type the entire string; type enough letters for bash to recognize the text and then press the [tab] key. Bash will fill in the remaining letters for you. If there is more than one option, the shell will beep. Pressing the [tab] key a second time will produce a list of possible matches for the text you have entered.


Exercises:

  1. Load Floppix and login using your initials.
     
  2. Try a few commands:
  3. Try entering a command in upper case. For example:  CAL
    What error message is displayed?  _________________________
    Why? ___________________________________
     
  4. Try the following experiment in using [Ctrl-d] and [Ctrl-c].
  5. Look at the man page for the who command.
  6. Experiment with command history.
  7. Try this experiment:
  8. Try using the command completion feature.
  9. Logout on all consoles and shutdown.


Questions & Answers:

  1. If you make a mistake while you are entering a line, what combination of keys can you press to erase the entire line and start over?
     
    Answer: [Ctrl-u]
     
  2. What key(s) do you press to recall the previous command?
     
    Answer: Press the [up-arrow] key
     
  3. Does the key conbination [Ctrl-d] always logout?
     
    Answer: [Ctrl-d] signals end-of-input or end-of-file. If you are sitting at the bash prompt, then [Ctrl-d] will cause a logout (although bash can be configured to ignore it). If you are running a command, then the [Ctrl-d] key conbination is passed to the command not the shell and will not be interpreted as logout.
     
  4. What command do you use to get help about the cal command?
     
    Answer: man cal
     
  5. Identify the command, options and arguments in the following:
    ls -al /etc
     
    Answer:
    The command is: ls
    There are two options: a and l
    The argument is: /etc
     
  6. Can commands be entered in uppercase?
     
    Answer: No, unix is case sensitive and commands are usually lowercase.
     
  7. What error message do you get when you try to run a command that does not exist on floppix?
     
    Answer: command not found
     
  8. How would you get help on the -j option of the cal command?
     
    Answer: man cal
    The manpage for a command will list all of the options for that command with a description of the purpose of each option. You can get help for a command, not an option.
     
  9. The syntax for the cal command is:
    cal [-jy] [[month] year]
    How do you interpret this?
     
    Answer: entries in [ ] are optional. For this command, there are:
  10. The syntax for the who command is:
    who [OPTION]... [ FILE | ARG1 ARG2 ]
    How do you interpret this?
     
    Answer:
    ... indicates that an item can be repeated one or more times;
    | should be interpreted as "or"
    For this command:

Copyright © L. M. MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next