What is UNIX? ---- UNIX is the name of the operating system of all workstations that you will use during the JANUS-practicum.
Why should you care? --- UNIX is a very powerfull, and convenient operating system, IF you know how to use it. But you will hate it, if you don't. So, if you never used UNIX before it might be a good idea to read the following short introduction to UNIX.
The following introduction is by no means complete. You can find more information under
You already changend your password? OK. If not you should do it right now!
Just type
passwd
You will be asked to enter your old password and your new password (twice).
Old Password: [enter your current password]
New password: [enter your new password]
Retype new password: [re-enter your new password]
Choose a password preferably between 6 and 8 characters in length,
containing at least one non-alphanumeric character as ! or @ or % or ...
Now that your account is safe let's continue with some of the most frequently used commands:
If you use simple filenames as arguments of a command it will operate on your current working directory (you get a complete path of this directory by using 'pwd'). If you want to manipulate objects in other directories than you have to describe the path how to get to this directory.
In a path-description the names of directories are separated by '/'. For example "dir1/name" is the file called 'name' in the subdirectory 'dir1' of your current working directory. The directory '..' is a pointer to the parent directory of your current directory, '.' (a single period) is a pointer on the working directory itself. You can use any levels of indirection you want. So for example the path "../../dir1/" leads to the subdirectory 'dir1' of the parent of the parent of your current directory.
By now we described the way to a second directory starting from your current working directory (relative path). As well we can start at the root of the directory-hierarchy by preceding the pathname with a '/' (absolute path). 'pwd' will give you an absolute path to your home directory.
All possible path-components:
. |
the current working directory |
.. |
the parent of the current directory |
/ |
at the beginning of a path-name: the root of the directory-hierarchy
in the middle of a pathname used to concatenate directory-names |
name |
the directory called 'name' |
~ |
your home-directory |
~name |
the home-directory of account 'name' |
E.g.:
Now you can move files, copy them, remove them again and so on. But consider you don't have a single file, but lots of them. E.g.: you have 100 files called 'ex1', ..., 'ex100' and you want to remove them. Either you can use the 'rm'-command 100 times, or you use wildcards.
Useful wildcards are:
* |
matches any sequence of characters |
? |
matches any single character |
[...] |
matches any character in the enclosed list or range |
Some examples:
If you start a program it usually runs in the 'foreground' of your shell. This means that you have to wait until the program is finished before you can type any other commands in this specific shell. If you want to continue working in this shell without waiting for a program to stop you can also start it in the background by adding an '&' to the end of a command (e.g. 'emacs example &' starts an editor in the background and allows you to continue your work in the same shell).
If a program is running in the foreground of a shell you can stop it by typing 'CTRL-c'. This works in most cases. If it doesn't use 'kill'. You can suspend a running foreground-jop by typing 'CTRL-z'. This job will then sleep until you wake it up by using 'fg' or 'bg'.
If you log yourself out all processes that run in the foreground of a shell are terminated. Background-jobs wil continue running till they are done or get killed.
UNIX considers any device attached to the system to be a file. And that includes your terminal!
By default a program takes it input from your terminal (the keyboard) and writes it output back to your terminal (the shell in which you started the program). You can redirect both of it.
An example: you would like to have a list of all files in your working directory. If you use 'ls' you will get this list, but only written on your screen. In order to collect the output a file you have to redirect the standard-output. Try 'ls > test'. This command will create a file 'test' with the contents of your current working directory.
UNIX allows you to link two or more commands sing a pipe. The pipe takes the standard output from one command and uses it as the standard input to another command.
command1 | command2 | command3
The | (vertical bar) character is used to represent the pipeline connecting the commands. With some practise you can use pipes to create complex commands by combining several simpler commands.
An example: if you now want to know how many files are in your working directory, you can use 'ls' to get a list of the files, take the output and feed it in a program that counts the lines of the output.
ls | wc -l
(use 'man wc' to find out mor about 'wc')
< name |
redirect standard-input (take input from file 'name') |
> name |
redirect standard-output to file 'name' |
>> name |
redirect standard-output, append to file 'name' |
cmd1 | cmd2 |
pipe output of 'cmd1' to standard-input of 'cmd2' |
>& name |
redirect error messages to file 'name' |
Original version from Detlef Koll (Thanks!)
Last modified: Thu Feb 15 13:32:56 EST 2001
Maintainer: tanja@cs.cmu.edu.