Answers 87

From LXF Wiki

Answers 87

<title>SUSE DVD to CDs</title>

<question>I thought that SUSE 10.1 from your August issue [LXF82] would give me an excellent opportunity to set up a Linux computer and begin to learn the system. I have a computer with a DVD reader but it's not the one I want to use for Linux and, being severely Linux-challenged, I don't know how to create installation CDs for my other computer from this distribution. </question>

<answer>That disc included a mkiso script to create CD images from the DVD, but only under Linux. We have included a script that will do the same thing under Windows on this month's DVD. The procedure takes a little longer than normal, because the script is not on the same disc, but it isn't too complicated. Start by copying the winmkiso.bat file from this month's DVD to somewhere to your hard disk. It doesn't matter where, and you can delete it when done. For the sake of this example, I'll assume that you copied it to C: and that your DVD drive is D:. Then open an MS-DOS prompt or command box and type

D:
cd distros\suse
c:\winmkiso

It will take a while to complete ­ a long while, because it has to scan the entire contents of the DVD for each CD image it creates. This appears to be a limitation of Jigdo, the program that does the hard work. The Linux version caches the data from the first scan to speed up the subsequent ones. The Windows version should do the same but in reality it takes a long time for each disc. Eventually, you will have five ISO images in C:. You can burn these files to CD using Nero or any other CD-burning program, but make sure you use the option to burn an image file. If you want to put the created ISO images somewhere else, give the path at the end of the winmkiso command. For example, if your DVD drive is E: and you want to save the ISO images to D:\suse, type

E:
cd distros\suse
c:\winmkiso D:suse

Make sure the path you choose exists, otherwise winmkiso will spend a significant proportion of your lifetime scanning the disk and then abort with an error when it cannot write the ISO file. </answer>

<title>Trust me</title>

<question>I have just been given a new digital camera (manufactured by Trust), and I have been unable to get DigiKam to recognise it. However, /var/log/messages seems to detect that a device has been added to the USB port, and the camera is powered up. I don't know anything about USB, but I do know that an entry does not exist in my /etc/fstab. Could this be the problem? Is KDE's DigiKam the best software to use? </question>

<answer>You don't need an entry in fstab for KDE's automounting to work. In fact, it generally works best without such an entry. However, not all digital cameras work as USB mass storage devices; some use camera-specific protocols. Does /var/log/messages show partitions when you connect the camera, in much the same way you would see with a USB memory stick? Something along these lines would indicate that it is a mass storage device:

usb-storage: waiting for device to settle before
scanning
Vendor: NIKON Model: NIKON DSC E3200
Rev: 1.00
Type: Direct-Access                   ANSI SCSI
revision: 02
SCSI device sda: 2012160 512-byte hdwr sectors
(1030 MB)
...
SCSI device sda: 2012160 512-byte hdwr sectors
(1030 MB)
sda: sda1

If not, this camera doesn't show itself as a storage device. But DigiKam should still recognise it if it is supported by Gphoto2, and you have Gphoto2 installed. Gphoto2 is the command-line client for libgphoto2, which is used by DigiKam. If you don't have it installed, you should find it on your distro's discs. You should run it as a normal user and as root ­ any difference in the output will indicate a problem with permissions. To find out if your camera is supported, run

gphoto2 --auto-detect

and note what it shows. If your camera is not recognised, check the archives of the mailing lists at www.gphoto.org and send the developers details about your camera. DigiKam is a fine program for managing digital photos, but if all you want to do is copy pictures from the camera, you can do that with Konqueror, by typing camera:/ in the location bar. This will show a list of any connected cameras that libgphoto2 recognises. </answer>

<title>E-mail anywhere</title>

<question>I have a Linux mail server (SquirrelMail). How can I check my mail from any Windows workstation without installing any extra software? </question>

