FTP access restrictions

When you first install Linux, it comes with a lot of Internet services running, including mail, telnet, finger and FTP. You really should disable all those that you don't need from /etc/inetd.conf and your startup scripts.

FTP may be very useful, but must be configured correctly. It can allow people to log into their accounts, it can allow anonymous users to login to a public software directory, and it can display nice messages to them. The files that you will probably want to modify are /etc/ftpusers and /etc/ftpaccess.

The file /etc/ftpusers is very simple. It lists the people that will not be allowed to use FTP to your system. The root account, and other system accounts should be in that file.

The file /etc/ftpaccess is a bit more complex and controls the behaviour of the FTP server. It tells it what to use as README file to display on a directory listing, what kind of logs to create and what messages to display.

Note that if you create an anonymous FTP area, you will need to read the FTP man page and do exactly what it tells you to avoid possible security risks.

Making CD-ROM images

With other operating systems, such as Microsoft Windows or IBM OS/2, you are not allowed in the license to make your own CD-ROM with the OS on it and then distribute it.

Linux, being Open Source and free, can be copied. You can download a distribution or buy it from an online store and burn your own copy, and then install it on many computers, or give it to your friends. Usually, you will find instructions on how to do that on the FTP server for your favorite distribution. You will need the main directory on the CD-ROM. The sources are not needed since they are available from the FTP site.

Some distributions also come with ISO images of their CD-ROM. This is a single file that can be put onto a CD-ROM, and will create a full file system with files on it.

One thing you have to be careful is not to copy commercial programs. The basic CD-ROM where the Linux distribution is located is composed of free software. But some distributions may come with other commercial programs, and you should read the license first.

LILO and boot problems

When a computer starts, the number of beeps the BIOS outputs tells you the state of the computer. On some computers, one beep means all is ok, but 2 beeps mean there is an error. LILO uses the same kind of codes. The number of letters you see from the word LILO on the screen says what is wrong. The whole word means everything is fine, only LI means only the first part of LILO could be loaded. A full description of this is available from the Bootdisk HOWTO.

When LILO can't load, it's a major problem. This often means that the boot code was corrupted. The only way to boot is from a floppy disk. In RedHat, you can use the rescue disk, in Slackware, you can use the boot disk with the "mount" image.

When LILO is fine, it's often easier to figure a boot problem. If the kernel panics when it tries to boot, it is usualy due to a configuration error. You can tell LILO to mount another kernel you may have, like a "safe" or "old" image you kept for these cases. If the problem is in initialization scripts, you can tell LILO to boot directly into a shell with the following boot command line:

LILO boot: linux init=/bin/sh

Where "linux" would be your kernel image.

Bytes per inodes

When you format a partition using Linux's primary file system, ext2, you have the choice of how many bytes per inode you want. From the man page:

-i bytes-per-inode

Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. This value defaults to 4096 bytes. bytes-per-inode must be at least 1024.

This means that by using a smaller size, you will save disk space but may slow down the system. It is a space/speed trade off.

This is similar to one of FAT16/FAT32' major differences.

More information from usenet

There are newsgroups about everything. Newsgroups on the latest TV show, on gardening, and more. There also are newsgroups on Linux. In fact, the best help can be obtained from newsgroups. But which ones?

Here is a list of a few newsgroups dedicated to Linux, and what they are used for:

  • comp.os.linux.advocacy: This newsgroup is used for advocacy. People stating their opinions about Linux or Linux applications, and about Linux competitors. Some post facts, some will flame other people.

  • comp.os.linux.setup: This is a general purpose setup help group. Users will post questions and get answers there.

  • linux.*: There now is a linux section on usenet. Currently there are more than 150 groups in linux.* and they are all about Linux!

Make sure you read the FAQ and rules of every newsgroup you want to post to.

Default boot mode

When a Linux system boots, it loads the kernel, all its drivers, and the networking servers, then the system will display a text login prompt. There, users can enter their user names and their passwords. But it doesn't have to boot this way.

There are 3 modes defined in most Linux distributions that can be used for booting. They are defined in /etc/inittab and have specific numbers. The first mode, also called runlevel 1, is single user mode. That mode will only boot the system for 1 user, with no networking. Runlevel 3 is the default mode. It will load the networking servers and display a text login prompt. Runlevel 5 is the graphical mode. If you have X Window installed and configured, you can use it to display a graphical login prompt.

