Some Suggested Exercises

Introductory Session

Exercises:

1) Run a few commands of your choice.

Type and see what gets listed.

Run a from the history, (hint: use ! followed by the number of the command).

Enter a new shell of your choice.

Type history and see what gets listed.

Exit this shell to go back to your previous shell.

Change the HISTSIZE environmental variable to 5. View your history again.

2) Look the environmental variables currently set. Add another directory to your PATH variable. (Look inside the /usr/software/bioenvrc for the syntax for this command.)

3) Look at how your machine is organized using –k.

Read the for df.

4) Put in a floppy disk and the floppy drive.

Read the /etc/ file and the manual page for fstab (and related web links if you have .) Can you see why the command to mount a floppy is what it is?

Unmount the floppy drive.

5) Type to see the default permission settings for new files. Create a new file, (e.g. use the command ) and see what permissions are on the file.

Change the umask to 066, create a file and check the permissions for that file.

Now create a new directory, (e.g. use the command) and check the permissions on the directory.

User1 has a folder (~home/user1/sequences/testseqs) and he wants user2 to be able to see data stored in that folder of user1’s account. Use permissions to enable this. How could you ensure that data added after to this folder after this point in time would also be readable by user2?

6) User1 now wants user2 to be able to access only specific files in ~home/user1/sequences/testseqs. He wants to give user2 a list of specific filenames he can view, but does not want user2 to see what else is in that directory. How would you grant permissions that allow user2 the appropriate level of access?

7) Look at the information on creating users produced when you type the command

man useradd

Create a new user. Decide where you want their home directory to go, and what you want their username and default login shell to be.

Run –la on the new user account’s home directory.

Investigate the contents of some of these files and directories. (Where did these directories and files come from?)

Try using the usermod command to alter information about a user already on the system.

8) Run df –k and look at the output. Do you know what it is telling you?

Read the man page for df.

9) Read /etc/fstab. Do you understand what the different lines are referring to? When you run mount /mnt/cdrom , what is being mounted where?

What is the relative amount of space designated to each filesystem? Will this suit your requirements?

Can you see why the current setup should be monitored? What happens if someone decides to load EMBL into their home directory?

(For the true sysadmins out there – EMBL is a VERY large flatfile database.)

For the next few exercises, please move into the directory /home/manager/eg_bio-linux2.0_course

Further Command Line Session

Exercises:

1) List processes that access the /var partition

2) List processes that use the ssh port

a. using fuser b. using

3) Launch artemis Consult the man page for fuser and figure out a way to send a to all process that use /usr/software What happens?

4) List all manual pages relevant to password

5) Email the man page to your email account

6) ~manager/examples/further_cli/tar/ Compress all the blast reports (.blastp) files into a tar.gz file

7) cd ../compressed compressed.tar file in current directory

8) Compress/gzip all .prot files What of compression ratio do you get? Can you alter/improve this?

Possible commands (solutions) for Further Command Line exercises numbers 1-8:

1) lsof /var

2a) fuser ssh/tcp | '{print $2}' | ho cmd

2b) lsof -i :ssh lsof | ssh | grep -v TCP

3) fuser -k

4) man -k password

5) man passwd | -s "man passwd| [email protected]

6) tar xzf blastarchive.tar.gz *.blastp

7) file compressed.tar reveals: file compressed.tar compressed.tar: bzip2 compressed data, block size = 900k tar tjf compressed.tar then tar xjf compressed.tar

Better yet... compressed.tar compressed.tar.bz2 tar xvjf compressed.tar.bz2 or bunzip2 then tar xvf or even bzip -d then tar xvf

8) ls *.prot > list_prot for i in ` list_prot`;do;gzip -v $i; done

Process and System management:

Exercises:

1) Experiment with ps and its modifying switches. Refer to the man pages to alter the display.

2) is a very system intensive command – see if you can work out how to run top so it only updates the display once every 20 seconds. Does this reduce the load?

3) Using the man pages try to figure out how to use top to do process management tasks.

4) View the like structure of the processes running on the machine. processes have the child processes, and why do you think this is?

5) Work out how to list the processes associated with a terminal using .

6) Relate free, cat /proc/meminfo and vmstat information, can you see where the commands get their information from?

7) Get some size information from some of the directories on the filesystem. What do the larger directories contain?

8) Load up gtop and learn what the various displays are showing relative to the commands learnt in the session.

9) Work out what the crontab entry would be to run a program every Saturday at 2.34pm in every even numbered month.

Further Linux command line

Exercises:

1) Create a text file with a favoured line of prose or verse. Turn it into parody with .

2) Use grep to display genbank.txt without the AUTHOR lines.

3) Use grep to pull out lines of genbank.txt which have an EcoRI restriction site.

4) Read and try some of the things in these two links: http://pegasus.rutgers.edu/~elflord/unix/sed.html http://pegasus.rugers.edu/~elflord/unix/grep.html

5) cat fofn.txt. Use foreach to display each file listed in fofn.txt to screen.

Essential Linux administration

Exercises:

1) Examine the output of rpm -qa. If you don't recognise what they are use man to investigate what kind of services the rpms are providing.

2) Attempt to install pan-0.13.4-nospell1.i686.rpm by searching out the dependencies on the net. Google for the errors, has anyone else had the same problem? Do their fixes work? Which forums have good information? If all else fails install it with no dependencies and see if it works.

3) Uninstall the rpm from 2).

4) Play around with the rpm -q options. Try to some sense of the man pages.

5) Go to www.sourceforge.net . a small package that comes as a .tar.gz or .tgz file (not rpm) and attempt to compile and install it.

6) Install snort to /tmp/.

Printer setup

Exercises:

1) Load printconf-gui as manager with . Set up some dummy printers to familiarise yourself with the interface.

Log files and log monitoring

Exercises

1) Read /var/log/dmesg and deconstruct with: http://www.linuxgazette.com/issue59/nazario.html

2) Examine the file logwatch.txt. This is the output from logcheck.sh. What time did an active attack occur? Where did this originate from? Are there any other messages related to this attack in the file? How can you identify them? How could you parse the file to only pull out lines related to the attack to submit a report?

Linux security 101

Exercises:

1) Think about the passwords you're currently using. Do you really think that they are sufficiently secure to stop someone guessing them? If not CHANGE THEM!

2) Check /etc/narc/narc.conf and see if you can work out how to change the firewall rules to allow incoming web traffic on port 80.

3) man , and play with netstat to see if you can decode some of the information that is given.

4) Read some of : http://www.ecst.csuchico.edu/LDP/HOWTO/Security-HOWTO/

Booting up and Session

Exercises:

1) Read /etc/inittab to determine what scripts are executed in what order. Where/when is X started? What does this suggest about troubleshooting X problems?

Read the /etc/rc.d/rc script.

Can you see, looking at the information, why you can run virtual terminals using the Cntl-Alt-F1 through to Cntl-Alt-F6 keys combinations?

2) Read the man page for chkconfig. Find out about all the services chkconfig knows about on the machine you are working on.

Look at the names of the scripts in the init directories for the various run levels, (/etc/rc.d/rc0.d, /etc/rc.d/rc1.d, /etc/rc.d/rc5.d, and so on.) Can you see a connection between the information you see in chkconfig and the scripts that will be executed at the various run levels?

3) Stop sshd running on your machine using the appropriate init.d command. Start sshd running again.