<answer>You can read your mail using any standard mail software, or even Outlook Express. If you want to be able to read it without reconfiguring the mailer on the workstation, as would be the case if you were only using it temporarily, your best option is to install a webmail program on the server ­ that way you can read your mail from anywhere with nothing more than a web browser. One of the most popular webmail servers is Squirrelmail (www.squirrelmail.org). You will need an IMAP server running on the Linux box, because most webmail programs use IMAP. SquirrelMail is a PHP program, running through a web server, so you will also need Apache (or another web server) installed and running. Once installed and configured, which is well documented and a simple process, you can access your mailbox from most web browsers. While SquirrelMail is one of the more popular and longstanding webmail projects, there are several other choices; I rather like RoundCube, from www.roundcube.net. This is an Ajax project, and although it's only at release 0.1beta2, seems stable with a reasonable feature set. Which of these you choose to use, or whether you go for another alternative, such as NeoMail (http://neocodesolutions.com/software/neomail) depends on your needs. If you need only occasional access to check your email when away from your own computers, I would recommend you try RoundCube, although any of these is fine for this task. If you anticipate a heavier use requiring more of the features of a full email client, you should try them all and see which suits your needs best. You can have more than one of these installed at a time by putting each one in a different directory on the server. That way you can jump between them before you decide which one suits your needs most closely. </answer>

<title>Hidden partition</title>

<question>My father in-law recently expressed some interest in GNU/Linux, so I told him to download the brand-new-to-Linux distro du jour, Ubuntu. I really, really, expected the install to go smoothly, but he ran into a problem that has me stumped. The answer is probably simple, but beyond me. He is using a new-ish P4 Dell that came with Windows XP pre-installed. He had about 10GB of free space to use for the installation. The normal installation procedure ran smoothly and instructed him to reboot. Upon reboot, Grub returned an Error 21. After he did a little digging, he found out that Dell places a small, invisible partition on its disks that contains Dell tools and utilities. Apparently, the MBR [Master Boot Record] has been moved somewhere unusual on these machines. After consulting the marvellous Ubuntu forums, I discovered that, a/ yes, this is the problem, and b/ nobody seems to have a good solution. So, how do I configure Grub so that it boots properly? I don't have physical access to the machine, but I know it only has a single hard drive. After install, the partitions should lay out something like:

 hda1 Dell super-secret files.
 hda2 Windows.
 hda3 onwards boot.
 / swap.

</question>

<answer>You don't say which model of Dell this is, but the usual layout is to put the Dell utilities partition on hda1 and a bootable Windows partition on hda2. The MBR should be in the usual place, otherwise the BIOS wouldn't be able to find the partitions. Grub Error 21 is a stage 2 error, which tells us that Grub has already loaded from the MBR and found its stage 2 files in /boot to be able to get as far as this error. Error 21 means `Selected disk does not exist' so this would appear to be an error in the Grub configuration: trying to load a kernel from the wrong place, such as a non-existent partition. This is definitely the case if Grub is able to load Windows (which would atleast prove that Grub itself is working). Press Esc to get to the Grub menu, highlight the Linux entry and press `e' to see the details. You should see something like this:

root (hd0,0)
kernel /boot/vmlinuz-2.6.15-23-386 root=...

There is a good chance the root setting is wrong. Press `c' to get the grub command prompt and type

find /boot/vmlinuz-2.6.15-23-386

using the full filename specified in the kernel line above. This will return the location of the partition that contains the kernel, which will probably be hd(0,2) or (hd0,4), depending on whether /boot is on a primary or logical partition. Press Esc to get back to the menu entry, highlight the `root' line and press `e' to change it to match the output of find. Press Enter to accept the change then `b' to boot. Once you know it works, you can edit the configuration file to make the change permanent by running this in a terminal:

sudo nano /boot/grub/menu.lst

You'll find the menu details below the line that reads `## ## End Default Options ##' The bad news is that you really need physical access to the computer to do this, or to be able to talk your father-in-law through it. </answer>

<title>Automating layout</title>

<question>I would like to print an image, JPEG or BMP, and a text file in one report. Is there any freeware that would allow me to do this easily via the command line? I want to pre-generate reports via a script automatically. </question>

<answer>Yes, there are a number of ways to do this. Which one you choose depends on the quality of output you need and how much time you are prepared to spend implementing it. The easiest way is to write the report to HTML, which can be viewed or printed in a browser. The following shell script will take the names of an image and a text file and write the HTML to standard output. It's a very basic example, but you'll get the idea.

#!/bin/sh
echo "<html><head><title>My Report</title></
head><body>"
echo "<img src=\"$1\" align=\"right\">"
cat $2
echo "</body></html>"

At the other end of the spectrum would be one of the Tex-based packages, such as Tetex or Lyx. These are typesetting programs that give you a great deal of control over the finished document's layout. The learning curve is steep, but the results may justify it. Tex source files are plain text, so it would be easy to generate them from the command line using a template file and a short shell script. Lyx provides a somewhat simpler means of producing Tex files. It is a graphical application, but once you have created your template you could manipulate it with a shell script. You have a choice of splitting the template into three and doing something like this:

