Top: Index Previous: Commanding Up: Index Next: Connecting

CSC8306 -- Systems Administration

Super user

For systems administration a good knowledge of the superuser account is very important 1. Most of the tasks that you will need to carry out need will require its use.

log
  1. You will need to become familiar with the super user account. What is it? Why have it? Why use it?
  2. List 2 ways to become superuser, what command allows specified users to run specific commands as root, without knowing the superuser password? (Hint this is how we will access superuser facilities)
  3. Ubuntu will not let you login as root. Can you work out why? How would you enable it to?
  4. When should you NOT use the superuser account.

Next try to actually use your superuser privileges. Try the following commands using the superuser account. Most of them will not work without.

act
  1. Try downloading this structure from PDB — the protein data bank.
  2. You should see that Firefox doesn't know what to do with it; this is a pity because it's just the sort of thing you'd want to be able to see. So, we are going to install a program to view it.
  3. Try to install rasmol. There are several commands you can use to do this. On the command line, try aptitude install rasmol.
  4. When this fails, use one of the mechanisms you found previously to get root access and try again.
  5. Now try to open the PDB file — rasmol may be offered, or you may have to navigate to it (which rasmol on the command line will tell you where).
  6. Uninstall rasmol — aptitude remove rasmol.
  7. Find "Synaptic Package Manager" in the menu. Launch this. It will ask for your password; again this is gaining root access.
  8. You should be able to work out how to install rasmol again through this interface.

Now, back to some shell commands!

Further commands

There are lots of Unix commands that appear to do very little on their own. Combining these together using pipes and redirects is one of the things that makes Unix so useful. Having a good understanding of these can make you quicker and more productive than the traditional GUI 2.

log Briefly describe the following commands:
  • find 3
  • grep
  • sort
  • unique

Next, you will need some external resources.

act In your home directory, run the command

wget https://internal.cs.ncl.ac.uk/modules/2011-12/csc8306/csc8306.tgz

You should be able to unpack this as a directory structure in your home directory.

logact
  1. What does wget do? Read the manual page.
  2. use find to locate all files in your home directory and all child directories
  3. repeat, but only show files newer than 5 days
  4. use grep to find all the CDS lines in a sequence file
  5. use grep to find all ID lines in all sequence files, and then use sort to print these out in alphabetical order

File Permissions

Linux has a system of file and directory permissions. Personally, I find it more straight-forward than Windows bizarre set of options and conditions. However, Unix file permissions catch everyone out at times and can be confusing. It's important that you understand them.

log
  1. What are the three types of permissions that can be set on a file?
  2. What are the user groups, to whom these permission types can be set?
  3. What permissions would you give a file that you didn't want anyone else to read, with what command would you do this?
  4. What permissions would you give an executable file that you and your group needed to use, with what command would you do this?

Scripting

Unix offers a wide range of possibilities for scripting. At it's simplest, this involves writing a set of commands into a file and having them run one after the other.

There are many different scripting languages available on a Linux system. They are generally all fairly powerful, but they all have their quirks and differences 4. In this course, we will introduce you to the facilities provided by the shell (bash) that you are using. All of these facilities are actually available at the command line or can be placed within a file.

While some fairly large applications have been written using bash scripts, it's generally not a good idea. As a language, it's functional, but not straight-forward. It can be hard to debug. However, it will run on almost every unix system everywhere. Other languages commonly used for system administration, include tcl, perl, python and awk. Generally, I use bash if it's simple (< 50 lines), perl if it's more complicated (< 1000 lines). More than this, I write an application in Java. This is a personal choice though; others do it differently.

Scripts need to be in a file with executable privileges. If you wish to execute the script aScript in the current directory you must give an explicit path, ie ./aScript. Scripts normally start with the "magic shebang line". This just tells unix which command to use to run the script.

#!/bin/bash
echo "hello world!"
echo "your home directory is $HOME"
log
  1. Write a script that displays the users, username, PATH and home directory and display the number of files in the users home directory
  2. Using a for loop, display the numbers 1 to 100

1. Being a system admin gives some people an unwholesome feeling of power; they can do things like switch peoples network connection on and off, remove all their files and so on. Please don't. A nice sys-admin who only says "no" when they really have to is worth their weight in gold.

2. I do most of my file management with these commands on both Unix and Windows (using Cygwin). The file manager does have it's use, but this is generally quicker.

3. find is one of those commands which really does too much. The man pages on my version are over 900 lines long which is really excessive. Some Unix commands are like this. You don't, however, need to know all the options of a command for it to be very useful. Very few people actually know all the options. They just read the man pages when they need them.

4. Again choice of scripting languages is a bit religious. I don't understand why these things cause such passion, but they do.


Top: Index Previous: Commanding Up: Index Next: Connecting