Exercises

This section contains some practical exercises that will help you to get Unix in the fingers.

There are practical examples and exercises on shell scripting in the general exercises section.

Exploration tour

Connecting and disconnecting

Log on to the system

Log out

Log in with a username that can't possibly exist

Log in with your userID but enter a wrong password

X

Try all the mouse buttons

Explore the menus

Open a terminal window

Open another terminal window

Switch focus between the two windows

Start xcalc or xclock, see the difference between starting in the background (xcalc &) and starting in the foreground (no &)

See what the buttons on the titlebar do

Resize some windows

Minimize and maximize a window

Move a window around

Copy and past a command from one xterm to another using the mouse

Close the applications

Close the terminal window

Customize the looks of your graphical environment

The filesystem

Get a shell prompt

Check the working directory with the pwd command

Change to your homedirectory with the cd command

Change to the /bin directory using cd /bin

Change to the root of the filesystem: cd /

List the top directories on your system using ls

Change to /etc

List the content of /etc

Check your present working directory

Try to cd to a non-existent directory

List the content of /usr/doc or /usr/share/doc

You and the others

Enter the who am i or whoami

Enter the who command

Change to your homedir

Go one directory up: cd ..

List the other users with the ls

Finger a user, e.g. finger root

Show a list displaying the last 10 users that connected to the system: last -10

Enter the passwd command to change your password.

Enter the echo $SHELL to find out what shell you are running

Files and directories

Use vi, emacs or pico to create two files

Try the more, less and cat commands on your new files

Append the two files

Make a long listing of your files using the ls -la

Use the * and ? operators to narrow the listing

Create a directory using mkdir

Move the two files to this directory

Rename one of your files

Copy one file from this directory to you homedirectory using absolute pathnames

Do the same using relative pathnames

Remove one of your files using rm

Remove the directory you made using rmdir

Find the files resolv.conf, profile, tar and xclock

Redirecting input and output

Put the date of today in a file: date > today

Append to this file the names of users that are currently logged in: who > > today

Display long output on the screen: ls /etc

View the output piping through more or less

Grep all files starting with "host" from the /etc directory

Making space

Explain why the tail afile > ashorterfile does not do what you might expect.

Find the difference between the following:


% tail afile > ashorterfile
% cat ashorterfile > afile
% rm ashorterfile

and


% tail afile > ashorterfile
% mv ashorterfile afile

Explain why you should always use the first form. e.g. to shorten logfiles.

Documentation

Read a manpage, e.g. man man

Read help on a command, e.g. help cd

Note

Only shell built-in commands provide the help option.

Use short help of a command, e.g. ls --help

Read info on a command, e.g. info info

Change to /usr/doc or /usr/share/doc and read a README file of one of the programs on your system.