Shells
A command line shell allows you to enter text commands to execute system functions and programs. A large number of different shells are available for unix (sh,bash,bash2,tcsh,csh etc.). When you log on to the white rose grid you will (by default) enter a bash shell, users who are more familiar with other shells an change this default.
The command line basics
If you have followed the tutorial for logging on to the white rose grid, you should now see, at the bottom of the shell screen a prompt:
username@pascali$
With a cursor after it.
Type motd into the shell and press return, this will print the "message of the day" to the shell console. This message will be printed every time you log on to pascali and should be read as important information about system status, downtime and changes will be posted here.
All shell commands, such as motd have a standard syntax (with a few exeptions):
command [options] [file(s)]
You enter the command name, followed by any options, followed by the file or files that the command should operate on. Note that the precise syntax varies from command to command. It is important to remember Unix file names and commands are CASE SENSITIVE. myfile and MyFile will be completely different files.
For example, enter: ls. This command lists all files in the current directory. If this is the first time you have logged on you will not see any files yet! Create a new file using the command touch sample_file. Now run ls again. To get a bit more information, we can run ls with an option to print in long format: ls -l. This should give output similar to:
-rw-r--r-- 1 cjm csci 0 May 26 10:27 sample_file
man
Most Unix commands have a bewildering and complex array of options, however, as long as you remember the command name, you can get detailed information about the command and it's syntax using the man (manual) command. Try: man ls
. To navigate the manual pages, use space to step forward, "b" to step backward and "q" to quit.
To find out more information on man, you can read its man page by entering: man man
Command completion and history
To make the use of the command line easy, most shells (including the bash shell we use by default) provide command completion and history. To view your command history, you can enter: history. To get a previous command you can scroll through your history using the up and down arrow cursor keys, if you do this now you should be able to go back through the commands you have entered in this tutorial. You can also edit your command line by using the left and right arrow keys.
Command completion provides a quick way to enter long commands and filenames, to complete a command or filename, press the tab key twice after entering the first few letters. For example, enter ls -l sam and press tab twice, this will search for files starting "sam" if only one match is found, the filename will be completed, if multiple matches are found they will be listed.
Useful commands
There are an enormous number of useful commands available in the Unix shell. Some important ones are:
passwd Change your password.
motd Print the message of the day.
ls list files in this directory.
hostname print the name of the host on which the shell is running.
pwd Print the current working directory.
cd Change the current working directory.
Next steps
Once you are comfortable with logging on to a Unix command line shell, using the command line to enter commands and using man pages to get information on commands, I suggest you move on to the "Unix file system" and "advanced shell" tutorials (in that order).