Answers 93

From LXF Wiki

Answers 93

<title>Installing from DVD</title>

<question>I am brand new to Linux, and have successfully installed the OpenSUSE 10.2 distro that came on the LXF89 DVD in your magazine. Awesome! So far I am very impressed by what little I've seen in the Linux program. My question, however, will reveal my ignorance: how do I get the other programs on the DVD (like FLPhoto) from the DVD to my computer, and have them become usable? I have found no instruction on moving, installing, incorporating or otherwise getting the programs `installed' and making them usable. I am sure this is because it is assumed that anyone using the DVD and Linux knows how to do this, but I have no clue. </question>

<answer>Installation methods vary, according to how the software is packaged. In the example you give, there are two files containing FLPhoto: flphoto-1.3-source.tar.gz and flphoto-1.3-linux-intel.rpm. RPM is the package format used by SUSE, so the latter file is the one you want. You can install it using SUSE's Yast ­SUSE's `do everything' administration program ­ by double-clicking on the file. You'll be asked for the root password, which is needed because installing software involves writing files to system directories, then the installer will pop up and you need only to click Install. If there is no RPM file, you are left with the option of installing from the source code tarball (these files generally end in .tar.gz or .tar.bz2). The Essential Linux Info section of the magazine gives generic instructions on installing from source code on page 78. Installing from source requires a compiler, which SUSE doesn't install by default. It is on the installation DVD though; all you need to do is fire up Yast, click on Software Management, type gcc into the Search box, select only the gcc package and click on Install. The gcc package will also install any other components needed to be able to compile software from source. </answer>

<title>Optimum Optus</title>

<question>I have broadband with Optus in Australia. I was unable to get Linux to connect to the modem (a Siemens SpeedStream 4200) until I got Gentoo 2006.1. Once it worked I found the difference was that it used dhcpcd and the others used pump or dhclient. Mandriva 2007 offered all three, but only dhcpcd worked. When I checked, I found that dhcpcd uses the -h hostname option. I haven't been able to get the other programs to work, but I have been able to get other distros (DSL-N, Knoppix and Ubuntu) by mounting the Gentoo partition and running dhcpcd, which brings up the net immediately. The others get what looks like a valid IP address but don't connect or drop the connection before I can use it. I think Optus has a special version of the modem, but it does use other brands of modem. I originally used the Windows setup disk on XP until I found Gentoo worked. What is the difference between the programs? </question>

<answer>It seems that this is a fairly common problem with this modem. When used with some DHCP programs, it does exactly what you describe: it gives out an IP address and then drops the connection. There are two possible solutions, the first of which you have already discovered. By using dhcpcd, you can pass a hostname to the modem with the -h option. There is an equivalent option with pump, -u or --hostname, but not with dhclient. It would appear that either the modem or your ISP is very picky about the format of any DHCP requests you send. Given the apparently flaky nature of the DHCP support in this modem, the second solution would be more reliable: to use static addressing. You need to find the IP address of the modem, which you can do after a successful dhcpcd negotiation, by connecting through Windows or by trial and error. The default address varies according to the ISP it is intended to be used with, but the default for OptusNet should be 10.1.1.1. Once you know the modem's IP address, it is easy to configure your computer's Ethernet interface to use a static address. Pick an address on the same subnet as the modem, say 10.1.1.2 and set the gateway and DNS server addresses to that of the modem (10.1.1.1). The netmask needs to be set to 255.255.255.0. With a setup like this, you should have no more problems. DHCP is a great time saver when working with larger networks, or when moving from one network to another with a laptop. For a small home network, it is usually simpler to just give each device its own static address. </answer>

<title>Mail from anywhere</title>

<question>I've been using Thunderbird as a mail client and am very happy with it. I've now acquired two laptops and would like to be able to access my mailbox from all three machines ­ ie for them all to share the same contents. My requirements in a nutshell:

  I want to download all mail from the ISP once (I don't want to leave it on the ISP).
  I want to use Thunderbird as the mail client on all machines.
  All machines should share the same set of mailboxes so that I can, for example, send email from 
  laptop 1 and be able to see the sent emails on laptop 2 and desktop as well.
  It should be able to run on Mac OS X 10.4 as well as Linux.
  It should be open source.

I've tried simply sharing out the mailbox directory using Samba, but this doesn't seem to work ­ it seems to screw up index files. </question>

<answer>There are two ways you can achieve this. One is to use POP3 to collect mail from the server and synchronise the mail storage directories on the two machines. Unison (www.cis.upenn.edu/~bcpierce/unison) is excellent for performing this task, as well as for synchronising any other part of your home more than one box. Unison is best suited to keeping two computers in sync ­ I use it to keep my laptop and desktop up to date with each other. It uses the rsync protocol to save bandwidth and time but, unlike rsync, it can handle situations where each computer has had files updated since the last sync. Using it with three machines would require a little more effort to begin with, but would certainly be workable. Your other option, which applies only to email, is to run your own IMAP server on your desktop machine. Here you would run Fetchmail to pull messages from your ISP and store them locally, then point the mail programs on all the computers to the IMAP server on the desktop (you do this on the desktop too, setting the server to localhost). Your mail is stored on the server and so is status information, so when you read a mail from one computer it is marked as `read' on all of them. Unlike with POP3, with IMAP you leave your mail on the server and can read it from anywhere with an internet connection. Most mail clients have an option to synchronise their local store with the server, so you can also keep local copies of mails for reading when offline. I prefer to use Dovecot (http://dovecot.org), but the easiest choice is probably to use whichever IMAP server your distro defaults to, as that will be largely set up on installation and have the most support from your distro's forums or mailing lists. For something as straightforward as your needs, you shouldn't have to move very far ­ if at all ­ from the default configuration. The Dovecot wiki, at the above address, has plenty of information on there is more than one person in your household, is that you can get Fetchmail (possibly with the help of Procmail) to sort your mail into separate mailboxes for each user. Then each can access their mail using the same IMAP server (but a different login name of course). </answer>

