5. Porting, Compiling and Obtaining Programs

5.1 How To Compile Programs

Most Linux software is written in C and compiled with the GNU C compiler. GCC is a part of every Linux distribution. The latest compiler version, documentation, and patches are on ftp://ftp.gnu.org/pub/gnu/.

Programs that are written in C++ must be compiled with the GNU G++ compiler, which is also included in Linux distributions and available from the same place as GCC.

To build version 2.0.x kernels, you will need GCC version 2.7.2.x, approximately. Trying to build an early Linux kernel with a different compiler, like GCC 2.8.x, EGCS, or PGCC, may cause problems because of GCC related code dependencies. Kernel versions 2.3 and 2.4 should compile correctly with more recent compilers.

Information on the EGCS compiler is at http://www.gnu.org/software/gcc/gcc.html.

Note that at this time, the kernel developers are not answering bug requests for earlier kernels, but instead are concentrating on developing 2.4.x version kernels and maintaining 2.2.x version kernels.
[J.H.M. Dassen, Axel Boldt]

Table of Contents 5

5.2 How To Install GNU Software

On a correctly configured system, installing a GNU software package requires four steps:

* With the source.tar.gz archive in the /usr/src/ directory, or wherever you maintain your source files, untar and decompress the package with the command:

    tar zxvf package-name.tar.gz

* Run the ./configure script in the untarred source archive's top-level directory with whatever command line arguments you need. The options that configure recognizes are usually contained in a file called INSTALL or README.

* Run make. This will build the source code into an executable program (or programs) and may take a few minutes or a few hours, depending on the speed of the computer and the size of the package.

* Run make install. This will install the compiled binaries, configuration files, and any libraries in the appropriate directories.

Table of Contents 5

5.3 Where To Get Java

The Sun Microsystems Java runtime environments and developer's kits are at http://java.sun.com/java/.

You can also get the source code, which is licensed by Sun Microsystems.

The home page of IBM's Jikes Java compiler is http://www10.software.ibm.com/developerworks/opensource/jikes.

There is a version of Sun's HotJava browser for Linux at: http://www.java.sun.com/products/hotjava/.

Kaffee, a free Java clone, is available from: http://www.kaffe.org/.

There is a resource page of free and commercial Java packages at: http://www.blackdown.org/java-linux.html.

Netscape Communicator comes with its own version of the Java Runtime Environment, so if you need Java only to view Web graphics, you may already have the runtime version of the Java Virtual Machine and libraries that you need installed on your system. You can download Communicator from http://www.netscape.com/.

Table of Contents 5

5.4 How To Port XXX to Linux

In general, *nix programs need very little porting. Simply follow the installation instructions. If you don't know--and don't know how to find out--the answers to some of the questions asked during the installation procedure, you can guess, but this tends to produce buggy programs. In this case, you're probably better off asking someone else to do the port. If you have a BSD-ish program, you should try using -I/usr/include/bsd and -lbsd on the appropriate parts of the compilation lines.

Table of Contents 5

5.5 What Is ld.so and How To Get It?

ld.so is the dynamic library loader. Each binary using shared libraries used to have about 3K of start-up code to find and load the shared libraries. Now that code has been put in a special shared library, /lib/ld.so, where all binaries can look for it, so that it wastes less disk space, and can be upgraded more easily. ld.so can be obtained from http://tsx-11.mit.edu/pub/linux/packages/GCC/ and mirror sites. The latest version at the time of writing is ld.so.1.9.5.tar.gz. /lib/ld-linux.so.1 is the same thing for ELF ("What's all this about ELF? ") and comes in the same package as the a.out loader.

Table of Contents 5

5.6 How To Upgrade the Libraries without Trashing the System

Warning

Note: You should always have a rescue disk set ready when you perform this procedure, in the likely event that something goes wrong!

This procedure is especially difficult if you're upgrading very old libraries like libc4. But you should be able to keep libc4 on the same system with libc5 libraries for the programs that still need them. The same holds true for upgrading from libc5 to the newer-yet glibc2 libraries.

The problem with upgrading dynamic libraries is that, the moment you remove the old libraries, the utilities that you need to upgrade to the new version of the libraries don't work. There are ways around around this. One is to temporarily place a spare copy of the run time libraries, which are in /lib/, in /usr/lib/, or /usr/local/lib/, or another directory that is listed in the /etc/ld.so.conf file.

For example, when upgrading libc5 libraries, the files in /lib/ might look something like:

libc.so.5
libc.so.5.4.33
libm.so.5
libm.so.5.0.9

These are the C libraries and the math libraries. Copy them to another directory that is listed in /etc/ld.so.conf, like /usr/lib/:

$ cp -df /lib/libc.so.5* /usr/lib/
$ cp -df /lib/libm.so.5* /usr/lib/
$ ldconfig

Be sure to run ldconfig to upgrade the library configuration.

The files libc.so.5 and libm.so.5 are symbolic links to the actual library files. When you upgrade, the new links will not be created if the old links are still there, unless you use the -f flag with cp. The -d flag to cp will copy the symbolic link itself, and not the file it points to.

If you need to overwrite the link to the library directly, use the -f flag with ln.

For example, to copy new libraries over the old ones, try this. Make a symbolic link to the new libraries first, then copy both the libraries and the links to /lib/, with the following commands:

$ ln -sf ./libm.so.5.0.48 libm.so.5
$ ln -sf ./libc.so.5.0.48 libc.so.5
$ cp -df libm.so.5* /lib
$ cp -df libc.so.5* /lib

Again, remember to run ldconfig after you copy the libraries.

If you are satisfied that everything is working correctly, you can remove the temporary copies of the old libraries from /usr/lib/ or wherever you copied them.

Table of Contents 5

5.7 How To Use Code or a Compiler Compiled for a 486 on a 386

Yes, unless it's the kernel.

The -m486 option to GCC, which is used to compile binaries for x486 machines, merely changes certain optimizations. This makes for slightly larger binaries that run somewhat faster on a 486. They still work fine on a 386, though, with a small performance hit.

However, from version 1.3.35 the kernel uses 486 or Pentium-specific instructions if configured for a 486 or Pentium, thus making it unusable on a 386.

GCC can be configured for a 386 or 486; the only difference is that configuring it for a 386 makes -m386 the default and configuring for a 486 makes -m486 the default. In either case, these can be overridden on a per-compilation basis or by editing /usr/lib/gcc-lib/i*-linux/ n.n.n/specs.

There is an alpha version of GCC that knows how to do optimization well for the 586, but it is quite unreliable, especially at high optimization settings. The Pentium GCC can be found on ftp://tsx-11.mit.edu/pub/linux/ALPHA/pentium-gcc/. The ordinary 486 GCC supposedly produces better code for the Pentium using the -m386, or at least slightly smaller.

Table of Contents 5

5.8 What Does "gcc -O6" Do?

Currently, the same as -O2 (GCC 2.5) or -O3 (GCC 2.6, 2.7). Any number greater than that does the same thing. The Makefiles of newer kernels use -O2, and you should probably do the same.

Table of Contents 5

5.9 Where Are linux/*.h and asm/*.h?

The files /usr/include/linux/ and /usr/include/asm/ are often soft links to the directories where the kernel headers are. They are usually under /usr/src/kernel*/.

If you don't have the kernel sources, download them. Refer to the answer: ("How To Upgrade/Recompile a Kernel.")

Then, use rm to remove any garbage, and ln to create the links:

$ rm -rf /usr/include/linux /usr/include/asm
$ ln -sf /usr/src/linux/include/linux /usr/include/linux
$ ln -sf /usr/src/linux/include/asm /usr/include/asm