cat template1.lyx >report.lyx
echo /path/to/my/image >>report.lyx
cat template2.lyx report.txt template3.lyx >>report.lyx

Or you could do something more complex by using sed to replace parts of the template with your text and image files. Once you have the report.lyx file, you can output it in a number of formats, all at the highest quality. For example,

lyx --export pdf report.lyx

will produce a PDF report. Lyx is a powerful program with detailed online help. Give it a try. An alternative is to use the scripting capabilities of a word processor or page layout program such as OpenOffice.org (see our recent OOo Basic tutorials, LXF80­LXF84), AbiWord or Scribus. </answer>

<title>Canon can't</title>

<question>I have a dual boot system (Windows XP and SUSE 10.1) and a Canon LBP-1120 laser printer. As stated, the printer works fine on the Windows system. The problem is that try as I might, I cannot make it do anything on the Linux setup. I have downloaded and installed the CAPT drivers (numerous times) and then gone through the printer configuration and generally, nothing happens. The most that has happened is that occasionally the printer will send a piece of paper through, with nothing printed on it. Apart from that, anything that I try to print just stays in the print queue, unless I email it to myself and use Windows to do the printing. </question>

<answer>This is a `Winprinter' ­ one that uses the driver to do part of the work of the firmware. As with their cousins, Winmodems, getting Winprinters to work with anything but Windows can be a frustrating process that is not always successful. You have a choice of drivers for this printer: there is the official Canon driver, which is the one I guess you have tried, and one recommended on www.linuxprinting org that is available from www.boichat.ch/nicolas/capt. I suggest you try both of these drivers and also follow the advice given for this printer at http://linuxprinting.org/show_printer. cgi?recnum=Canon-LBP-1120. When diagnosing printer problems, your first step should be to check the CUPS log files. Type

tail -f /var/log/cups/error_log

in a terminal, then try to print a page. You should see messages written to the error log in the terminal. This often gives a clue as to the cause. By default, the logged messages are quite limited. If you need more information, edit /etc/cups/cupsd.conf (as root), find the line

LogLevel info

and change `info' to `debug' Restart CUPS, either from Yast or the terminal with

/etc/init.d/cups restart

Now the error_log will contain much more detail. As a general point of advice, any Linux user should check the printer database at www.linuxprinting.org before investing in a printer. </answer>

<title>Service Monitoring</title>

<question>I am running a number of services on my server ­ is there a way that I can monitor these services, and restart them if they die? I wondered about using some sort of Cron task. </question>

<answer>There are a number of programs written specifically for this task ­ the most popular of which is probably Mon, which you can get from www.kernel.org/software/mon. There is quite a long list of dependencies, mainly Perl modules, so it would be most convenient to install it with your distro's package manager. Mon can be installed on the computer that you wish to monitor or on any other computer that can reach it over the network. The latter is a better choice, as it will be able to let you know if the server dies altogether. Mon is controlled by a config file located in /etc/mon. Here's an example section that monitors a web server:

hostgroup servers www.example.com
watch servers
 service http
   interval 5m
   monitor http.monitor
   period wd {Sun-Sat}
     alertevery 1h
     alert mail.alert webmaster@example.com

