When you successfully login for the first time , your screen will appear something like this :
login as: z912730 Using keyboard-interactive authentication. Password: Last login: Thu Jun 14 17:09:58 2007 from 131.156.145.133 Linux 2.6.16.21 #1 Sep 2006 z912730@lx:~> |
except maybe for the "Last Login:" message.
The screen you are looking is called a terminal, athough it actually an emulation. Your keyboard is the standard input device and the window on your monitor is both the standard output and the standard error devices.
If you were to type something, it would appear to the right of the ~> characters referred to as the command prompt for the bash command interpreter on our system. Later in the course, we will look at ways to modify this prompt to provide more information.
Throughout these modules and the book you may find the command interpreter is also referred to as the shell.
If you were to type something in and press the [enter] key, the command interpreter would parse the input and attempt to run the instruction or command entered. Whether the command interpreter was successful would depend on if you correctly entered the command and if you had the appropriate permissions to run the command.
Throughout these study modules, you will be provided with exercises and experiments to try at the command prompt. Please try them. Except for a few commands which you will be warned about, a command incorrectly entered will not harm your account, simply enter it again.
As long as you have not pressed [enter], it is possible to move back and forth on the line and edit it. If you are using putty, you should be able to use the [<-] and [->] cursor keys to move the "cursor" to the location to edit. The "cursor" is an identifier that shows where on the screen any character you type will be entered. It is often a small blinking rectangle. Depending on how putty is configured, the [backspace], [delete], and [ctrl]h keys should allow you to delete a character either under or next to the cursor. Experiment with each to see exactly what happens.
If you start typing in new characters, they should be inserted under the cursor position. When you are done making any changes, press [enter] and the command interpreter will attempt to execute your instructions.
bash and several other command interpreters provide a history mechanism which allows you to fetch previously entered command lines without retyping them. With bash, you can use the [up] and [down] arrow keys to scroll though the history list of previously entered commands. We will take a detailed look at the history list mechanism and its features in a later module. For now, as you do the various exercises, remember you have history at your finger tips.
Most command interpreters process a character known as a control character as a special instruction or signal. To enter a control character, hold down the [ctrl] key and press the selected key. Although you are pressing two character, the command shell views this as a single character. The following table lists useful control characters to use at the prompt.
[ctrl]d | EOF - indicates end of file or input.
Signalling an end of file is often used when a command is reading input from
standard input, the keyboard. Since anything can be valid input, you need a
special character to indicate you have finished all input. We will look at
another control character that can be used to suppress the meaning of [ctrl]d if
needed. If entered at the command prompt, [ctrl]d will indicate you are done entering commands and the command interpreter terminate. |
[ctrl]c | interrupt - requests the currently running foreground program terminate. Use [ctrl]c when you wish to cancel the running of a program you just started. Programs can be designed to ignore or take special action upon receiving an interrupt. You may also find that certain actions have already occurred even if you interrupt a command as soon as it is issued. |
[ctrl]z | suspend execution - requests the currently running foreground process be suspended. Use [ctrl]z when you need to pause a long running program in order to run something else quickly. A suspended program can be restarted with the fg command. |
[ctrl]h | backspace key - move cursor back one character. The specific action of this key can be influenced by the version and settings of your terminal software, so you may want to test it. |
[ctrl]w | delete previous word on the command line. |
[ctrl]u | clear whole command line. This is useful when you are entering your login id or password, especially the password. If you have entered bad info and not yet pressed [enter], [ctrl]u clears the input (even if you can't see it). |
[ctrl]s | suspend or pause output. This was used to pause the display output of a command. Because systems are now very fast and terminals are connected across networks, this control is not very useful. However, because it still exists, you need to know not to use it and if you do what to do to resume an active display. See next control. |
[ctrl]q | resume displaying output. This is the complement to [ctrl]s. If you find your terminal appears frozen, first try issuing a [ctrl]q. In most cases, the worst that can happen is that you insert an extra character in some text. And if you screen is frozen because you accidentally hit [ctrl]s, this should allow it to resume normal functioning. |
[ctrl]v | control quote. On occasion, you will need to
enter a control character as input or in a string. [ctrl]v followed by another
[ctrl] character pair will allow the second pair to be treated as input or a
control character as a string character. Try the following at the prompt : echo "hi[ctrl]v[ctrl]h there" You should see the representation of the backspace in the string. If you press [enter], the echo command will process the backspace normally when it echos the text to the screen. [ctrl]v will control quote even itself if repeated twice in a row.
|
Keep it in mind that the command interpreter processes input one line at a time and the location of this line is stored internally in the interpreter's environment. This means that even if your terminal software allows you to scroll back the display to see previous commands entered and their output, you can only work from the current command prompt line. Later we will look at programs such as less that do allow you scroll back and forth in the display and issue commands at any position in the display.