/usr/src/linux/include/asm/ is a symbolic link to an architecture-specific asm directory. If you have a freshly unpacked kernel source tree, you must make symlinks. You'll also find that you may need to do `make config' in a newly-unpacked kernel source tree, to create linux/autoconf.h.

Table of Contents 5

5.10 What To Do about Errors Trying to Compile the Kernel

See the previous question regarding the header files.

Remember that when you apply a patch to the kernel, you must use the "-p0" or "-p1" option: otherwise, the patch may be misapplied. See the patch manual page for details.

"ld: unrecognized option `-qmagic'" means that you should get a newer linker, from ftp://tsx-11.mit.edu/pub/linux/packages/GCC/, in the file binutils-2.8.1.0.1.bin.tar.gz.

Table of Contents 5

5.11 How To Make a Shared Library

For ELF,

$ gcc -fPIC -c *.c
$ gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 *.o

For a.out, get tools-n.nn.tar.gz from tsx-11.mit.edu/pub/linux/packages/GCC/src/. It comes with documentation that will tell you what to do. Note that a.out shared libraries are a very tricky business. Consider upgrading your libraries to ELF shared libraries. See the ELF HOWTO, at ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/

Table of Contents 5

5.12 Programs Are Very Large

With an ELF compiler ("What's All This about ELF? glibc?"), the most common cause of large executables is the lack of an appropriate .so library link for one of the libraries you're using. There should be a link like libc.so for every library like libc.so.5.2.18.

With an a.out compiler the most common cause of large executables is the -g linker (compiler) flag. This produces (as well as debugging information in the output file) a program which is statically linked--one which includes a copy of the C library instead of a dynamically linked copy.

Other things worth investigating are -O and -O2, which enable optimization (check the GCC documentation), and -s (or the strip command) which strip the symbol information from the resulting binary (making debugging totally impossible).

You may wish to use -N on very small executables (less than 8K with the -N), but you shouldn't do this unless you understand its performance implications, and definitely never with daemons.

Table of Contents 5

5.13 Does Linux Support Threads or Lightweight Processes?

As well as the Unix multiprocessing model involving heavyweight processes, which is of course part of the standard Linux kernel, there are several implementations of lightweight processes or threads. Recent kernels implement a thread model, kthreads. In addition, there are the following packages available for Linux.

* GNU glibc2 for Linux has optional support for threads. The archive is available from the same place as glibc2, ftp://ftp.gnu.org/pub/gnu/

* In sipb.mit.edu:/pub/pthread/ or ftp.ibp.fr:/pub/unix/threads/pthreads. Documentation isn't in the package, but is available on the World Wide Web at http://www.mit.edu:8001/people/proven/home_page.html. Newer Linux libc's contain the pthreads source. The GNU Ada compiler on ftp://metalab.unc.edu/pub/Linux/devel/lang/ada/gnat-3.01-linux+elf .tar.gz contains binaries made from that source code.

* In ftp://ftp.cs.washington.edu:/pub/qt-001.tar.Z is QuickThreads. More information can be found in the technical report, available on the same site is /tr/1993/05/UW-CSE-93-05-06.PS.Z.

* In gummo.doc.ic.ac.uk/rex/ is lwp, a very minimal implementation.

* In ftp://ftp.cs.fsu.edu:/pub/PART/, an Ada implementation. This is useful mainly because it has a lot of Postscript papers that you'll find useful in learning more about threads. This is not directly usable under Linux.

Please contact the authors of the packages in question for details.

Table of Contents 5

5.14 Where To Find lint for Linux

Roughly equivalent functionality is built into GCC. Use the -Wall option to turn on most of the useful extra warnings. See the GCC manual for more details (type F1-i in Emacs and select the entry for GCC).

There is a freely available program called lclint that does much the same thing as traditional lint. The announcement and source code are available at on ftp://larch.lcs.mit.edu/pub/Larch/lclint/; on the World Wide Web, look at http://lclint.cs.virginia.edu/.

Table of Contents 5

5.15 Where To Find Kermit for Linux

Kermit is distributed under a non-GPL copyright that makes its terms of distribution somewhat different. The sources and some binaries are available on ftp://kermit.columbia.edu.

The WWW Home Page of the Columbia University Kermit project is http://www.columbia.edu/kermit/.

Table of Contents 5

5.16 How To Use Linux with a Cable Modem

The www.CablemodemInfo.com and xDSL Web page at http://www.cablemodeminfo.com/ has a section devoted to Linux.

Table of Contents 5

5.17 Is There an ICQ Program That Runs under Linux?

Several ICQ clients are available on metalab.unc.edu. (Refer to: "Where Are the Linux FTP Archives?") ICQ itself does not have a Linux client, but there is a Java client at http://www.mirabilis.com/download/.

Table of Contents 5
6. Solutions to Common Miscellaneous Problems

6.1. FTP Transfers Seem to Hang

FTP transfers that die suddenly are due, apparently, to some form of overrunning buffer. It occurs both with Linux and Microsoft servers. On Linux systems, The problem seems to occur most commonly with the distribution's server software.

If you receive ftp: connection refused errors, then the problem is likely due to a lack of authentication. Refer to "FTP or Telnet Server Won't Allow Logins.."

One remedy is to be replacing the distribution FTP server with the Linux port of the OpenBSD FTP server. The home page is: http://www.eleves.ens.fr:8080/home/madore/programs/

To install the BSD server, follow the installation instructions, and refer to the manual pages for inetd and inetd.conf. (If you have the newer xinetd, see below.) Be sure to tell inetd to run the BSD daemon alone, not as a subprocess of, for example, tcpd. Comment out the line that begins "ftp" in the /etc/inetd.conf file and replace it with a line similar to (if you install the new ftpd in /usr/local/sbin/):

# Original entry, commented out.
#ftp    stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/in.ftpd

# Replacement entry:
ftp     stream  tcp     nowait  root    /usr/local/sbin/ftpd -l

The replacement daemon will become effective after rebooting or
sending (as root) a SIGHUP to inetd, e.g.:

# kill -HUP inetd

To configure xinetd, create an entry in /etc/xinetd.d per the instructions in the xinetd.conf manual page. Make sure, again, that the command-line arguments for ftpd are correct, and that you have installed the /etc/ftpusers and /etc/pam.d/ftp files. Then restart xinetd with the command: /etc/rc.d/init.d/xinetd restart. The command should report "OK," and the restart will be noted in the system message log.

Table of Contents 6

6.2 Free Dumps Core

In Linux 1.3.57 and later, the format of /proc/meminfo was changed in a way that the implementation of free doesn't understand. Get the latest version, from metalab.unc.edu, in /pub/Linux/system/Status/ps/procps-0.99.tgz.

Table of Contents 6

6.3 Netscape Crashes Frequently

Netscape shouldn't crash, if it and the network are properly configured. Some things to check:

