Practicum - week 2

Welcome to the first practicum!


Log in and get acquainted with the terminal. Open more virtual terminals, etc. Try pressing the middle button of the mouse to copy the highlighted text. Try deleting with ^h. Close a virtual terminal with 'exit', as well as with ^d. (Remark: from now on ^ will refer to the CTRL button.)


Change your password (passwd), and don't forget the new one!

Rule no. 1.: Never tell anybody your password!


Check the shell you are using with: 'echo $SHELL'. You should get '/usr/local/gnu/bin/bash'.
Try out typing the same, but changing the case, like 'ECHO', '$shell', etc. Use the upper cursor to save typing. Notice the different error messages.

What is the reason for that if you type both an incorrect command (like 'Echo') with an incorrect variable name (like '$sheLL') you are told about the variable, and not about the command? Remember what we have told about the way the shell works...


Check which directory you are in ('pwd'). List the content of this directory ('ls'). Walk within the directory tree using 'cd'. What does 'cd ..', 'cd ../..', etc.? Always look at your prompt, and check if it really shows your actual working directory ('pwd'). Always list the actual directory, see at its content, and walk up and down. Check also 'ls -l'. In many systems the command 'll' is just a standard alias for abbreviating 'ls -l': try it out. If you are lost, go home (simply 'cd' or 'cd ~'), and check if you are really there.


Now that you are back home, you can start changing the content of your home directory.  Make new directories, check their content and remove them. Create files ('cat > filename') , check them ('ls', 'ls -l', 'cat filename') and remove them. Check if you could successfully remove your directories and your files.

Try to remove a non existent file or a non existent directory. Try to remove a directory with 'rm' (without '-r'). What happens?

What is ~/.. ? Try creating a directory and a file in ~/.. !

Note that UNIX doesn't give you any message if the task could be successfully executed! Therefore:

Rule no. 2.: Always check the effect of your commands!

Play around with: cp, mkdir, mv, rm, rmdir, ls. Try out different wildcards.
Use the TAB and the double-TAB to save typing.

Try 'who', 'who am i', 'w', 'date' and 'cal'. (Don't forget 'cal 09 1752'!)

Get information on these commands using 'man <command_name>' and '<command_name> --help | more'. (Within man or less: use cursor-up, cursor-down and 'q' to quit; while 'space' and 'enter' within more.)


Assignment to be presented to one of the instructors:

Create a directory 'assignment_1'  within your home directory.  Create the following ones within it: a directory called 'apple' and files called 'alfa', 'beta', 'gamma', 'delta' and 'epsilon'.

Then give the appropriate command using wildcards to (in this order), without changing directory:
- list 'apple' and 'alfa'
- get a long list about 'alfa' and 'beta' (note that both contain exactly 4 letters)
- get a reverse alphabetical list (according to the latin alphabet) of 'gamma' and 'delta' (there are more possibilities) (check the manual for the appropriate options)
- move 'gamma' and 'epsilon' into 'apple'
- rename 'apple' to 'pear'
- copy 'alfa' to your home directory
- remove 'alfa' from your home directory
- copy the content of (the files within) 'pear' into your working directory
- remove the content of 'pear'
- remove 'pear', but let the computer ask you beforehand if you really want it.

(Points: 8 minus the number of not done tasks.)


10 minutes of vi

Start vi by typing: ' vi <filename> '. Then don't panic!

There are tree modes in vi:
- command mode: typing a character means a command, and does not appear on the screen.
- input mode: now you can type in whatever text you wish into your text, to the place where the cursor is.
- status-line mode (last-line mode): issuing long commands that will appear on the bottom line of your screen.

Changing between these modes:
- when you enter vi, you are in the command mode;
- pressing the 'Esc' button ('escape') brings you back always to command mode;
- from command mode 'a' or 'i' brings you to input mode;
- from command mode ':' brings you to the last-line mode.

In the input mode you can just type in your text, but you will sometimes be surprised that you are not able to delete it. Maybe you are even not able to use the keys for moving your cursor! Then go back to the command mode (by using Esc) and bring the cursor onto the character you wish to delete. Just press 'x' to delete. Then 'a' or 'i' will bring you back to input mode.

Are you lost and even not able to move your oursor? Use the h (left), j (down), k (up) and l (right) keys in the command line.

In fact 'x' deletes the given character by putting it into a buffer ("cut") and 'p' will paste it to the actual position of the cursor. If you wish to put more than one character into the buffer (e.g. copying or moving an entire word), then just type the number of characters before 'x'. For instance '5x' will delete five characters, and put them into the buffer. Finally, 'dd' will delete you a line, and put it into the buffer. If you get lost, just don't panic...

By pressing ':', you get to the last-line mode. Pressing 'vi' will start a new file ("new document"), 'vi <file_name>' opens the mentioned file. Typing 'w' will
save (write) our file, while typing 'w <file_name>' saves as (under) the given name.

Leaving this sadistic editor is possible by typing 'q' (quit), 'q!' (quit, even if not saved) or by 'wq' (save and quit).

Assignment: show the teacher that you manage to handle vi, at least for 45 seconds...!

(2 points)


Now you can try out pico and pine! Relax and enjoy having left vi...