The way to change this is to edit /etc/inittab and change the initdefault line:

id:3:initdefault:

Changing a 3 to a 5 will make the system display a xdm graphical screen on bootup.

Default file permissions

When you create a file, the system gives it default permissions. On most systems the permissions are 755 (read, write and execute for the owner, and read and execute for others).

This default is setup with the umask command. To use the command, you need to find the right octal number to give it. The permissions in the umask are turned off from 666. This means that a umask of 022 will give you the default of 755. To change your default permissions from 755 to 700, you would use this command:

umask 077

Multiple kernels choices

When you compile a new kernel, you will often change your configuration. This means you may forget to include an important driver, like the IDE driver, or otherwise make your system unbootable. The solution is to always keep your old kernel.

When you compile your kernel, the compilation procedure will often copy your old kernel into vmlinuz.old. If it does not, you can do it manually. What you should do is add an entry to /etc/lilo.conf allowing you to boot your old kernel. You should view the lilo man page for the complete syntax. You could also add entries for different kernels, for example if you want to have an older stable version of the kernel and the newest development version on your system.

Note that some distributions name their kernel with the version they represent. For example, your current

kernel may be /boot/vmlinuz-2.0.36-0.7

International console

Most Linux distributions are configured to use a US english keyboard. If you need to write on a french or any other kind of keyboard, you will want to change the locale so special keys like accents appear in the console.

The way to do this is to change the system locale with a program called loadkeys. For example, to enable a canadian-french locale, you need to add this line in your startup files:

loadkeys cf

Here cf means the canadian-french keyboard. Other locales are us, fr and more.

Annoying boot messages

When recompiling your kernel, you might end up seeing strange messages on bootup like:

modprobe: cannot find net-pf-5

modprobe: cannot find char-major-14

These are messages from the modules loader telling you that he can't find specific modules. This usualy happens when you compile modules, but modprobe tries to load modules that were not compiled and it can't find them. The way to remove those messages is to set the modules to off. In the file /etc/conf.modules you may want to add:

alias net-pf-5 off

alias char-major-14 off

This will stop modprobe from trying to load them. Of course you could also try to resove the problem by compiling the modules and make sure modprobe knows where they are.

Linux and NT booting

Some people choose to have both Windows NT and Linux on the same system. Windows NT has its own boot loader called NTLDR and Linux has LILO. Which should go on the MBR?

The safest way is to install Windows NT first, and give it the MBR. Then, when you install Linux, tell LILO to install on the Linux partition. Also set the Linux partition as the active partition. When the system boots, LILO will be loaded, and if you want to boot Windows NT, then LILO can load the MBR with NTLDR in it. There is a mini HOWTO text covering this subject available at

http://metalab.unc.edu/pub/Linux/docs/HOWTO.

Allowing users to run root programs

When a user starts a command, it runs with the permissions of that user. What if you want to allow them to run some commands with root permissions? You can, and that's called suid.

You can set a command to be suid root with the chmod command. This will make it run as root even if a user starts it. Here is how to set mybin suid root:

chmod +s mybin

Note that you must be very careful with this option. If the command has any security hole, or allows the user to access other files or programs, the user could take over the root account and the whole system.

Allowing users to mount drives

By default, Linux will not allow users to mount drives. Only root can do it, and making the mount binary suid root is not a good idea. With a special command in the /etc/fstab file, you can change that.

This is a typical line for the fd0 (A:) drive in /etc/fstab:

/dev/fd0     /mnt     auto     noauto,user 1 1

The keywords here are noauto and user. Noauto tells mount not the try to mount a diskette on boot, and user allows any user to mount the drive into /mnt. The auto keyword is also interesting. It tells mount to try to find out which file system is on the diskette. You could also use msdos or ext2.

X Window configuration options

Each Linux distribution has its own X Window configuration program. XFree86 also has a text-based configuration program which is complex to use. But what if both the distribution program and xf86config, the text-based configuration for XFree86, do not seem to do what you need? XFree86 also comes with a graphical configuration tool.

The name of the graphical program is XF86Setup. This will launch a graphical window and allow you to configure the X Window Server.

