Organically Grown Software ™

 About Us   Grown Software   Custom Hardware   Support 

Administration Concepts Unix Primer Maintenance Tasks Trouble Shooting

Maintenance Tasks

Common tasks for the fearless

Some conventions used in these mini how-to articles might prove useful. Command lines will be displayed with fixed width fonts and always begin with a $ for normal user privileges or a # for root (super user) privileges. What the system displays will be in black, and what the user types will be in blue. Notes about what should be typed are in red. Many of these mini how-to guides center around typed commands on a command line. Pressing the enter key at the end of each command line is assumed. If you are not yet familiar with basic unix commands, please read the unix primer first!

Gaining super user authority Installing new software under Gentoo Linux Updating software under Gentoo Linux Installing a local printer Checking how much disk space is free Scheduling a task with the cron daemon Checking my network (IP) address Accessing my Windows files Starting PPP dialup services

Gaining super user authority
In Linux and Unix, the super user or administrative account is called root. (If you are familiar with Windows, you may know of the windows equivalent, administrator). In order to do many of the systems administration functions on your computer, you will need to have the proper privileges. The preferred way to escalate your privileges is inside a command shell (also called a shell, terminal, xterm, console, etc.). Open a shell and at the prompt type:
$ su -
Password: (type the root password)
#

Now that you have a # prompt, any commands that you enter will be done as the root user. Be careful as the root user is allowed to do anything the computer knows how to do without question. It is recommended that root privileges only be used when absolutely needed. To act with normal privileges again, type:
# exit
$

Installing new software under Gentoo Linux
The process of installing new software under Gentoo Linux is somewhat different than most other Unix and Linux varients, and it is totally unlike Windows. This is a boon to systems administrators as it keeps unwanted software off your system and prevents significant tampering from users. Portage is the software management system in Gentoo, and our new favorite tool for managing software is called emerge. Emerge is a command line tool, and will require super user privileges. Let's assume that we would like to install the command line tool "units" to help us convert units of measure. We can install the units package by typing:
# emerge units
Calculating dependencies ...done!
>>> emerge (1 of 1) app-sci/units-1.80-r1 to /
>>> md5 src_uri ;-) units-1.80.tar.gz
>>> Unpacking source...
>>> Unpacking units-1.80.tar.gz to /var/tmp/portage/units-1.80-r1/work
* Applying remove-script.patch ... [ ok ]
* Applying astronomicalunit.patch ... [ ok ]
>>> Source unpacked.
.
.
.
This just shows you the beginning of what emerge does for you. When it is done, units is installed. Emerge has loaded the source code, compiled and installed the program. Not bad for typing just two words! Suppose we want to remove units now. We can remove the package almost as easily. Just type:
# emerge --unmerge units
For more information on emerge, check the Gentoo Handbook's A Portage Introduction

Updating software under Gentoo Linux
Prerequisite: Internet Access
Prerequisite: Super User Authority

Updating software is very similar to installing it. Suppose we know that there is a new version of Open Office out and we need some new features it offers. We would type:
# emerge sync
# emerge --update openoffice
That seems quite simple, so let us next address keeping your whole system up to date. This can be a much more involved process. We will only explain the basic flow assuming everything goes smoothly. (The more often you update, the more likely everything is to go smoothly). Here is a table of the commands and a description for each:

CommandsDescriptions
emerge sync - updates the portage tree (the list of available software and versions)
emerge -uDpv world - list all installed software that has available updates
emerge -uDv world - update all installed software where updates are available
emerge -pv depclean - describes what software is no longer neccessary
emerge -v depclean - remove software that is no longer neccessary
revdep-rebuild -pv - describe software that was broken in the update or removal process
revdep-rebuild -v - re-compile (fix) software that was broken in the update or removal process
etc-update - update any configuration files that need it
glsa-check -f all - check for security updates and fix any security flaws

This information has been paraphrased from a post on the Gentoo Forum by robmoss.

Installing a local printer
Step 1.) Make sure that the CUPS daemon is installed. Open a shell and get super user authority. Check to see if CUPS is installed by typing:
# emerge search cups
Searching...
[ Results for search key : cups ]
[ Applications found : 6 ]

* net-print/cups
Latest version available: 1.1.20-r5
Latest version installed: [ Not Installed ]
Size of downloaded files: 3,653 kB
Homepage: http://www.cups.org/
Description: The Common Unix Printing System
License: GPL-2
.
.
.
The "Latest version installed" line shows cups is not installed. If a version number is listed, you can skip the installation. Install cups by typing:
# emerge cups
Step 2.) Make sure CUPS is running. Type:
# /etc/init.d/cupsd status
* status: stopped
If the status is stopped, start cups by typing:
# /etc/init.d/cupsd start
It is a good idea to have cups start each time the computer is turned on if you plan to have a printer connected. To make sure cups is always started upon computer startup, type:
# rc-update add cupsd default
Step 3.) Open your favorite web browser and go to the local cups administrative website at: http://localhost:631/. Click on the "Manage Printers" link and then on the "add printer" link. Type in a name for the printer (Location and Description are optional). Hit continue and you will be asked to pick the device for the printer. Assuming that you have a usb printer, you should see it listed next to a usb printer entry. Select it and click continue. Select the appropriate brand for the printer and click continue. Select the appropriate model for the printer and click continue. You are now done. If you select the Printers link at the top of the page, you can see your printer. Click on "Print Test Page" to make sure it works. If you are having troble, you can check the Gentoo Printing Guide for more in-depth coverage. Not all printers are well supported under linux. Check to make sure that linux has support for your printer at the printer support database.

