Bash is the default UNIX shell for RCS. A UNIX ``shell" is a program that acts as the interface between you and the UNIX operating system, prompting you for input, checking commands for syntax errors and, then executing them. As soon as you log on, you are using the shell. You do not have to do anything special to start up the default shell.
Bash, which stands for the Bourne-Again Shell, was chosen because it incorporates many popular features of other shell programs, such as the Bourne shell (sh), the C shell (csh), and the Korn shell (ksh). For example, bash uses the Bourne shell's programming syntax (also used by ksh), the C shell's job control and history functions, and the Korn shell's ability to edit previous command lines using common visual editors. In addition, bash has several attractive features of its own.
Bash has an on-line help feature that provides basic information about most of its built-in commands. To see the help description for a particular command, enter
help command(for example, help alias) at the bash UNIX prompt. To see a list of bash commands for which help is available, type help at the bash UNIX prompt. You may access the manual page for bash by entering man bash at a UNIX prompt, but beware, it is 60 pages long.
With bash, you can reissue commands by pressing the up or down arrow key and pressing Enter or Return when the appropriate command reappears.
When you press the up arrow key, previously issued commands will appear on the command line, one at a time. Press the down arrow key to scroll back through them. Press the right or left arrow keys to move the cursor through the command. Anything you type will be inserted into the command. Use the Backspace key to erase characters. Press Return or Enter to re-issue one of those commands.
You can also use CTRL-p and CTRL-n to scroll through commands in your command history and use regular emacs commands to search for strings and edit a command line. For example, CTRL-d deletes a character and CTRL-k erases from the cursor to the end of the line.
A feature of bash is ``file name completion." This means that if you type a filename as part of a UNIX command and you have typed enough of it to uniquely identify the file, you can press the TAB key to make bash fill in the rest of the filename for you.
If you have not typed enough characters to uniquely identify the file, the workstation will beep; press the TAB key several more times, and a list of possible filenames should appear.
Bash also allows you to define aliases, which act as ``shortcuts" that take the place of longer commands, and functions, which are similar to aliases, except that they allow more complex expressions. You can define aliases, functions, and environment variables in a .bash_aliases file, which you can create with your favorite editor.
An alias command consists of the command alias, the name you want to give the alias, and a definition that contains the actual command for which you are creating the alias.
Two sample alias commands appears below. The first example makes the rm command prompt you before it removes a file; the second makes the ls command append a forward slash (/) to all directory names so you can easily distinguish between files and directories.
alias rm='rm -i'
alias ls='ls -F'
As a simple exercise, use your favorite UNIX editor to create a .bash_aliases file, and type these commands into that file. Note that you must always put an equal sign (=) between the alias and the alias definition, as shown above. In addition, the alias definition should have quotes at the beginning and end of it, if it contains more than one word.
To use the newly-created aliases and functions in your current session, you must enter the following command in order to source the file and make the system read it. (Otherwise, the new aliases and functions will not be available until the next time you log in.)
. .bashrc
To test the first alias described above, simply enter the command
rm myfile
At the prompt that appears, enter y to remove the file, or n to cancel the command. To see the effect of the second alias, enter the command
ls