Basic Shell Commands
The Unix shell is a powerful command interpreter. It is an essential tool for systems programming.The shell can be started from the menu via Xtras->Accesssories->Terminals.. You may now type commands into the shell which are then executed. These commands may be either programs or commands which are executed directly by the shell.
The shell maintains a so-called current directory , which is pre-prended to each file name given on the command line. When a new shell is started, the current directory is the home directory. This directory may be abbreviated with ~. The most important commands are:
- cd <directory>: This command changes the current directory to the directory <directory>;
- ls <directory>: This command lists all the files in the directory <directory>. If this argument is omitted, the files in the current directory are listed;
- rm <file>: removes file <file>;
- cp <file1> <file2>: copies <file1> to <file2>.
It is also possible to store the output of a command in a file for later analysis. This is achieved by adding > <file> at the end of the command. This process is called redirecting the output .
If you want to start programs in the current directory, you must precede the program name with ./
You do not have to type long filenames all yourself. It suffices to type only part of the name and then press the key labelled "Tab". The shell then automatically adds the rest of the name as far as it is unique. For example, assume the current directory contains two files, test1a and test2b. If you type "t" and then "Tab", the shell will add the string "est". If you type now "1" and then the Tab-key, emacs will add the character "a" and a space to indicate that the filename is now complete. This feature is called file completion , and is extremely useful. For further information see the section entitled " Shell & Scripting " of the Using Linux page of the supportweb.