Checking how much disk space is free
There are two commands that are extremely usefull in getting a better picture of our disk space usage. They are df and du. du stands for Disk Usage and it can tell you how big a file is or how much space is taken up by all the files in a directory and all its subdirectories. If we want to list the disk space used by our home directory, we can type:
$ du ~/
The output is listed in KB (Kilo bytes) by default, and it lists the size of every file and subdirectory. It finishes with the last line showing the total for the directory we asked about. We can make it list results in human readable form and only show us the last line by typing:
$ du -h ~/ | tail -n 1
768M /home/chris/
The df command stands for Disk Free and will tell us which partition a file or directory is on and how much of the disk partition is free. You may wish to see how much space is left on the /var/ file system by typing:
# df /var/
The df command also accepts the -h option to label the units with human readable tags like K (Kilo bytes), M (Mega bytes), or G (Giga bytes).
# df -h /var/
Filesystem Size Used Avail Use% Mounted on
/dev/hda6 9.4G 930M 8.5G 10% /var
The most common file systems for an administrator to watch the size of are /var/ and /home/ since log files tend to grow quickly when there are problems and users tend to take up more or less space in unpredictable patterns.

Scheduling a task with the cron daemon
Cron is the service that runs programs at regular intervals. Not all users are allowed to use cron. Usually this is the realm of the administrator, though most administrators may grant permissions for a user to access cron if they have a legitimate reason. Cron operates on a file of rules to tell it when to run programs. This is accessed by the crontab program. We can look at scheduled jobs by typing:
# crontab -l
38 3 * * * emerge --sync
0,30 * * * * /opt/bin/halfHourSystemCheck
With this output, we see that two rules are already in the example system. The first runs the command "emerge --sync" at 3:38 am each morning. The second runs a "halfHourSystemCheck" command on the first and 30th minute of every hour. The rule format is:
[min] [hour] [day of month] [month] [day of week] [program to be run]
We could run some report program called "myreport" at 2pm every Monday by adding a rule:
0 14 * * 1 myreport
The "*" can be thought of as "every" or "all". To actually enter this new rule, type:
# crontab -e
This will bring up your system editor. Make a new line for the new rule and type it just as it looks above. When you exit from the editor, the modified crontab will be installed automatically. To insure that it worked, try the crontab -l command again. If you do not see your additions, try again and make sure that you save the file before exiting the editor.

Checking my network (IP) address
The task of checking our network address is often a part of trouble shooting network problems. All addresses for your machine can be found by typing: # ifconfig -a
or as a non root user: $ /sbin/ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:40:63:CB:50:EB
inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:375003 errors:0 dropped:31 overruns:0 frame:0
TX packets:273324 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:211214538 (201.4 Mb) TX bytes:107901479 (102.9 Mb)
Interrupt:15 Base address:0x8000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:135793 errors:0 dropped:0 overruns:0 frame:0
TX packets:135793 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:23095292 (22.0 Mb) TX bytes:23095292 (22.0 Mb)
Our local address is listed under "eth0" in the line starting with "inet addr:" as "192.168.1.5". In this case, we are connected to a local network, and not directly connected to the internet. To find the address that you have on the internet, open a web browser and go to www.checkip.org. If you are on a local network, this address as seen from the internet is likely to be shared between many computers on your internal network.

Accessing my Windows files
We assume that you have a dual boot machine where you can select at startup time which operating system you will use. Windows does not read linux file systems, but Linux can read Windows file systems. We assume that linux automatically mounts your windows disk partitions. The typical place for windows partitions to be mounted would be /mnt/win_c for the C: drive and /mnt/win_d for the D: drive. (You may not have a D: drive). You will need super user authority to access your windows drives. Then you need to know where on your windows file system you can find the files you want. This is typically under "C:\Documents and Settings\<your user name>\My Documents" so you would type:
# cd /mnt/win_c/Documents\ and\ Settings/<your windows user name>/My\ Documents/
# ls
Most of your files are likely to be in subfolders. Lets assume you want to copy a picture called MyGrandma.jpg from the subfolder "My Pictures" and put it in your pictures directory on linux.   Type:
# cp My\ Pictures/MyGrandma.jpg /home/<your linux user name>/pictures/
Notice that we insert a backslash or "\" in front of spaces in file names on linux. This tells the command interpreter that we want a space character instead of treating the space as separating command arguments. Now we should remember that we coppied this file while we had super user authority. We want to be able to manipulate the picture in linux as our normal selves. To change the permissions on the picture type:
# chown <your linux user name>:users /home/<your linux user name>/pictures/MyGrandma.jpg

Starting PPP dial-up services
We will assume that the PPP services have been configured already and that a standard modem is attatched to the computer and on. To start a dial-up session to get access to the internet, type:
$ pon
This will initialize the modem and connect to the default internet provider set up in the configuration. Once PPP is up, you can use the internet. To disconnect from the internet, type:
$ poff
Note that you may have to have super user authority to do this on some systems. Your systems administrator can allow you to dial up without super user permissions by making you part of the "dialout" group.

About Us | Grown Software | Custom Hardware | Support
Valid XHTML 1.0! Powered by Gentoo Linux Powered by the Apache Web Server