Command Line (Shell) Interface
The ssh protocol provides a text-based session to a remote host,
with no graphics and no mouse support. Interaction with the
system consists of typing commands and viewing the system's
responses in a terminal window.
Note: The ssh protocol can "tunnel" the
X Window protocol. This allows you to run X clients
with graphics and mouse support. For this to work, you
need to run X server software on your workstation.
Examples of X clients include the emacs text editor
and the konqueror file manager/web browser.
These notes deal only with the command line interface.
Commands
Linux and other Unix-like platforms provide a rich
environment with many applications and development tools. Hence
there are hundreds of commands available to the user. Here is a list
of basic commands that you should know about.
Only the most common modes of usage are described here. Most of
the commands have a number of options that affect their behavior.
For full details, use the man command. Many commands
also support a --help option that displays a synopsis of
the available options.
- logout
- Logs you off and disconnects you from the system. On most
platforms, exit and ctrl-D
have the equivalent effect.
- ls
- Lists the files in your current directory. With a -l
argument, gives a more detailed listing of file properties. The form
ls DIR, where DIR is a directory,
lists the files in that directory.
- rm FILE1 FILE2 ...
- Deletes the named files. Warning #1: Use with caution!
You might not be prompted for confirmation, and once a file is
gone, it's gone. Warning #2: Do not type
rm *. The * character is a "wildcard" that
matches every filename (except for files whose names begin with
"."), so this will delete all your
non-hidden files. To be prompted for confirmation, run rm
with the -i option.
- more FILE
- Displays the contents of a file, one screenful at a time.
Hit the spacebar to advance to the next screenful. Type
q to abort the listing.
The more command can be used as a filter
to paginate the output of other programs. For example, type
last | more to see the output of the last
command one screen at a time.
- cp FILE1 FILE2
- cp FILES DIR
- The first form copies FILE1 to FILE2. The second form makes new
copies of all files in the list in the specified directory.
- mv FILE1 FILE2
- mv FILES DIR
- The first form renames ("moves") FILE1 to FILE2. The second form
moves each file in the list to the specified directory.
- cd DIR
- Changes your current working directory to the one specified.
(Example: cd /var/www/html
gets you to Apache's document root directory
on the oriole server.) The cd
command without an argument returns you to your "home" directory.
- mkdir DIR
- Creates a directory. This will fail if the directory exists.
- rmdir DIR
- Removes the directory. To succeed, the directory must be empty.
- chmod PERMS FILE1 FILE2 ...
- Changes access permissions on the files as specified by the
PERMS argument. Examples:
- chmod a+r foo.html - adds read permission for everybody
- chmod ug+r foo.html - adds read permission for owner
and group, leaves read status for others unchanged
- chmod o-w foo.html - removes write permission for others;
owner and group status is unchanged. (Without write permission,
others cannot modify the file.)
- chmod a+x myscript.pl - adds execute permission for
everybody. (Normally, scripts and compiled programs should have
execute permission. Also, directories should have
execute permission.)
- pico FILE
- Runs the pico text editor, which allows you to modify the
specified file (and create it if it doesn't already exist).
Note: Pico is a full-screen editor. No mouse support, but
you should be able to use the arrow keys to move the cursor around,
and the PageUp and PageDown keys to scroll. Pico displays a
command menu at the bottom of the screen. The notations like
^X that you see there denote control
characters, generated by holding down the Ctrl key while
you type the character. One of the Pico commands will give you
online help.
-
Sermon on editors: The pico editor is easy to learn but
is extremely wimpy in the functionality department. It was
originally intended as a very simple editor for creating email
messages. For more serious editing tasks -- software
development, for example -- there are better editors available.
Two standard Unix editors are "vi" and "emacs". I personally
prefer emacs for source code editing. It supports multiple
windows, has "undo" functionality, and when run in "C mode"
it understands C syntax and does automatic indentation. It
can be run either in terminal mode or as an X client.
When
run as an X client, it also does color syntax-highlighting and
supports mouse usage.
In addition to C language support, Emacs has special modes for
other languages, such as Perl and C++. Emacs has a somewhat
steeper learning curve that most editors, but the effort is
worth it. (End of sermon.)
- man COMMAND
- Displays online documentation ("manual entry") about the given
command, including
a list of all possible arguments and their effects. For example,
man ls gives detailed documentation on the
ls command, and man man displays
documentation on the man command itself.
- info COMMAND
- Similar to man, but presents documentation in a
more structured format. Some commands have more detailed
info entries than man entries;
on the other hand, some don't have info entries
at all. Try both. Type info info for instructions
on how to use the info facility.
- mail
- The basic Unix mail program. You can use it to read and send
email messages.
- pine
- A more full-featured, screen-oriented email program.
- who
- Shows who is currently logged in.
Special Keys
When in terminal mode, you are communicating with the
shell and applications through a piece of software called a terminal
controller. Normally, the controller simply passes on keys that you
press to the application that you are running. However, certain keys are
intercepted by the controller and produce special effects:
- ctrl-D
- Produces an EOF (end-of-file) condition on keyboard input.
Warning: When typed at the shell command prompt,
this might have the effect of logging you off and disconnecting
you.
- ctrl-C
- Sends a terminate signal to the application. Normally, this
causes the program to terminate. This is a good way to abort a program
that is caught in an infinite loop.
- ctrl-Z
- Sends a suspend signal to the application. This suspends the
application but does not terminate it. The application can be resumed
later using the fg command or by other means. Warning:
The system will resist logging you off if you have suspended tasks.
(You'll see the message "There are stopped jobs.") You
should exit from any stopped jobs before logging off.
- Backspace
- Moves the cursor one space to the left, erasing the last character
typed. (Note: Depending on the ssh client you are running,
you might need to type some other key to get this effect. Possibilties
include delete, ctrl-delete, and ctrl-backspace.)
- ctrl-U
- Erases the current line of input, moving the cursor to the beginning
of the line.
- ctrl-W
- Erases the last word typed, moving the cursor to the beginning of
the word.
Caveat: The above describes the default behavior of
these keys. But programs can modify the effects of any of
the above keys. Hence
these keys may have different effects in different applications.