This will attempt to connect to the web server every five minutes and email an alert if it fails. The alertevery parameter means that although it will continue to check every five minutes, it will not send a mail on every consecutive failure, only nag you every hour. Mon is able to monitor more than services: it can also keep track of things like disk space and processes, which could help you prevent a rogue program or denial of service attack stopping the server completely. There are other alert options supplied with Mon, including pager alerts (after all, there's no point in an email alert if the mail server has just died). Monitors and alerts are Perl scripts, so you can customise them or build your own ­ the Mon website has a collection of user-contributed monitors and alerts, you can be nagged by AIM or text message if you really want. Another program worth considering is Monit ­www.tildeslash.com/monit. This works in a similar way to Mon, but is designed to run on the server itself and be able to take corrective action rather than disturb the sysadmin. Monit is able to restart a service that has died ­ it also has a built-in web server that enables you to log in from a remote computer to check on the status of monitored services. The safest approach is to run Mon remotely and Monit locally. </answer>

<title>Waiting for files</title>

<question>I am having some trouble with an updated Red Hat server at work. We have an applet that makes an FTP connection to the server, and users can upload files. This all works fine. The problem lies with a script that runs on the server to look for changes in the modification date of the folder that they are loaded into. When the date changes it processes the file. This worked fine on the old server, but on the new server it appears that while the transfer is in process the folder modification date is being changed. This means that we are getting truncated files, because the process starts before the transfer is complete. Is there any way to set how folder modification dates are created? Is it an FTP issue or an OS issue? The server is RHEL ES 4, the old server was RHEL ES 2. </question>

<answer>Is your script looking at the file modification dates manually? The problem is that the folder is modified twice: once when the new file is opened at the start of the upload and again when it is closed on completion. I had to set something like this up recently and found the best approach is to use the Fam (File Alteration Monitor) service, which is able to distinguish between these events. You need to install Fam and ensure that the famd service is run at startup. Then you need a program that will ask the server to watch for changes to your files or directories and take the appropriate action when informed of them. I found the fileschanged program ideal for this if all you need to do is run a script. You can get fileschanged from http://fileschanged.sourceforge.net, and run it like this:

fileschanged --show changed --
exec /usr/local/bin/ourscript /var/
ftp/somedir/

The --show option tells fileschanged to listen only for changes to files in the directory, skipping the initial notification when the file is created (fileschanged can also watch for files being deleted or executed). When it receives a notification, it runs the script with two arguments. The first is a single letter indicating the type of file change: `M' for modified. The second argument is the name of the file. With this information, your script knows the name of the file that was uploaded and can do whatever you want. You may also find it useful to add a --timeout option to increase the delay in notification of changes to a file. </answer>

<title>Traffic Warden</title>

<question>I need to keep track of how much bandwidth my servers are using. How can I log network traffic for all or selected interfaces? </question>

<answer>There are a number of programs that will monitor and display the traffic though each network interface, most of these use information culled from the /proc filesystem. The main differences between them are the way in which they display the statistics. For a simple overview, Vnstat is a good choice. Available from http://humdi.net/vnstat, and probably in your distro's package repositories too, Vnstat is normally run as an hourly Cron job, collecting statistics from /proc and adding them to its database. You can query this database at any time by running Vnstat from the command line. There are options to display the statistics by day, week or month as well as various other ways of tweaking the output. If you need more than a simple ASCII report, you should try Traffic-vis, from www.mindrot.org/traffic-vis.html. This consists of a number of tools; the one that does most of the work is Traffic-collector, which should be running all the time. Traffic-collector collates information on the traffic passing through the specified network interfaces and saves this data to a file. This file is not meant to be read directly but passed to one of the other programs in the suite that process the traffic data and produce reports in HTML, PostScript, plain text and GIF formats. The HTML option is particularly interesting if you want to monitor a web server, as you could have a CGI script run Traffic-tohtml and give you on-demand traffic reports from a web browser. There are other utility programs included that can process the data in other ways; for example, Traffic-exclude is a useful option if you have bandwidth limits or charges and want to know only how much traffic the interface passed over your more expensive connection while ignoring and traffic between, say, the web server and database server on the same network. </answer>

<title>KFind finds too much</title>

<question>I am using Kubuntu 6.06 with the Ichthux packages but my question is common to any distribution using KDE. The `Find Files' utility searches every directory on the root (/), including the directories in the /mnt directory. This means KFind is searching my files in other distributions, and I usually have several, so KFind loses a lot of time here. Is there some way to configure find to skip /mnt? Otherwise the only solution I can think of would be to unmount /mnt every time before using KFind, but that might create problems. </question>

<answer>KFind is a front-end to two standard shell commands: find and locate. Unfortunately it doesn't give access to all of the options of find, such as specifying which directories or filesystems to search or skip. All you can do is give a starting point. This isn't an issue when searching your home directory, the default, but it can cause the problems you describe when trying to search the whole filesystem. Happily, in the `Use files index' checkbox you can elect to use locate instead of find. Locate uses a database built with the updatedb command for much faster searching, although it only finds files that were present when the database was searched. Updatedb is usually run as a daily or weekly cron task. The search path of locate is configurable, so you should add /mnt to the PRUNEPATHS list in /etc/updatedb.conf. For maximum flexibility, it is worth learning the find and locate commands themselves, eg

find / /home -xdev -iname `*.pdf'

will look for all files ending in .pdf or .PDF in / or /home, but ignore other filesystems (thanks to the use of -xdev) such as /proc, /dev and those mounted under /mnt or /media. The find and locate man pages will give you a lot more information, but the main thing to remember is that locate is for a fast, name-based search while find allows far more control over the search parameters, including filename, file type and file age as well as the directories and filesystems searched. Unmounting filesystems mounted under /mnt may work, but is just as likely to fail if you have an open file or directory in any of them. Either way, it shouldn't be necessary. </answer>

<title>Enlarging GTK fonts</title>

<question>I am looking for information on how to enlarge the fonts in Xara Xtreme, Gimp and similar programs that do not change when System Config > Appearance and Themes > Fonts are manipulated. I am using SimplyMepis, taken from your DVD [LXF84] ­ and like it! </question>

<answer>Xara Xtreme and Gimp use the GTK2 toolkit, whereas the System Config settings only affect KDE programs. I would normally recommend that you install the gtk2-engines-gtk-qt package, which makes Gnome and other GTK programs use your KDE settings and adds options to control the appearance of GTK programs to the Settings menu and the KDE Control Centre. However... although the package is installed by default with Mepis 6.0 it doesn't work. The programs are there but it is impossible to load it (others have reported the same on the SimplyMepis forums). Worry not: there is another way to do what you want, by installing gnome-control-center and using gnome-font-properties. Run the program by typing gnome-font-properties in a terminal or the Run command dialog that appears when you press Alt+F2. This allows you to set Gnome fonts in a similar manner to the way you set KDE fonts. This technique will modify the fonts for the current session, but they will revert to the defaults on the next restart. To make the changes permanent, type this in a terminal as your normal user (not root):

ln -s /usr/lib/control-center/gnome-settings-daemon ~/.kde/Autostart/

This ensures that gnome-settings-daemon is started whenever you load your KDE desktop. The daemon causes your Gnome settings to be applied to all GTK programs. </answer>

<title>Configure me this</title>

<question>I have my usual problem in trying to install a VNC program to my laptop running Xubuntu. I downloaded all the VNC programs on to a recent disc and copied them to my laptop. I then used the correct tar instruction to unpack the archive both of TightVNC and VNC, ran cd into the resulting directory, typed ./configure... and was told the instruction did not exist. I'm afraid this is the usual state when I try to load your programs either on Ubuntu or SUSE. Am I doing something wrong? </question>

<answer>In my ever so humble opinion, it is the distro makers that are doing something wrong. They assume that you will find every program you need in their repositories and that only developers will need compiler tools. In reality, most Linux users will need a compiler at some time, even if it is only to install a driver for their network card or the latest Nvidia graphics card drivers. Even installing VMware, a closed source binary package, requires a compiler for the kernel modules. Many of these require the kernel source too, another package considered non-essential. That's enough ranting. On Ubuntu, you need to install the build-essential package, which includes everything you need to compile from source. With SUSE, you need the gcc package. If you want to install software from source tarballs, which will happen sooner or later, these packages will be essential, so install them now and avoid any grief later. However, in this case compiling from source is not necessary. Both distros include recent versions of TightVNC in their standard repositories or on the install discs, with Ubuntu also including the standard VNC. Unless you need the latest, most bleeding-edge versions, it makes sense to use the packages that came with your distro, as they have been tested, and you will be informed of any updates. </answer>

<title>I want my modem back</title>

<question>I have at last got a good program that I have been after for a long time. With LXF85 along came SLED 10. Brilliant! However, I already have SUSE 9.3/10.1 and my modem works fine in both of these, but try as I might I cannot get my modem working in SLED 10. It keeps asking me for an Ethernet card, which I don't have, and saying that it is not connected. I know the card is not damn well connected because I don't have one! How do I configure the modem to work? I am on dial-up, I do not have broadband. </question>

<answer>When you installed SLED, you should have seen a screen listing your networking hardware (Ethernet/DSL/modem) with options to configure each. If you have an Ethernet connection in your computer ­ and most motherboards have one built in nowadays ­ this will be used as the default if you didn't select anything else. (Remember that SLED is an `Enterprise Desktop' distro, so its native habitat is a PC connected to a LAN.) I suspect this is what has happened here. The default setting for a network card is to use DHCP to ask the network for an address and other connection details. Because your network card is not connected, this request fails, giving the error message you see. You need to disable the Ethernet connection and enable your modem. Both these tasks are done in the Control Centre. Select Network Cards, highlight your network card and press Delete. The card will still show up, but it is now listed as Not Configured. Now go back to the Control Centre and select Modem. From here, you can choose an ISP and input your connection details. </answer>