<title>Switchdesk or su?</title>

<question>I've finished installing Fedora Core 6, and have downloaded the 200-plus upgrades. I need to get out of root but can't locate the switchdesk command. I don't want to reinstall to get this. </question>

<answer>You shouldn't be running the desktop as root in the first place! There is never any need to do this, which is why some distros make it difficult to load a root desktop. The system administration programs can all be run from a standard user desktop. When they need root privileges, they will ask you for the root password, then drop root privileges when they no longer need them. If you need to run any other programs as root; open a terminal, type su - to become root then run whatever programs you need from there. This is far safer than running the entire desktop as root, although it goes without saying that you should quit any programs run as root as soon as you have finished with them. Switchdesk is still available. Select Add/Remove programs from the Applications menu and type switchdesk into the Search tab ­ you will probably want switchdesk-gui as well as switchdesk. Once it's installed, you can run it from System > Preferences > More Preferences > Desktop Switching Tool. However, this is not the correct way to run programs as root; switchdesk is intended to allow users to switch desktops, hence the name. Keep the root user where they belong: locked in a box only to be let out when needed. You should rarely need to reinstall a Linux distro. The computer I am using now is three years old, as is the Linux installation running on it ­ it has been frequently updated but never reinstalled. Reinstalling doesn't fix problems, it merely removes the whole environment containing the problem... until the next time it occurs. If you fix the problem itself, instead of wiping the whole system, it should go away forever or, even if it doesn't, be easier to fix the next time it occurs. </answer>

<title>Use the source</title>

<question>I am very new to Linux, although there do seem to be some similarities to the Amiga of years past. After a few attempts I have finally installed Fedora Core 5, dual booting with Win XP. I have tried to install FreeBasic using your instructions `How to install from source code' [Essential Linux Info], with no success so far! It does not seem to recognise ./configure and some of your other instructions. </question>

<answer>One significant difference between Linux shells and the Amiga shell is that Linux does not include the current directory in the path by default, whereas AmigaDOS did. The Linux way is more secure, but it means you have to specify the path when running a script or program from the current directory. The current directory is denoted by `.' so ./configure means "run the program or script called configure in the current directory" It should now be clear that the command ./configure only works when the file configure exists in the current directory. Compiling from source usually involves unpacking the tarball, changing to the directory created by the previous step and running ./configure, followed by make and make install ­something like this:

tar xf foo-1.2.3.tar.gz
cd foo-1.2.3
./configure
make
make install