LILO can't find a kernel on a big drive

On some big hard drives, LILO can have problems loading your kernel. The problem is because the hard drive has more then 1024 cylinders.

The trick is to make sure your kernel is in the first 1024 cylinders so LILO can find it. The way to do this is to make a small /boot partition at the begining of the drive, and make sure the kernel is in the /boot directory.

You can set the partitions in fdisk, and select the right path for the kernel in /etc/lilo.conf so LILO knows where it is. When you compile your kernel, simply move the new kernel in that directory so LILO can load it.

Master boot record and LILO

What is the master boot record (MBR) and why does LILO erase the old boot loader? Every hard drive has a top space called the MBR where the BIOS will try to load an operating system. Every system has its own loader. DOS has DOS-MBR, Windows NT has the NTLDR and Linux has LILO.

When you install LILO, you can install it in the MBR or in a boot record for the Linux partition. If you want to keep your current boot loader, you can select the Linux partition, and make sure it is the active partition in fdisk. This way you will be able to boot to LILO, and then boot the old loader from the MBR.

If you plan on only using Linux on your system, you can tell LILO to boot right into Linux and not display a "boot:" prompt, and you can install it in the MBR.

Wrong memory size found

The Linux kernel will detect various settings from your computer configuration. This includes the size of memory you have. In some cases, it will find the wrong size. For example, it could find only 64 megs of memory when in fact you have 128 megs.

The trick here is to specify the amount of RAM memory you have with the "mem=" parameter. Here is what you would type when your system boots if you have 128 megs of memory:

LILO boot: linux mem=128M

This will tell LILO to load the linux kernel with 128 megs of memory.

The boot prompt

The Linux system uses a program called LILO to boot itself. This is the LInux LOader, and will load a kernel and can pass various parameters. This is what the "boot:" prompt is for.

At the "boot:" prompt, you can enter a lot of parameters. You can send parameters to drivers like the ethernet driver, telling it at which IRQ the ethernet card is located, or you can pass parameters to the kernel, like memory size or what to do in a panic. Reading the LILO manual will tell you all of the nice things LILO can be used for.

Note that for device drivers compiled as modules, you need to pass values when you load these drivers, and not on the "boot:" prompt.

Kernel size and modules

To configure Linux to detect a new hardware part, especially on a new kernel, you may need to recompile the kernel. If you add too many devices in the kernel configuration, you may get an error message telling you that the kernel is too big. The trick is to enable modules.

The kernel itself must be a certain size because it needs to be loaded in a fixed memory size. This is one reason why modules can be very handy. If you enable modules, you will need to make them:

make modules

and install them:

make modules_install

Then using the modprobe utility you can load selected modules on bootup. This way the kernel will be smaller and will compile with no error.

More swap with a swap file

You installed a new Linux system, but forgot to set enough swap space for your needs. Do you need to repartition and reinstall? No, the swap utilities on Linux allow you to make a real file and use it as swap space.

The trick is to make a file and then tell the swapon program to use it. Here's how to create, for example, a 64 megs swap file on your root partition (of course make sure you have at least 64 megs free):

dd if=/dev/zero of=/swapfile bs=1024 count=65536

This will make a 64 megs (about 67 millions bytes) file on your hard drive. You now need to initialize it:

mkswap /swapfile 65536

sync

And you can then add it to your swap pool:

swapon /swapfile

With that you have 64 megs of swap added. Don't forget to add the swapon command to your startup files so the command will be repeated at each reboot.

Swap and memory

One important setting in any protected mode operating system like Linux is the swap space. In the installation, you will need to create a swap partition. A common question is what size should the partition be?

The proper size depends on 2 things: The size of your hard drive and the size of your RAM memory. The less RAM you have, the more swap you will need. Usually you will want to set your swap space size to be twice the RAM size, with a maximum of 128 megs. This of course requires you to have a hard drive with enough free space to create such a partition.

If you have 16 megs of RAM, making the swap space 32 megs or even 64 megs is very important. You will need it. If you have 128 megs of RAM on the other hand, you won't need much swap because the system will already have 128 megs to fill before using swap space. So a swap partition of 128 megs or even 32 megs could be enough.

If you don't select enough swap, you may add more later.