* Make sure that the MOZILLA_HOME environment variable is correctly set. If you installed Netscape under /usr/local/netscape/, for example, that should be the value of MOZILLA_HOME. Set it from the command line (e.g, "export MOZILLA_HOME="/usr/local/netscape"" under bash or add it to one your personal or system initialization files. Refer to the manual page for your shell for details.

* If you have a brand-new version of Netscape, try a previous version, in case the run-time libraries are slightly incompatible. For example, if Netscape version 4.75 is installed (type "netscape --version" at the shell prompt), try installing version 4.7. All versions are archived at ftp://ftp.netscape.com/.

* Netscape uses its own Motif and Java Runtime Environment libraries. If a separate version of either is installed on your system, ensure that they aren't interfering with Netscape's libraries; e.g., by un-installing them.

* Make sure that Netscape can connect to its default name servers. The program will appear to freeze and time out after several minutes if it can't. This indicates a problem with the system's Internet connection; likely, the system can't connect to other sites, either.

Table of Contents 6

6.4 FTP or Telnet Server Won't Allow Logins

This applies to server daemons that respond to clients, but don't allow logins. On new systems that have Pluggable Authentication Modules installed, look for a file named, "ftp," or "telnet," in the directory /etc/pam/ or /etc/pam.d/. If the corresponding authentication file doesn't exist, the instructions for configuring FTP and Telnet authentication and other PAM configuration, should be in /usr/doc/pam-. Refer also to the answer for "FTP server says: "421 service not available, remote server has closed connection."."

If it's an FTP server on an older system, make sure that the account exists in /etc/passwd, especially "anonymous."

This type of problem may also be caused a failure to resolve the host addresses properly, especially if using Reverse Address Resolution Protocol (RARP). The simple answer to this is to list all relevant host names and IP addresses in the /etc/hosts files on each machine. ( Refer to the example /etc/hosts and /etc/resolv.conf files in: "Sendmail Pauses for Up to a Minute at Each Command..") If the network has an internal DNS, make sure that each host can resolve network addresses using it.

If the host machine doesn't respond to FTP or Telnet clients at all, then the server daemon is not installed correctly, or at all. Refer to the manual pages: inetd and inetd.conf on older systems, or xinetd and xinetd.conf, as well as ftpd, and telnetd.

Table of Contents 6

6.5 How To Keep Track of Bookmarks in Netscape?

This probably applies to most other browsers, too. In the Preferences/Navigator menu, set your home page to Netscape's bookmarks.html file, which is located in the .netscape (with a leading period) subdirectory. For example, if your login name is "smith," set the home page to:

   file://home/smith/.netscape/bookmarks.html

Setting up your personal home page like this will present you with a nicely formatted (albeit possibly long) page of bookmarks when Netscape starts. And the file is automatically updated whenever you add, delete, or visit a bookmarked site.

Table of Contents 6

6.6 The Computer Has the Wrong Time

There are two clocks in your computer. The hardware (CMOS) clock runs even when the computer is turned off, and is used when the system starts up and by DOS (if you use DOS). The ordinary system time, shown and set by date, is maintained by the kernel while Linux is running.

You can display the CMOS clock time, or set either clock from the other, with /sbin/clock (now called hwclock in many distributions). Refer to: man 8 clock or man 8 hwclock.

There are various other programs that can correct either or both clocks for system drift or transfer time across the network. Some of them may already be installed on your system. Try looking for adjtimex (corrects for drift), Network Time Protocol clients like netdate, getdate, and xntp, or NTP client-server suite like chrony. Refer to: "How to Find a Particular Application.."

Table of Contents 6

6.7 Setuid Scripts Don't Seem to Work

That's right. This feature has been disabled in the Linux kernel on purpose, because setuid scripts are almost always a security hole. Sudo and SuidPerl can provide more security than setuid scripts or binaries, especially if execute permissions are limited to a certain user ID or group ID.

If you want to know why setuid scripts are a security hole, read the FAQ for comp.unix.questions.

Table of Contents 6

6.8 Free Memory as Reported by free Keeps Shrinking

The "free" figure printed by free doesn't include memory used as a disk buffer cache--shown in the "buffers" column. If you want to know how much memory is really free add the "buffers" amount to "free." Newer versions of free print an extra line with this info.

The disk buffer cache tends to grow soon after starting Linux up. As you load more programs and use more files, the contents get cached. It will stabilize after a while.

Table of Contents 6

6.9 When Adding More Memory, the System Slows to a Crawl

This is a common symptom of a failure to cache the additional memory. The exact problem depends on your motherboard.

Sometimes you have to enable caching of certain regions in your BIOS setup. Look in the CMOS setup and see if there is an option to cache the new memory area which is currently switched off. This is apparently most common on a '486.

Sometimes the RAM has to be in certain sockets to be cached.

Sometimes you have to set jumpers to enable caching.

Some motherboards don't cache all of the RAM if you have more RAM per amount of cache than the hardware expects. Usually a full 256K cache will solve this problem.

If in doubt, check the manual. If you still can't fix it because the documentation is inadequate, you might like to post a message to comp.os.linux.hardware giving all of the details--make, model number, date code, etc., so other Linux users can avoid it.

Table of Contents 6

6.10 Some Programs (E.g. xdm) Won't Allow Logins

You are probably using non-shadow password programs and are using shadow passwords.

If so, you have to get or compile a shadow password version of the programs in question. The shadow password suite can be found at ftp://tsx-11.mit.edu:/pub/linux/sources/usr.bin/shadow/. This is the source code. The binaries are probably in linux/binaries/usr.bin/.

Table of Contents 6

6.11 Some Programs Allow Logins with No Password

You probably have the same problem as in ("Some Programs (E.g. xdm) Won't Allow Logins."), with an added wrinkle.

If you are using shadow passwords, you should put a letter `x' or an asterisk in the password field of /etc/passwd for each account, so that if a program doesn't know about the shadow passwords it won't think it's a passwordless account and let anyone in.

Table of Contents 6

6.12 The Machine Runs Very Slowly with GCC / X / ...

You may have too little real memory. If you have less RAM than all the programs you're running at once, Linux will swap to your hard disk instead and thrash horribly. The solution in this case is to not run so many things at once or buy more memory. You can also reclaim some memory by compiling and using a kernel with less options configured. See ("How To Upgrade/Recompile a Kernel.")

You can tell how much memory and swap you're using with the free command, or by typing:

   $ cat /proc/meminfo

If your kernel is configured with a RAM disk, this is probably wasted space and will cause things to go slowly. Use LILO or rdev to tell the kernel not to allocate a RAM disk (see the LILO documentation or type "man rdev").

Table of Contents 6

6.13 System Only Allows Root Logins

You probably have some permission problems, or you have a file /etc/nologin.

In the latter case, put "rm -f /etc/nologin" in your /etc/rc.local or /etc/rc.d/* scripts.

Otherwise, check the permissions on your shell, and any file names that appear in error messages, and also the directories that contain these files, up to and including the root directory.

Table of Contents 6

6.14 The Screen Is All Full of Weird Characters Instead of Letters.

You probably sent some binary data to your screen by mistake. Type echo '\033c' to fix it. Many Linux distributions have a command, reset, that does this.

If that doesn't help, try a direct screen escape command.

   $ echo 'Ctrl-V Ctrl-O'

This resets the default font of a Linux console. Remember to hold down the Control key and type the letter, instead of, for example, Ctrl, then V. The sequence

   $ echo 'Ctrl-V Esc C'

causes a full screen reset. If there's data left on the shell command line after typing a binary file, press Ctrl-C a few times to restore the shell command line.

Another possible command is an alias, "sane," that can work with generic terminals:

   $ alias sane='echo -e "\\033c";tput is2; \
   > stty sane line 1 rows $LINES columns $COLUMNS'

The alias is enclosed with open quotes (backticks), not single quotes. The line break is included here for clarity, and is not required.

Make sure that $LINES and $COLUMNS are defined in the environment with a command similar to this in ~/.cshrc or ~/.bashrc,

   $ LINES=25; export $LINES; $COLUMNS=80; export $COLUMNS

using the correct numbers of $LINES and $COLUMNS for the terminal.

Finally, the output of "stty -g" can be used to create a shell script that will reset the terminal:

Save the output of "stty -g" to a file. In this example, the file is named "termset.":

   $ stty -g >termset

The output of "stty -g" (the contents of "termset") will look something like:

   500:5:bd:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:73

Edit "termset" to become a shell script; adding an interpreter and "stty" command:

   #!/bin/bash
   stty 500:5:bd:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:73

Add executable permissions to "termset" and use as a shell script:

   $ chmod +x termset
   $ ./termset

[Floyd L. Davidson, Bernhard Gabler]

Another way to accomplish normal characters again is to type:

   $ tput reset

and then, of course tap Return or Enter.
Note: You will have to tap your keyboard blindly.
[gwl]

Table of Contents 6

6.15 I Screwed Up the System and Can't Log In to Fix It

Reboot from an emergency floppy or floppy pair. For example, the Slackware boot and root disk pair in the install subdirectory of the Slackware distribution.

There are also two, do-it-yourself rescue disk creation packages in ftp://metalab.unc.edu/pub/Linux/system/recovery/. These are better because they have your own kernel on them, so you don't run the risk of missing devices and file systems.

Get to a shell prompt and mount your hard disk with something like

   $ mount -t ext2 /dev/hda1 /mnt

Then your file system is available under the directory /mnt and you can fix the problem. Remember to unmount your hard disk before rebooting (cd somewhere else first, or it will say it's busy).

Table of Contents 6

6.16 I Forgot the root Password

Note: Incorrectly editing any of the files in the /etc/ directory can severely screw up a system. Please keep a spare copy of any files in case you make a mistake.

If your Linux distribution permits, try booting into single-user mode by typing "single" at the BOOT lilo: prompt. With more recent distributions, you can boot into single-user mode when prompted by typing "linux 1," "linux single," or "init=/bin/bash."

If the above doesn't work for you, boot from the installation or rescue floppy, and switch to another virtual console with Alt-F1 -- Alt-F8, and then mount the root file system on /mnt. Then proceed with the steps below to determine if your system has standard or shadow passwords, and how to remove the password.

Using your favorite text editor, edit the root entry of the /etc/passwd file to remove the password, which is located between the first and second colons. Do this only if the password field does not contain an "x," in which case see below.

   root:Yhgew13xs:0:0: ...

Change that to:

   root::0:0: ...

If the password field contains an "x," then you must remove the password from the /etc/shadow file, which is in a similar format. Refer to the manual pages: "man passwd," and "man 5 shadow."
[Paul Colquhuon, Robert Kiesling, Tom Plunket]

Table of Contents 6

6.17 There's a Huge Security Hole in rm!

No there isn't. You are obviously new to unices and need to read a good book to find out how things work. Clue: the ability to delete files depends on permission to write in that directory.

Table of Contents 7

6.18 lpr and/or lpd Don't Work

First make sure that your /dev/lp* port is correctly configured. Its IRQ (if any) and port address need to match the settings on the printer card. You should be able to dump a file directly to the printer:

   $ cat the_file >/dev/lp1

If lpr gives you a message like myname@host: host not found" it may mean that the TCP/IP loopback interface, lo, isn't working properly. Loopback support is compiled into most distribution kernels. Check that the interface is configured with the ifconfig command. By Internet convention, the network number is 127.0.0.0, and the local host address is 127.0.0.1. If everything is configured correctly, you should be able to telnet to your own machine and get a login prompt.

Make sure that /etc/hosts.lpd contains the machine's host name.

If your machine has a network-aware lpd, like the one that comes with LPRng, make sure that /etc/lpd.perms is configured correctly. Also look at the Printing HOWTO. "Where can I get the HOWTO's and other documentation? ".

Table of Contents 6

6.19 Timestamps on Files on MS-DOS Partitions Are Set Incorrectly

There is a bug in the program clock (often found in /sbin). It miscounts a time zone offset, confusing seconds with minutes or something like that. Get a recent version.

Table of Contents 6

6.20 How To Get LILO to Boot the Kernel Image

>From kernel versions 1.1.80 on, the compressed kernel image, which is what LILO needs to find, is in arch/i386/boot/zImage, or arch/i386/boot/bzImage when it is built, and is normally stored in the /boot/ directory. The /etc/lilo.conf file should refer to the vmlinuz symbolic link, not the actual kernel image.

This was changed to make it easier to build kernel versions for several different processors from one source tree.

Table of Contents 6

6.21 How To Make Sure the System Boots after Re-Installing the Operating System

This should work whether you're re-installing Linux or some other, commercial, operating system:

* Insert a blank, formatted floppy in drive A:

* Save a copy of the boot hard drive's Master Boot Record to the floppy, by executing the command:

       #dd if=/dev/hda of=/dev/fd0 count=1

dd is a standard program on Linux systems. A MS-Windows compatible version is available from ftp://ftp.gnu.org/, as well as many MS software archives.

* Test that the floppy boots the system by rebooting with the floppy in the A: drive.

* Then you should be able to install the other operating system (on a different hard drive and/or partition, if you don't want to uninstall Linux).

* After installation, boot Linux again from the floppy, and re-install the MBR with the command: /sbin/lilo.

[Jacques Guy]

Table of Contents 6

6.22 The PCMCIA Card Doesn't Work after Upgrading the Kernel

The PCMCIA Card Services modules, which are located in /lib/modules/version/pcmcia, where version is the version number of the kernel, use configuration information that is specific to that kernel image only. The PCMCIA modules on your system will not work with a different kernel image. You need to upgrade the PCMCIA card modules when you upgrade the kernel.

When upgrading from older kernels, make sure that you have the most recent version of the run-time libraries, the modutils package, and so on. Refer to the file Documentation/Changes in the kernel source tree for details.

Important: If you use the PCMCIA Card Services, do not enable the Network device support/Pocket and portable adapters option of the kernel configuration menu, as this conflicts with the modules in Card Services.

Knowing the PCMCIA module dependencies of the old kernel is useful. You need to keep track of them. For example, if your PCMCIA card depends on the serial port character device being installed as a module for the old kernel, then you need to ensure that the serial module is available for the new kernel and PCMCIA modules as well.

The procedure described here is somewhat kludgey, but it is much easier than re-calculating module dependencies from scratch, and making sure the upgrade modules get loaded so that both the non-PCMCIA and PCMCIA are happy. Recent kernel releases contain a myriad of module options, too many to keep track of easily. These steps use the existing module dependencies as much as possible, instead of requiring you to calculate new ones.

However, this procedure does not take into account instances where module dependencies are incompatible from one kernel version to another. In these cases, you'll need to load the modules yourself with insmod, or adjust the module dependencies in the /etc/conf.modules file. The Documentation/modules.txt file in the kernel source tree contains a good description of how to use the kernel loadable modules and the module utilities like insmod, modprobe, and depmod. Modules.txt also contains a recommended procedure for determining which features to include in a resident kernel, and which to build as modules.

Essentially, you need to follow these steps when you install a new kernel.

* Before building the new kernel, make a record with the lsmod command of the module dependencies that your system currently uses. For example, part of the lsmod output might look like this:

	Module         Pages    Used by
	memory_cs          2            0
	ds                 2    [memory_cs]     3
	i82365             4            2
	pcmcia_core        8    [memory_cs ds i82365]   3
	sg                 1            0
	bsd_comp           1            0
	ppp                5    [bsd_comp]      0
	slhc               2    [ppp]   0
	serial             8            0
	psaux              1            0
	lp                 2            0

This tells you for example that the memory_cs module needs the ds and pcmcia_core modules loaded first. What it doesn't say is that, in order to avoid recalculating the module dependencies, you may also need to have the serial, lp, psaux, and other standard modules available to prevent errors when installing the pcmcia routines at boot time with insmod. A glance at the /etc/modules file will tell you what modules the system currently loads, and in what order. Save a copy of this file for future reference, until you have successfully installed the new kernel's modules. Also save the lsmod output to a file, for example, with the command: lsmod >lsmod.old-kernel.output.

* Build the new kernel, and install the boot image, either zImage or bzImage, to a floppy diskette. To do this, change to the arch/i386/boot directory (substitute the correct architecture directory if you don't have an Intel machine), and, with a floppy in the diskette drive, execute the command:

	$ dd if=bzImage of=/dev/fd0 bs=512

if you built the kernel with the make bzImage command, and if your floppy drive is /dev/fd0. This results in a bootable kernel image being written to the floppy, and allows you to try out the new kernel without replacing the existing one that LILO boots on the hard drive.

* Boot the new kernel from the floppy to make sure that it works.

* With the system running the new kernel, compile and install a current version of the PCMCIA Card Services package, available from metalab.unc.edu as well as other Linux archives. Before installing the Card Services utilities, change the names of /sbin/cardmgr and /sbin/cardctl to /sbin/cardmgr.old and /sbin/cardctl.old. The old versions of these utilities are not compatible with the replacement utilities that Card Services installs. In case something goes awry with the installation, the old utilities won't be overwritten, and you can revert to the older versions if necessary. When configuring Card Services with the "make config" command, make sure that the build scripts know where to locate the kernel configuration, either by using information from the running kernel, or telling the build process where the source tree of the new kernel is. The "make config" step should complete without errors. Installing the modules from the Card Services package places them in the directory /lib/modules/version/pcmcia, where version is the version number of the new kernel.

* Reboot the system, and note which, if any, of the PCMCIA devices work. Also make sure that the non-PCMCIA hardware devices are working. It's likely that some or all of them won't work. Use lsmod to determine which modules the kernel loaded at boot time, and compare it with the module listing that the old kernel loaded, which you saved from the first step of the procedure. (If you didn't save a listing of the lsmod output, go back and reboot the old kernel, and make the listing now.)

* When all modules are properly loaded, you can replace the old kernel image on the hard drive. This will most likely be the file pointed to by the /vmlinuz symlink. Remember to update the boot sector by running the lilo command after installing the new kernel image on the hard drive.

Also look at the questions, How do I upgrade/recompile my kernel? and Modprobe can't locate module, "XXX," and similar messages.

Table of Contents 6

6.23 How To Remove (or Change) the Colors in the ls Display

The shell command, "unalias ls," should completely unset the configuration that some distributions provide as standard. To change the colors, refer to the ls man page ("man ls").

Table of Contents 6

6.24 Why Won't a Program Work in the Current Directory?

Because the current directory (i.e., ".") is not in the search path, for security reasons, as well as to insure that the correct program versions are used. If an intruder is able to write a file to a world-writable directory, like /tmp, presumably he or she would be able to execute it if the directory were in the search path. The solution to this is to include the directory in the command; e.g., "./myprog," instead of "myprog." Or add the current directory to your PATH environment variable; e.g., "export PATH=".:"$PATH" using bash, although this is discouraged for the reasons mentioned above.

Table of Contents 6
7. How To Do This or Find Out That...

7.1. How To Find Out If a Notebook Runs Linux

There's no fixed answer to this question, because notebook hardware is constantly updated, and getting the X display, sound, PCMCIA, modem, and so forth, working, can take a good deal of effort.

Most notebooks currently on the market, for example, use "Winmodems," which often do not work with Linux because of their proprietary hardware interfaces. Even notebooks which are certified as "Linux compatible," may not be completely compatible.

Information about installing Winmodems in general is contained in the Winmodems-and-Linux HOWTO. (Refer to "Where Is the Documentation?")

You can find the most current information, or ask other users about their notebook experiences, on the linux-laptop mailing list, which is hosted by the vger.redhat.com server. (Refer to "What Mailing Lists Are There?")

A mailing list for Linux on IBM Thinkpads has its home page at http://www.topica.com/lists/linux-thinkpad/.

Another Thinkpad mailing list is hosted by http://www.bm-soft.com/. Send email with the word "help" in the body of the message to majordomo@www.bm-soft.com.

There is a Web page about Linux on IBM Thinkpads at http://peipa.essex.ac.uk/tp-linux/.

The Linux Laptop home page is at http://www.cs.utexas.edu/users/kharker/linux-laptop/.

For information about interfacing peripherals like Zip and CD-ROM drives through parallel ports, refer to the Linux Parallel Port Home Page, at http://www.torque.net/linux-pp.html.

If you need the latest version of the PCMCIA Card Services package, it is (or was) located at ftp://cb-iris.stanford.edu/pub/pcmcia/, but that host no longer seems to be available. Recent distributions are on ftp://metalab.unc.edu/pub/Linux/kernel/pcmcia/. You will also need to have the kernel source code installed as well. Be sure to read the PCMCIA-HOWTO, which is included in the distribution.

Table of Contents 7

7.2. Installing Linux Using FTP

Most distributions are too large and complex to make FTP installation practical. Installing a basic Linux system that doesn't have a GUI or major applications is possible with FTP, however. The main non-commercial distribution in use is Debian GNU/Linux, and this answer describes an installation of a basic Debian system, to which you can add other Linux applications and commercial software as necessary.

This answer describes installation on IBM-compatible machines with an Intel x86 or Pentium processor. You will need a machine with at least a 80386 processor, 8 Mb of memory, and about 100 Mb of disk space. More memory and a larger disk is necessary however, for practical everyday use.

For other hardware, substitute "-arm," "-ppc," "-m68k," or other abbreviation in directory names for "-i386."

For detailed and hardware-specific information refer to: http://www.debian.org/releases/stable/.

* Connect using anonymous FTP to ftp.debian.org and cd to the pub/debian/dists/stable/main/disks-i386/current/ subdirectory.

* Retrieve the binary image files for the rescue disk, and the drivers disk. Depending on the floppy drive installed on your machine, retrieve either the diskette images with "1200" in the names if you have a 1.2 Mb, 5.25-in. floppy, or the disks with "1440" in the name if the computer has a 3.25-in., 1.44 Mb floppy. Then retrieve the base system diskettes. Note that there are 7 base system images in the 1.44-Mb set (which have a "14" in their names) , and 9 in the 1.2-Mb set of images (which have a "12" in their names). You will use these to create the basic installation diskettes. If you have a Linux machine, you can use dd to write the images to the diskettes. If you are creating the installation diskettes on a MS-DOS machine, also download the RAWRITE.EXE MS-DOS utility, which will copy the raw binary images to floppy disks. Also download the install.en.txt document, which contains the detailed installation instructions.

* Create the installation disk set on floppies using either dd under Linux (e.g.: "dd if=resc1440.bin of=/dev/fd0"), or the RAWRITE.EXE utility under MS-DOS. Be sure to label each installation diskette.

* Insert the rescue diskette into the floppy drive and reboot the computer. If all goes well, the Linux kernel will boot, and you will be able start the installation program by pressing Enter at the boot: prompt.

* Follow the on-screen instructions for partitioning the hard disk, installing device drivers, the basic system software, and the Linux kernel. If the machine is connected to a local network, enter the network information when the system asks for it.

* To install additional software over the Internet, be sure that you have installed the ppp module during the installation process, and run (as root) the /usr/sbin/pppconfig utility. You will need to provide your user name with your ISP, your password, the ISP's dial-up phone number, the address(es) of the ISP's Domain Name Service, and the serial port that your modem is connected to, /dev/ttyS0-/dev/ttyS3. Be sure also to specify the defaultroute option to the PPP system, so the computer knows to use the PPP connection for remote Internet addresses.

* You may have to perform additional configuration on the PPP scripts in the /etc/ppp subdirectory, and in particular, the ISP-specific script in the /etc/ppp/peers subdirectory. There are basic instructions in each script. For detailed information, refer to the Debian/GNU Linux installation instructions that you downloaded, the pppd manual page (type man pppd), and the PPP HOWTO from the Linux Documentation project, http://www.linuxdoc.org/.

* Once you have a PPP connection established with your ISP (it will be displayed in the output of ifconfig), use the dselect program to specify which additional software you want to install. Use the apt [A]ccess option to retrieve packages via anonymous FTP, and make sure to use the [U]pdate option to retrieve a current list of packages from the FTP archive.

Table of Contents 7

7.3 Resuming an Interrupted Download

You can use the "reget" command of the standard ftp client program after reconnecting to pick up where you left off.

Clients like ncftp support resumed FTP downloads, and wget supports resumed FTP and HTTP downloads.

Table of Contents 7

7.4. Boot-Time Configuration

You can configure Linux at the lilo: prompt either by typing the kernel arguments at the BOOT lilo: prompt, or by adding an "append=" directive to the /etc/lilo.conf file; for example:

# At the LILO prompt (example only):
BOOT lilo: parport=0x3bc,7 parport=0x3bc,none serial=0x3f8,4 serial=0x2f8,3

# Example statement for /etc/lilo.conf:
append="parport=0x3bc,none serial=0x3f8,4 serial=0x2f8,3"

If you modify the /etc/lilo.conf file, be sure to run the lilo command to install the new configuration.

Configuration notes for specific hardware devices are in the documentation of the kernel source distribution, /usr/src/linux/Documentation in most distributions.

Refer to the lilo and /etc/lilo.conf manual pages, as well as the LDP BootPrompt-HowTo ("Where Is the Documentation?"), and the documentation in /usr/doc/lilo.

Table of Contents 7

7.5. Formatting Man Pages without man or groff

The man2html program translates groff text to HTML, which you can view with a Web browser. The man2html program, and many like it, are availble on the Web. Look for them with your favorite search engine.

The unformatted manual pages are stored in subdirectories of /usr/man, /usr/local/man, and elsewhere.

If you want to view text, use nroff and less. Both of these programs have MSDOS versions with an implementation of the man macro package available as well. An example would be:

$ nroff -man /usr/man/man1/ls.1 | less

If you know where to find a good implementation of the man macros without installing groff, please let the FAQ maintainer know.

If the manual page filename ends in ".gz," then you'll need to uncompress it before formatting it, using gzip -d or gunzip. A one-line example would be:

$ gzip -dc /usr/man/man1/ls.1.gz | nroff -man | less
Table of Contents 7

7.6. How To Scroll Backwards in Text Mode

With the default US keymap, you can use Shift with the PgUp and PgDn keys. (The gray ones, not the ones on the numeric keypad.) With other keymaps, look in /usr/lib/keytables. You can remap the ScrollUp and ScrollDown keys to be whatever you like.

The screen program, http://vector.co.jp/vpack/browse/person/an010455.html provides a searchable scrollback buffer and the ability to take "snapshots" of text-mode screens.

Recent kernels that have the VGA Console driver can use dramatically more memory for scrollback, provided that the video card can actually handle 64 kb of video memory. Add the line:

#define VGA_CAN_DO_64B

to the start of the file drivers/video/vgacon.c. This feature may become a standard setting in future kernels. If the video frame buffer is also enabled in the kernel, this setting may not affect buffering.

In older kernels, the amount of scrollback is fixed, because it is implemented using the video memory to store the scrollback text. You may be able to get more scrollback in each virtual console by reducing the total number of VC's. See linux/tty.h.
[Chris Karakas]

Table of Contents 7

7.7 How To Get Email to Work

For sending mail via SMTP (Simple Mail Transfer Protocol) and receiving mail from an ISP's POP (Post Office Protocol) server, you can use a desktop client like Netscape Communicator or KDE kmail. You will need to enter the names of the SMTP and POP servers in the preferences of the respective application, as well as your E-mail address (username@isp's-domain-name), and your dial-up password. The same applies to Usenet News. Enter the name of the NNTP (Network News Transfer Protocol) server in your News client's preferences section. You may also have to provide the IP addresses of the ISP's primary and secondary name servers.

If you have a traditional MTA (Mail Transport Agent) like Sendmail, Smail, qmail, or Exim, you'll need to follow the instructions in each package. Basically, configuration entails determining which host machine, either on your local LAN or via dial-up Internet, is the "Smart Host," if you're using SMTP. If you're using the older UUCP protocol, then you'll need to consult the directions for configuring UUCP, and also make sure that your ISP's system is configured to relay mail to you.

Information about Internet hosting, and News and E-mail in general, is available on the Usenet News group news.announce.newusers, and those FAQ's are also archived at ftp://rtfm.mit.edu/pub/usenet/.

Table of Contents 7

7.8 Sendmail Pauses for Up to a Minute at Each Command

Make sure that Sendmail can resolve your hostname to a valid (i.e., parsable) domain address. If you are not connected to the Internet, or have a dial-up connection with dynamic IP addressing, add the fully qualified domain name to the /etc/hosts file, in addition to the base host name; e.g., if the host name is "bilbo" and the domain is "bag-end.com:"

   192.168.0.1  bilbo.bag-end.com bilbo

And make sure that either the /etc/host.conf or /etc/resolv.conf file contains the line:

   order hosts,bind

Caution: Do not change the "localhost" entry in /etc/hosts, because many programs depend on it for internal message-passing.

Sendmail takes many factors into account when resolving domain addresses. These factors, collectively, are known as, "rulesets," in sendmail jargon. The program does not require that a domain address be canonical, or even appear to be canonical. In the example above, "bilbo." (note the period) would work just as well as "bilbo.bag-end.com." This and other modifications apply mainly to recent versions.

Prior to version 8.7, sendmail required that the FQDN appear first in the /etc/hosts entry. This is due to changes in the envelope address masquerade options. Consult the sendmail documents.

If you have a domain name server for only a local subnet, make sure that "." refers to a SOA record on the server machine, and that reverse lookups (check by using nslookup) work for all machines on the subnet.

Finally, FEATURE configuration macro options like nodns, always_add_domain, and nocanonify, control how sendmail interprets host names.

The document, Sendmail: Installation and Operation Guide, included in the doc/ subdirectory of Sendmail source code distributions, discusses briefly how Sendmail resolves Internet addresses. Sendmail source code archives are listed at: http://www.sendmail.org/
[Chris Karakas]

Table of Contents 7

7.9 How To Enable and Select Virtual Consoles

In text mode, press the left Alt-F1 to Alt-F12 to select the consoles tty1 to tty12; Right Alt-F1 gives tty13 and so on. To switch out of X you must press Ctrl-Alt-F1, etc; Alt-F5 or whatever will switch back.

However, If you have a non-PC compatible system, please see the note below.

If you want to use a VC for ordinary login, it must be listed in /etc/inittab, which controls which terminals and virtual consoles have login prompts. The X Window System needs at least one free VC in order to start.

[Note: The key sequence is actually Ctrl--Meta-- FN. On PC compatible systems, the right and left Alt keys are really synonymous with the keysymbols Meta_L and Meta_R. If the binding is different, you can determine what keys produce Meta_L and Meta_R with xkeycaps or a similar application.]
[David Charlap]

Table of Contents 7

7.10 How To Set the Time Zone

Change directory to /usr/lib/zoneinfo/. Get the time zone package if you don't have this directory. The source is available in ftp://metalab.unc.edu/pub/Linux/system/admin/time/.

Then make a symbolic link named localtime pointing to one of the files in this directory (or a subdirectory), and one called posixrules pointing to localtime. For example:

$ ln -sf US/Mountain localtime
$ ln -sf localtime posixrules

This change will take effect immediately--try date.

If the system uses Red Hat-style configuration files, the respective time zone info files are /usr/share/zoneinfo and /etc/localtime.

The manual pages for tzset or tzselect describe setting the time zone. Some programs recognize the "TZ" environment variable, but this is not POSIX-correct.

You should also make sure that your Linux kernel clock is set to the correct GMT time. Type date -u and check that the correct UTC time is displayed. ("The Computer Has the Wrong Time.")

Table of Contents 7

7.11 Dial-up PPP Configuration

This information is mainly for people who do not have a wrapper utility like kppp or pppconfig, or are not able to get those utilities to work correctly. If you need to manually configure PPP to dial in to your ISP, you will need the following information:

* The port that your modem is connected to: /dev/ttyS0-/dev/ttyS3, which correspond to COM1-COM4 under MS-DOS.

* The phone number of your ISP's data connection.

* The user name and password that your ISP gave you.

* The IP addresses of the primary and possibly secondary Domain Name Service that you will use when dialing in to the ISP. This assumes that you will not be using a DNS that you installed on your system.

When you have all of this information, make sure that the programs pppd and chat, at the very minimum, are installed correctly. In most current distributions, they are installed in the /usr/sbin/ directory, and you will need to be logged in as root to use them. In addition, the following programs are also useful for configuring network connections, determining network status, and diagnosing problems: /sbin/ifconfig, /sbin/route, /bin/ping, /usr/sbin/traceroute.

These are the basic steps that you need to follow to configure PPP. You must be logged in as root.

* Make sure that the serial port and modem are operating correctly. Using a program like minicomm or kermit, you should be able to send AT commands to the modem and receive the OK string in response from the modem.

* Enter the primary and possibly secondary Domain Name Server IP addresses in the /etc/resolv.conf file, using dotted quad notation, with the nameserver label. For example:

	order hosts,bind
	nameserver 196.182.101.103
	nameserver 196.182.101.104

The nameserver addresses in the example above are examples only. They don't correspond to actual network hosts. The first line, order hosts,bind, tells your networking software, when it resolves network domain addresses, to first look in the /etc/hosts file, and then use the bind service; i.e., the DNS servers, which are specified on the lines that begin with nameserver.

* Locate the chat script that PPP will use to dial the modem and connect to your ISP. In many systems, this is either in the /etc/chatscripts or /etc/ppp directory, and will be called provider or something similar. You can store a chat script anywhere, provided that you tell pppd to use it rather than the default script. Refer to the chat and pppd manual pages, and the information below, for details. Here is a sample chat script:

	ABORT        BUSY
	ABORT        "NO CARRIER"
	ABORT        VOICE
	ABORT        "NO DIALTONE"
	""           ATDT
	ogin         
	word         

This is a chat program for a simple, script based login. The chat program uses the pair of strings on each line as a match/response pair. When it starts, it sends the string "ATDTyour_isp's_phone_number," where you have substituted the actual phone number of course. It then waits for the string ogin (a substring of the word login) and sends your user name. It then waits for word (a substring of password) and sends your password. If your ISP uses a different login and password prompts, and any additional prompts, you will need to edit the script accordingly. Again, refer to the chat manual page for details. If your ISP uses PAP or CHAP authentication, you will need to edit the pap-secrets or chap-secrets files in /etc/ppp directory as well. Refer to the manual pages for these files, as well as the instruction in the files themselves.

* The configuration of pppd, the program that maintains the actual connection, is usually contained in two or three separate files. The first is usually /etc/ppp/options, which contains options that all of your system's PPP connections will use. (Yes, you can have more than one; as many as your computer has serial ports, generally.) Here is a sample /etc/ppp/options file:

	# /etc/ppp/options

	asyncmap 0
	auth
	crtscts
	lock
	noipx

	# ------

The options may be given on one line or each on a separate line. Many options files are much longer, and come with a description of each option. Here, the options mean, in order, don't remap any characters between the PPP client and server; always use password, PAP, or CHAP authentication when making a connection; use the modem's hardware handshake lines for flow control; lock the serial port when in use so no other programs can access it; and do not use the IPX network protocol.

* For connection set-up on each individual serial port or PPP host, there will either be an /etc/ppp/options.ttyS1, for example, options file for /etc/ttyS1, or a file for your ISP in the /etc/ppp/peers directory. The default is often called /etc/ppp/peers/provider. Here is a sample of the default provider file:

	noauth
	connect "/usr/sbin/chat -v -f /etc/chatscripts/provider"
	defaultroute
	/dev/ttyS1
	38400
	persist

There might be an explanation of these and other options in the /etc/ppp/peers/provider file itself. You can also refer to the pppd manual page for details. Briefly, they mean: do not use PAP authentication for this connection; use the chat program and the /etc/chatscripts/provider script, which is described above, to dial the phone and log in; set the network default route to the PPP connection (so when your network software needs to resolve an network address that is not on your local machine(s), it will use the PPP connection to the Internet); use /dev/ttyS1 as the serial port for the connection; set the modem speed to 38400; and keep the pppd daemon running even if the connection fails.

* That is all of the configuration you need. To actually start and stop PPP, there are often /usr/bin/pon and /usr/bin/poff scripts (in Debian), or something similar, and they are usually very simple, and only contain the command:

	$ /usr/sbin/pppd call ${1:-provider}

This will start pppd and use the call option to call the server that you type on the command line, or the provider given in the /etc/ppp/peers/provider file if you do not specify a remote server. After making the call and logging in (about 30 seconds), you should be able to use the /sbin/ifconfig program to determine that the connection really did establish a PPP interface (the first will be ppp0, the second will be ppp1, etc., depending on how many simultaneous PPP connections you have. If something goes wrong, you can look at the /var/log/ppp.log file to determine what happened. You can also view the log as the connection is being made, by "tailing" it in another window; that is, viewing it as pppd logs the connection's status information. To do this, use the command (again, as root):

	$ tail -f /var/log/ppp.log

On some systems the PPP output is directed to /var/log/messages, in which case your system may not have a dedicated PPP log file.

You should be also able to ping one of your ISP's domain names (e.g., mail.isp.com) and receive a response.

These are the most basic steps for configuring a PPP connection. You will also need to take into account what other network connections may be present (for example, if there's an Ethernet connection that has already been assigned the default route), as well as various security measures at your ISP's end. If you're having trouble making the dial-up connection, usually the best way to determine what may be going wrong is to use Seyon, minicomm, kermit, or some other program to dial and log in manually to the ISP, and determine just exactly what you have to do to log in, then duplicate that in the PPP scripts.

Most Linux documentation also has additional instructions for configuring PPP connections. Refer to ("Where Are the Linux FTP Archives?") ("Where Is the Documentation?")

Table of Contents 7

7.12 What Version of Linux and What Machine Name Is This?

Type:

   $ uname -a
Table of Contents 7

7.13 What Is a "core" File?

A core file is created when a program terminates unexpectedly, due to a bug, or a violation of the operating system's or hardware's protection mechanisms. The operating system kills the program and creates a core file that programmers can use to figure out what went wrong. It contains a detailed description of the state that the program was in when it died.

If would like to determine what program a core file came from, use the file command, like this:

   $ file core

That will tell you the name of the program that produced the core dump. You may want to write the maintainer(s) of the program, telling them that their program dumped core.
[Eric Hanchrow]

Table of Contents 7

7.14 How To Enable or Disable Core Dumps

By using the ulimit command in bash, the limit command in tcsh, or the rlimit command in ksh. See the appropriate manual page for details.

This setting affects all programs run from the shell (directly or indirectly), not the whole system.

If you wish to enable or disable core dumping for all processes by default, you can change the default setting in linux/sched.h. Refer to definition of INIT_TASK, and look also in linux/resource.h.

PAM support optimizes the system's environment, including the amount of memory a user is allowed. In some distributions this parameter is configurable in the /etc/security/limits.conf file. For more information, refer to the Linux Administrator's Security Guide. ("Where Is the Documentation?")

Table of Contents 7

7.15 How To Upgrade/Recompile a Kernel

See the Kernel HOWTO or the README files which come with the kernel release on ftp.cs.helsinki.fi/pub/Software/Linux/Kernel/ and mirrors. (See "Where Are the Linux FTP Archives?") You may already have a version of the kernel source code installed on your system, but if it is part of a standard distribution it is likely to be somewhat out of date (this is not a problem if you only want a custom configured kernel, but it probably is if you need to upgrade.)

With newer kernels you can (and should) make all of the following targets. Don't forget that you can specify multiple targets with one command.

   $ make clean dep install modules modules_install

Also remember to update the module dependencies.

   $ depmod -a

This command can be run automatically at boot time. On Debian/GNU Linux systems, the command is part of the /etc/init.d/modutils script, and can be linked appropriately in the /etc/rcx.d/ directories. For more information on depmod, see the manual page.

Make sure you are using the most recent version of the modutils utilities, as well as all other supporting packages. Refer to the file Documentation/Changes in the kernel source tree for specifics, and be sure to consult the README file in the modutils package.

Remember that to make the new kernel boot you must run lilo after copying the kernel into your root partition. The Makefile in some kernels have a special zlilo target for this; try:

   $ make zlilo

On current systems, however, you can simply copy the zImage or bzImage file (in arch/i386/boot/ to the /boot/ directory on the root file system, or to a floppy using the dd command. Refer also to the question, How do I get LILO to boot the kernel image?

Kernel version numbers with an odd minor version (ie, 1.1.x, 1.3.x) are the testing releases; stable production kernels have even minor versions (1.0.x, 1.2.x). If you want to try the testing kernels you should probably subscribe to the linux-kernel mailing list. ("What Mailing Lists Are There?")

The Web site http://www.kernelnotes.org/ has lots of information and links to other sites that provide information about Linux kernel updates.

Also refer to the questions, "The PCMCIA Card Doesn't Work after Upgrading the Kernel." and "How To Get LILO to Boot the Kernel Image."

Table of Contents 7

7.16 Can Linux Use More than 3 Serial Ports by Sharing Interrupts?

Yes, but you won't be able to use simultaneously two ordinary ports which share an interrupt (without some trickery). This is a limitation of the ISA Bus architecture.

See the Serial HOWTO for information about possible solutions and workarounds for this problem.

Table of Contents 7

7.17 Configuring Emacs's Default Settings

Create a file in your home directory named .emacs with the Emacs Lisp commands that you want to run every time Emacs starts up. You won't see the file in the directory listing. (The leading '.' tells ls not to display it, unless you use the -a command line switch with ls.)

Any kind of Emacs Lisp statement will work in the .emacs file, including entire defuns. Emacs uses lisp variables and statements extensively, and many of the editing functions are written in Emacs Lisp. For example, to enable word wrapping whenever you edit a file that ends with .txt, add the following statement. This is from the Emacs Texinfo help document ( F1-i, then m Emacs Return):

(add-hook text-mode-hook
     '(lambda () (auto-fill-mode 1)))

This adds a statement that calls a hook function whenever a text editing mode is entered for that buffer. The value of text-mode-hook, which is a variable, to auto-fill-mode, which is a function.

If you want to turn off the menu bar at the top of each Emacs frame, add this statement:

(menu-bar-mode -1)

And if you want to include an Emacs Lisp program that someone has written, like msb.el (an enhanced, pop-up buffer menu), make sure the lisp file is in a directory where Emacs can find it (usually it will be named Site-lisp), and add these statements in the .emacs file:

(require 'msb)
(msb-mode 1)

Most tasks have several possible solutions in Emacs Lisp. Any task that can be programmed in Emacs Lisp is valid in the .emacs file. For more information, consult the Texinfo documentation. There is also a FAQ list for Emacs (refer to: What other FAQ's are there for Linux? ).

Table of Contents 7

7.18 How To Make a Rescue Floppy

Make a file system on it with bin, etc, lib and dev directories--everything you need. Install a kernel on it and arrange to have LILO boot it from the floppy (see the LILO documentation, in lilo.u.*.ps).

If you build the kernel (or tell LILO to tell the kernel) to have a RAM disk the same size as the floppy the RAM disk will be loaded at boot time and mounted as root in place of the floppy.

See the Bootdisk HOWTO.

Table of Contents 7

7.19 How To Remap a Keyboard to UK, French, Etc.?

For recent kernels, get /pub/Linux/system/Keyboards/kbd-0.90.tar.gz from ftp://metalab.unc.edu/. Make sure you get the appropriate version; you have to use the right keyboard mapping package for your kernel version. For older kernels you have to edit the top-level kernel Makefile, in /usr/src/linux/. You may find more helpful information in The Linux Keyboard and Console HOWTO, by Andries Brouwer, at ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/.

Table of Contents 7

7.20 How To Get NUM LOCK to Default to On

Use the setleds program, for example (in /etc/rc.local or one of the /etc/rc.d/* files):

for t in 1 2 3 4 5 6 7 8
do
 setleds +num < /dev/tty$t > /dev/null
done

setleds is part of the kbd package ("How do I remap my keyboard to UK, French, etc.? "). Alternatively, patch your kernel. You need to arrange for KBD_DEFLEDS to be defined to (1 << VC_NUMLOCK) when compiling drivers/char/keyboard.c.

Table of Contents 7

7.21 How To Set (Or Reset) Initial Terminal Colors

The following shell script should work for VGA consoles:

for n in 1 2 4 5 6 7 8; do
  setterm -fore yellow -bold on -back blue -store > /dev/tty$n
  done

Substitute your favorite colors, and use /dev/ttyS$n for serial terminals.

To make sure they are reset when people log out (if they've been changed):

Replace the references to getty (or mingetty or uugetty or whatever) in /etc/inittab with references to /sbin/mygetty.

#!/bin/sh
setterm -fore yellow -bold on -back blue -store > $1
exec /sbin/mingetty $@

[Jim Dennis]

Table of Contents 7

7.22 How To Have More Than 128Mb of Swap

Use several swap partitions or swap files. Linux kernels before version 2.2 supported up to 16 swap areas, each of up to 128Mb. Recent versions do not have this limitation.

Very old kernels only supported swap partition sizes up to 16Mb.

Linux on machines with 8KB paging, like Alpha and Sparc64, support a swap partition up to 512MB. The 128MB limitation comes from PAGE_SIZE*BITSPERBYTE on machines with 4KB paging, but is 512KB on machines with 8KB paging. The limit is due to the use of a single page allocation map.

The file mm/swapfile.c has all of the gory details.
[Peter Moulder, Gordon Weast]

Table of Contents 7

7.23 How To Prevent Errors when Linking Programs with Math Functions

Older run-time libraries included the math library in the C run-time library, so it was not necessary to specify the math library separately. If the compiler generates a message like this when linking a program that uses math functions:

/tmp/ccDUQM4J.o: In function `main':
/tmp/ccDUQM4J.o(.text+0x19): undefined reference to `sqrt'
collect2: ld returned 1 exit status

You need use the -lm option with GCC to link with the math libraries:

   # gcc -o program program.c -lm

Make sure also to use the statement #include in the source file.
[Florian Schmidt]

Table of Contents 7