While this applies to more than 90% of Linux applications, there are many exceptions. After running cd, look for files called README or INSTALL. These contain specific instructions on compiling and installing that particular application. In the case of FreeBasic, if you want to install from source, you have to do the configure-make-make install dance several times, after downloading two archives. Alternatively, you may have the pre-compiled binary archive ­ FreeBASIC-v0.16b-linux.tar.gz ­ which uses a completely different installation method with its own install script. Read the file readme.txt inside this archive for precise details on installation. We ask you to read the file rather than reproduce the instructions here, because there may be subtle changes in the installation process between versions. The readme.txt file should be considered authoritative. Always look for installation instructions when installing from an archive (as opposed to using a distro's package manager), as you are executing commands as root that could have an adverse effect on your system if done incorrectly. </answer>

<title>OOo bother!</title>

<question>Regarding OpenOffice.org 2.1 from LXF90's DVD: I am very new to Linux so I've no idea how obvious the answer to my problem is, and any answer probably needs spelling out to me. Following the instructions in the magazine I tried to install it into OpenSUSE 10.2. Everything went well until I entered

su -c "rpm -ivh *"

which returned the message:

  `desktop-integration: not an rpm package
  (or package manifest): Is a directory'

This is where my scant knowledge fails me. I did try what seemed the obvious course of action and moved the desktop integration folder elsewhere, but that didn't seem to work. I did try tinkering around with some other stuff but I was really stumbling around in the dark. </question>

<answer>When the shell sees a * on the command line, it replaces it by all matching files ­ * means "match any string" In this case, it matches all the RPM files and the desktop-integration directory. The solution is to be more specific and use

su -c "rpm -ivh *.rpm"

This now matches anything that ends in .rpm, which is what you need. If you also want to install the RPM files in the desktop-integration directory, extend the command to include these:

su -c "rpm -ivh *.rpm desktop-integration/*.rpm"

Note that adding desktop-integration/* will not work, because not all of the files in that directory are RPM packages and you will end up back at your original error. </answer>

<title>Modem malaise</title>

<question>I have installed Mandriva 2007 from your coverdisc [LXF87] to a Dell 5150. The Dell has no serial or parallel ports, just USB. I have a Sitecom 56k V.92 USB modem, model DC-009, but I cannot get Mandriva to connect to it. The USB keyboard and mouse work fine. I can get the cdc_acm module to load with modprobe but it does not seem to connect to a tty, although KPPP sees ttyS0 and ttyACM0 and reports `modem busy' when I query the modem on either ttyS0 or ttyACM0. I have trawled the net to no avail, including www.linux-usb.org. The modem worked out of the box in Windows XP. These issues should surely be a thing of the past by now? </question>

<answer>It would appear that this modem either is not fully supported or needs some kind of firmware file. This particular modem failed to show up on a web search, but that is not too surprising. Many of these devices are made by one manufacturer and branded by another. However, all such devices need to be approved by the FCC (Federal Communications Commission) for sale in the USA, so you can find out what it really is from its FCC ID code. Type the code into the box at the bottom of www.hardwaresecrets.com/page/fcc to find out who really made your modem. Once you are in possession that information, a search of sites like www.linux-usb.org should prove a lot more fruitful. There is a further complication that has a bearing on your situation: USB modems can be problematic because they are not truly standardised, with only some of them conforming to the CDC-ACM specification. Your USB keyboard and mouse work well because they all conform to the same standards (USB HID). One way to sidestep this problem is to use a serial modem via a USB serial adapter. I have a couple of these devices, using different chipsets and both bought cheaply from eBay, and they both work very well with the majority of the serial devices I have tried (a UPS being the only exception). This way you can use any serial modem, as well as any other serial devices you may wish to use with this computer. It seems that we have managed to get rid of parallel ports and floppy disc drives, but the old serial port just won't go away. </answer>

<title>Qemu query</title>

<question>The Qemu emulator looks interesting, but it is impossible to get working as you describe it. It says it needs GCC 3 to compile, and OpenSUSE 10.2 has only GCC 4. Is there any way round this? May I ask if another member of your staff tries out your various programs and ideas before committing them to the magazine? </question>

<answer>Qemu is one of the very few programs that still fails to compile with GCC 4, but it is unfortunate that distros like OpenSUSE no longer have GCC 3 packages available. It is still possible to install GCC 3 on your computer, either directly from source or by using the RPM packages from Fedora Core 5, which are reported to work with OpenSUSE 10.2. However, this is a lot of work for a single program, and there are precompiled packages available. One OpenSUSE 10.2 user has compiled Qemu and made it available from www.hasanen.com/files/linux/qemu.tar.gz. Now there is also a package on SUSE's website. Point your browser at http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/suse/i586 and click on the Qemu file (currently qemu-0.9.0-3.i586.rpm but it may have been updated by the time you read this). When the browser asks what to do with the file, select the option to install it and wait for it to be downloaded and installed (you'll need to give the root password when asked). Alternatively, you can install it from the command line with