Installing with no CD-ROM drive or modem

Most Linux distributions come on a CD-ROM. You can also download them from an FTP site, but that requires an Internet connection. What if you have a system with no CD-ROM drive or Internet connection, like an old 486 laptop? The trick here is to have another desktop system with a CD-ROM drive, and a null-modem serial cable. I will show you how to do it with Slackware. It is also possible with most other Linux distributions. Insert the Linux CD-ROM in the drive on the desktop and copy the A (base) and N (networking) packages on diskettes. You need at least those in order to use a serial cable to transfer the rest of the packages.

Now you need to enable NFS networking on the desktop, and allow the laptop to connect. You can give a temporary IP address to the laptop, like 192.168.1.11 that you need to add to your /etc/exports file on your desktop.

To link the two systems together, this is what you need to type on the laptop:

/usr/sbin/pppd -detach crtscts lock 192.168.1.11:192.168.1.10 /dev/ttyS1 115200

And this on the PC:

/usr/sbin/pppd -detach crtscts lock 192.168.1.10:192.168.1.11 /dev/ttyS1 115200

This is assuming the cable is linked to ttyS1 (COM2) on both systems.

With NFS, you can mount the CD-ROM drive remotely and tell the installation program to use a specific path to install the remaining packages. Mount the CD-ROM with a command like this:

mount -tnfs 192.168.1.10:/cdrom /mnt

Then run the installation program:

setup

and enter the new path for the packages files.

Multiple operating systems

A computer only needs one operating system to work. But what if you just want to try out a new system? Doyou need to forget about the old one and erase your hard drive? No, you can have as many operating systems on your computer as you wish.

Linux requires 2 partitions to work. Partitions are sections of the hard drive. When you install Linux, it will provide a program called fdisk or disk druid allowing you to create the needed partitions. The main problems people have is that they don't have empty partitions to use for Linux, and they don't want to erase the current

Windows or DOS partition. The trick is to resize your current partition to create empty space. Then you will be able to make the partitions needed by Linux to install properly.

Fdisk doesn't allow you to resize a partition. You will need to use another program to do the job, before using fdisk to create the Linux partitions. A very popular commercial product to do this is Partition Magic from http://www.powerquest.com.

Let's see step by step what is needed to resize an existing partition to allow the creation of a new one for Linux:

  • Buy Partition Magic, or get any other tool that can safely resize partitions.

  • Make sure you have at least 150 megs free on your main partition, the required amount for Linux.

  • Resize the partitions so you have at least 150 megs free, outside of any current partition.

  • Reboot and launch the Linux installation.

  • Run fdisk or any partitioning program that comes with the Linux distribution, and follow the installation instructions to make the required Linux partitions.

How to find a Linux CD-ROM at low cost

The Linux market started from a few distributions available only from FTP servers, to full feature commercial distributions available in stores and online including a printed manual and phone support.

Here are the main choices you have when looking for a Linux distribution:
  • You can download any Linux distribution from its FTP server. To take a few examples, RedHat can be downloaded from ftp://ftp.redhat.com, Slackware from ftp://ftp.cdrom.com and Debian from ftp://ftp.debian.org. That method is free, but requires you to have a fast Internet connection. Downloading a full Linux distribution over a 56Kbps modem will take you quite a few hours.
  • An other way is to buy a full distribution. RedHat, for example, can be bought online for about $50. This will include a box, a CD-ROM, a boot diskette, a manual and support from RedHat.
  • The last way is to buy only the CD-ROM. There are a few places selling CD-ROMs of various distributions for $2. One of them is http://www.cheapbytes.com. You will only get the CD-ROM, but this is all you need to install Linux if you are comfortable with the fact that you don't get a printed manual or free support. You can find the manual and other documentation on the CD-ROM.

Which distribution is good for you

They are all good. But that's not a real tip. What you should be looking for is which distribution you feel the
most comfortable with. RedHat has the reputation of being very easy to install. They provide special tools to
make the configuration easier. Debian also has some tools, but will usually require you to go on the command
line more often to configure the system. If you want to be on your own, and really learn how to edit
configuration files then Slackware is for you. The Web site http://www.linux.org lists all the available
distributions.
In the end, the best person to decide which distribution you like, is yourself.