Fixing Common Problems
This section describes how to fix several common problems. Each of the following sections outlines the problem and then describes the solution.
“I forgot my password”
Problem: You have to remember a zillion passwords at work and home. Unfortunately, you can’t remember your Linux password.Solution: The solution is simple if you have forgotten a user account password but still remember the root password. In that case, simply log in as root and reset the user password. For example, if your user name is rod, run the command passwd rod and enter the new password (for example) likes coffee.
The solution is more difficult when you forget the root password. You have to become a hacker and break in to your computer to fix the problem. Fortunately, Red Hat provides two possible solutions: Either boot into single-user mode via GRUB or boot from the first Red Hat installation disc.
“I forgot my root password!”
You can’t reset a regular user’s password if you can’t log in as the root (superuser). However, you can easily circumvent having to log in as the root user by booting your Red Hat Linux computer into Single User mode.Turn on or restart your computer and use the cursor keys to select the Linux operation system when the GRUB boot screen appears; Linux is selected automatically if you’re not using a dual-boot system (you installed only Linux). Next, press the e key to edit the GRUB configuration. You see three lines, the middle of which starts with the word kernel. Select the kernel line with the cursor keys when the 3-line menu appears. Press the e key again, press the spacebar, and then enter the number 1 at the end of the line. Press the Enter key and you return to the original GRUB window. Finally, press the b key to boot your system into single-user mode.Tip You can tell Linux to boot into nongraphical — rather than single-user — mode by substituting 3 for 1 when you’re editing the GRUB boot mechanism.
“I need to break into my own computer!”
Power on or reset your computer. Change your BIOS to boot from CD-ROM, if necessary. Before your computer starts the GRUB boot system, insert the companion DVD in the DVD/CD-ROM drive. When the Red Hat installation process starts, type linux rescue at the boot: prompt.Red Hat boots into single-user mode and mounts your Linux partitions. You can access and use your computer’s root file system by entering this command:
chroot /mnt/sysimage
You now have complete control over your computer. For example, you can reset the root password:
passwd
Enter the new password when prompted. Note that anyone who has physical access to your computer can use this method to break into it! If you use your computer in public or semipublic places, you should set your BIOS password. Setting a BIOS password doesn’t make using this method to break in impossible, but it does make it harder.
“I want to change the GRUB boot order”
Problem: You created a dual-boot computer with Red Hat Linux and Windows, and you want to change which one boots by default.Solution: Modify the /etc/grub/grub.conf file on your Linux computer. The grub.conf should look similar to this example:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-20.1)
root (hd0,1)
kernel /vmlinuz-2.4.20-20.1 ro root=LABEL=/1 hdb=ide-scsi
initrd /initrd-2.4.20-20.1.img
title DOS
rootnoverify (hd0,0)
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.x)
root (hd0,1)
kernel /vmlinuz-2.4.x ro root=/dev/hda7 hdb=ide-scsi
initrd /initrd-2.4.x.img
title Windows 2000
chainloader +1
rootnoverify (hd0,0) chainloader +1
In this case, Linux is the operating system that boots by default, unless you select otherwise; default = 0 corresponds to the first operating system in the list — the first Title line. To change the order, simply change the default value from 0 to 1:
default=1
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-20.1)
root (hd0,1)
kernel /vmlinuz-2.4.20-20.1 ro root=LABEL=/1 hdb=ide-scsi
initrd /initrd-2.4.20-20.1.img
title DOS
rootnoverify (hd0,0) chainloader +1
The next time you boot your computer, your Windows operating system (the DOS line) automatically boots.
“When I boot into Windows, I get the recovery process”
Problem: You have a dual-boot computer with Microsoft Windows as the alternative operating system. When you boot into Windows, you get the Windows recovery screen. “Help, I’m scared!”Solution: Relax — you almost certainly haven’t lost your mind or your Windows partition. What happened is that the Red Hat Linux installation process mistakenly selected the recovery partition from which to boot Windows. Most computers now come with a preinstalled Windows recovery partition (rather than a recovery CD-ROM), so Red Hat Linux sees at least two Windows partitions when configuring GRUB, and it made the wrong choice. For example, you have hda1 and hda2, and GRUB thinks that hda1 is the Windows partition; hda1 is the recovery partition, however, and hda2 is the Windows C: drive.You have to reconfigure GRUB to point to the correct Windows partition to make it work correctly. You may have this /etc/grub/grub.conf file for example:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-20.1)
root (hd0,1)
kernel /vmlinuz-2.4.20-20.1 ro root=LABEL=/1 hdb=ide-scsi
initrd /initrd-2.4.20-20.1.img
title DOS
rootnoverify (hd0,0)
chainloader +1
Change the rootnoverify (hd0,0) parameter to rootnoverify (hd0,1) and reboot your computer. This technique should fix your problem.
“My network is working, yet not working”
Problem: You have configured and checked your network connection, and it appears to be okay. But you can’t connect to some or all of the machines or network services you want. You’re perplexed.Solution: Check your Iptables-based firewall. Red Hat configures two different levels of firewalls during the installation. This book describes several different Iptables firewall configurations too. If your firewall isn’t configured correctly, it prevents some or all network communications. Even if your firewall is configured correctly, it may be designed, in many cases, to block the type of communications you want.Turn off your firewall with this command:
/etc/init.d/iptables stop
If your network connection instantaneously works, your firewall was most likely the culprit. In that case, you have to go modify your firewall to make it work for your needs. Don’t forget to turn your firewall back on as soon as you fix the problem:
/etc/init.d/iptables start
A description of how to customize an Iptables firewall is beyond the scope of this book. However, the firewalls we show you how to construct in this book may work for you and also be easier to understand and modify. Refer to Chapter 8 for more information about Iptables-based firewalls.
“I want to make an emergency boot floppy disk”
Problem: You skipped making an emergency boot disk when you installed Red Hat Linux and want one now.Solution: All is not lost if you read Chapter 3 and skipped making a boot disk. Nothing is lost because it’s easy, in fact, to make one. Log in to your computer as root and insert a floppy disk that you don’t mind erasing (losing everything on that disk). Run this command:
uname –r
This command returns information about the version of Linux you’re running. The output looks similar to this:
2.4.21-20.1
Use that number to run this command:
mkbootdisk 2.4.21-20.1
You have a Red Hat Linux boot floppy when the process finishes writing to the disk. Restart your computer and press the Enter key at the boot: prompt. You computer then starts Red Hat Linux.
“I can’t boot from my DVD”
Problem: Sometimes, you get a DVD (or CD-ROM) disc that you can’t boot from. The disc may otherwise be perfectly good, but for some reason it just doesn’t work for booting.Solution: You can get around this problem by using the boot image supplied with the companion DVD in the back of this book to create a bootable floppy disk. (This disc is different from the emergency boot floppy disk you have the option of creating in Chapter 3.)Log in to your Red Hat Linux computer as root and mount the first companion CD:
mount /mnt/cdrom
Change to the images directory on the CD-ROM:
cd /mnt/cdrom/images
Insert a disk into the floppy drive and run this command:
dd if=bootdisk.img of=/dev/fd0
A boot image is written to the disk, from which you can boot your computer.You can also create a bootable CD-ROM if you have a CD-R drive. Insert a writable CD-ROM (CD-R or CD-R/W) and run this command:
cdrecord -isosize boot.iso
“Linux can’t find a shell script (or a program)”
Problem: You type a command name, but Linux can’t find the command, even if it’s in the current directory.Solution: When you type a shell or binary command name, Linux looks for the name in specific places and in a specific order. To find out which directories Linux looks in, and in which order, type this command:
echo $PATH
You see a stream similar to this one:
/bin:/usr/bin:/usr/local/bin
Linux looks at these directories to find the command, program, or shell you want to execute. You may see more directories depending on your distribution or how your system administrator (if you have one) set up your system.Suppose that you create a shell or a program named bark and want to execute it (and assuming that you have set the permission bits to make bark executable by you). You have a couple of choices (although you have more than two choices, we list the safest ones). One choice is to type this line on the command line:
./bark
This line tells Linux to look in this directory (./) and execute bark.Your second choice is to move bark to one of the directories shown in the PATH variable, such as /usr/local/bin, and then enter bark at the prompt again.
“I don’t know how to make the X Window System start at boot time”
Problem: You don’t want to log in to a command-line mode (such as DOS) and then type startx. Instead, you want to log in through the X Window System.
Solution: If you like to see a graphical interface from the beginning, change this line in the /etc/inittab file:
id:3:initdefault:
to this:
id:5:initdefault:
Save your changes and reboot. X starts at the end of the boot process, and you can then log in through the graphical interface. To go back to the old way of booting, change the line in the /etc/inittab file back to this:
id:3:initdefault:
and reboot your machine.
“I never seem to have the correct time”
Problem: When you boot Linux, the time is wrong, so you set it with the date command. Then you boot Windows and its time is wrong, so you reset it. When you reboot Linux, its time is wrong again.Solution: Most Unix systems keep their time by using Universal Time (also known as Greenwich Mean Time, or GMT), but Microsoft systems keep their time as local time. When you set the time in either system, you set the CPU clock to that version of the time. Then, when you boot the other system, it interprets differently what is in the CPU clock and reports a different time.Linux enables you to use either GMT or your local time. You make this choice when you install the system. To change your choice, follow these steps:
Log in as root and type timeconfig.
The Configure Timezone dialog box appears.
Select the GMT option.
Highlight the option by pressing the Tab key, if necessary. (You should already be there when you activate the timeconfig command.)
Press the spacebar to deselect the option. Press the Tab key until you reach the OK button and then press Enter.
Reset the time to the proper value by using the ntpdate command.
You have to point the ntpdate command at a Network Time Protocol (NTP) time server. For example, you can run the command ntpdate clock.redhat.com. Some ISPs maintain their own NTP server, so you may be able run the command, like this:
ntpdate clock.redhat.com