su -c "rpm -ihv http://download.opensuse.org/
distribution/SL-OSS-factory/inst-source/suse/
i586/qemu-0.9.0-3.i586.rpm"

We do take every care to ensure that information given in the magazine is correct, including having another person try out instructions. It is an unfortunate consequence of the large number of distros, and the various permutations of installed packages for each one, that it is impossible to say that anything more complex than echo Hello World will work on every possible configuration without additional steps. The good news is that newer versions of Qemu are ikely to be compatible with GCC 4. </answer>

<title>Go directly to jail</title>

<question>I want to set up my SUSE

        10.2 system to allow
        users to connect to my

OpenSSH service. I can see any folder on the system when I connect (even as a regular user). How can I have it restrict users so that they can only see folders within the home folder that I assign to them when I create their user account? Is it possible to restrict certain users to just SFTP or SCP functions?

</question>

<answer>An SSH login is virtually the same as a local login, apart from the fact that it operates through an encrypted tunnel. So a user has the same rights when they are logged in via SSH as they would when sitting in front of your computer. This normally means they can read system directories ­ otherwise they wouldn't be able to run any programs ­ but not modify them. It is possible to set up a system to chroot a user to their home directory on login, but this is a far from trivial task. If you want to try this, I suggest you look at Jailkit (http://olivier.sessink.nl/jailkit), a set of utilities which will make this task somewhat easier. Jailkit can also be used to restrict users to SFTP or SCP connections only, but there is a simpler alternative if this restriction is all you need. Scponly (http://sublimation.org/scponly) is a replacement shell program that refuses shell logins but allows SFTP and SCP connections. The simplest way to run this is to set the user's shell to scponly in /etc/passwd. This will prevent shell logins, but will still allow them to traverse the filesystem according to the permissions of the various directories and files. There is also a chroot option for scponly, but this also adds a level of complexity ­ you may be better off with Jailkit if you want this. The difficulty of setting up a chroot login is that you must provide all the files the user needs to do whatever they need, including running programs, within their home directory, without providing anything they don't need that you don't want them to see. Programs like Jailkit work very well for this when used for a specific purpose ­ such as chrooting a server ­ but not so well for interactive logins. Depending on your security needs, in a majority of cases it is probably better to keep your system secure at the local level, by ensuring that non-administrative users cannot read system- critical files, then this security will automatically apply to any SSH, SFTP or SCP connections. </answer>

<title>Sparkling cron cleaner</title>

<question>As I'm getting rather too many comment spam attacks on my web server, I thought I'd set up a cron job to delete the comments automatically ever so often, but I can't get the command to operate. I'd welcome any thoughts on the code I'm using:

mysql -h hostname -u username -ppassword -e
`delete from table_name where pn_cid > x'

I do have more than one database on the server, and I note the above line of code doesn't have any mention of which database it should address, so perhaps there is a missing switch? </question>

<answer>You do need to specify the database name (even if you have only one database), otherwise MySQL won't know how to apply your commands. The database name can be given as the last parameter on the command line, or within the commands you pass to the mysql program. These are equivalent:

mysql -u user -ppword -e "delete from table_name
where pn_cid > x" database_name
mysql -u user -ppword -e "USE database_name;
delete from table_name where pn_cid > x"
mysql -u user -ppword - "delete from database_
name.table_name where pn_cid > x"

The first is simpler, but the others offer more flexibility. You can also pipe the commands to the MySQL client instead of using the -e option. This is useful if you want to run a number of commands, because you can put them in a file and do

mysql -u user -ppword <cmdfile

You also need to be aware that programs run by cron do not have the same environment as programs run from a shell. As there is no user login involved, the various environment variables in your profile are not set up. You can get around this by putting the commands in a short script:

#!/bin/sh
source /etc/profile #or ~/bash_profile or ~/.bashrc
mysql -uuser -ppword ...

Use whichever file contains your environment settings on the second line and set your cron task to call this script instead of running mysql directly. Using a script also makes testing slightly easier, as you know exactly the same commands are used whether you run it from a terminal or cron. Specifying the password on the command line is considered insecure because it is then available to any user on the machine for as long as the program is running, simply by looking at the output from ps. A safer option is to put the password in ~/.my.cnf, as

[client]
password=your_pass

and

chmod 600 ~/.my.cnf

makes sure the file is only readable by your user </answer>

<title>From me to you</title>

<question>How do I change the `from' address when using the Linux mail command? It insists on marking mail as from user@user-laptop (user-laptop is my hostname). </question>

<answer>This is not possible with the standard mail command without fiddling with the USER and HOSTNAME environment variables, which may have unwelcome side-effects on other programs running in the same shell. However, there are a number of alternative commands that will do what you want. Mutt is able to read the `from' address from the EMAIL environment variable. This is worth knowing if you already have Mutt installed, but it is a lot more than you need if you only want to send out messages. A small alternative is SMTPClient (www.engelschall.com/sw/smtpclient), which is similar to mail in operation but accepts the --from argument to set the `from' address. SMTPClient only passes your mail to a suitable SMTP server and defaults to localhost. If you want to use a different server, you will need to specify it with the --smtp-host command line option, or set the SMTPSERVER environment variable.

echo "Hello world - what else?" | smtpclient --
smtp-host=my.mail.server --from=hubris@
wherever --subject "Hello World"
someone@someplace

</answer>

<title>Going wireless</title>

<question>I have downloaded and installed OpenSUSE 10.2 and everything seems to go well, except for my wireless network. I am totally new to this and would appreciate a dummy's guide to setting it up. </question>

<answer>The answer to this depends on the type of chipset used in your wireless card. First, run Yast and go into the Network Card section. If your card is displayed, you can skip ahead, otherwise you'll have to identify the card by running lspci or lsusb (depending on the card type) in a terminal. You may have to type the full path to lspci, /sbin/lspci. Google is great for finding out which drivers you need. For USB devices, there is a useful list of devices and drivers at www.qbik.ch/usb/devices. Once you know the driver you need, the next step is to make sure it is installed. Some drivers are part of the Linux kernel, others need installing separately. Run /sbin/modprobe -l in a terminal to see a list of all in- kernel drivers. If yours is not listed, use the Search box in Yast's Software Management section to find a suitable package. If it is not in Yast, you need to go to the homepage of the driver to follow the instructions for installing from source. If the driver is present on your system but the card is not recognised, you probably need a firmware file. These are generally extracted from the Windows drivers. Once again, see the driver's website for details. As an example, lsusb identifies my Edimax USB device as a ZyDAS device. The above website confirms this uses the zd1211 drivers (included in recent Linux kernels) but the device also needs firmware files, available from http://sourceforge.net/project/showfiles.php?group_id=129083. SUSE expects he firmware files to be in /lib/firmware/zd1211 (other distros may use /lib/firmware), so create this directory, unpack the firmware archive and copy all the files to /lib/firmware/zd1211. Now go back to the Network Cards section of Yast, or start paying attention again if your card was already recognised. Your wireless device should appear in the list ­ select it and click the Edit button. Select Automatic Address Setup on the Address tab and set Device Activation on the General tab to either On Hotplug if it is a plugin USB device or has a switch (this will cause the wireless network to connect when you connect or turn on the device); otherwise use the Manual setting and control the device from the Network Manager icon in the taskbar. Press Next and Finish to exit the configuration. Go to the Network Manager applet in the taskbar, which should show a list of available networks. Select yours. If the network is secured with WEP or WPA encryption, you will be asked for the passphrase. If possible, consider turning off encryption on your access point while setting up the connection: let's get the connection working before we add an extra level of complexity! Once the network connection works, disconnect, turn the encryption back on and reconnect. This time SUSE will ask for your WEP or WPA passphrase and you should be connected securely. </answer>