There's no avoiding it, if you're using a computer (or just about anything else) the operating system needs to be maintained. This article addresses Linux maintenance issues and techniques, along with things you would expect to deal with, coming from a Windows background.
Accessing Storage Media
Hard drives, USB stick drives, flash drives, floppy disks, CD-ROMs, DVD-ROMs, and all sorts of other items fall under the term "storage media." Some are permanent media, like hard drives, and some are temporary or removable, like USB sticks.
Fortunately you don't need to know much to access most of these. Just put the USB stick into your USB slot, and when the icon appears on your desktop, double-click it, and you're off to the races. Then when you're done with it, be sure to right-click the stick on the desktop and unmount it before removing it (just like you're supposed to do on other types of systems as well). You'll also find that your filesystem explorer on your desktop lets you point and click through a number of possibilities.
Sometimes, though, you have to make a little effort. For example, maybe you're using a computer that can boot into either Linux or Windows, and you want to get to your Windows data from Linux. That Windows data is probably on one of your hard drives.
Each of your hard drives is divided into partitions. The fdisk command can help you determine which partition has Windows data (look for terms such as NTFS or FAT).
A great resource to help you learn more about mounting partitions is the Linux Partition HOWTO.
Adding New Software
Getting new software can be like getting presents in nice shiny wrappers. You can't wait to find some and see what's inside. Today's mainstream Linux distributions offer you a massive repository of everything from word processing programs to games and programming tools. Take a look at your distribution's documentation for the specific tools you'll use to browse and install these offerings.
In addition, there are probably extra repositories that you can tell your computer to search, broadening your access to software even further. Here's some excellent resources to help you with the distributions discussed here:
- Fedora - The Fedora FAQ
- Kubuntu - The Kubuntu Guide
- Mandriva - The Mandriva Wiki
- openSUSE - The openSUSE Documentation
- Ubuntu - The Ubuntu Guide
You should see this lecture everywhere, and there's a good reason for it! People new to Linux like to do a lot of things as the root user (the administrator). Sure, it's convenient, since root has permission to do everything. However, since root has permission to do everything, it's very easy to seriously mess things up. It's smarter to make yourself a regular user account and only log in as root if you absolutely have to.
Entering Single User Mode
Single user mode is actually quite a literal name. It means taking Linux into a maintenance state where there's no individual accounts or need to log in (and there's no networking and a lot of other things as well). There are two ways to enter single user mode: at boot time, and while already logged in.
Entering single user mode (also called runlevel 1) at boot time involves using the boot menu. If there isn't a single user or rescue mode option there, there are advanced tricks you can use, or you can accomplish the same thing by logging in and going to single user mode that way. To do that, log in as the root user and enter the command:
Filesystem Check and Repair
The general issue of filesystem check and repair is the same regardless of which distribution you're using. There are a number of situations where you may need to do one or the other:
- Your computer won't boot.
- While your computer is booting, it fails while doing a routine filesystem mount or check. You might be immediately dumped to a rescue mode, or the computer might just lock up.
- There's suspect behavior and you're afraid that something's wrong with your drives.
No matter which of these situations you're experiencing, the best approach is to begin by either using your distribution's rescue CD (it's the first CD or DVD you used to install the distribution) or any LiveCD to reboot the computer. If you're asked if it should mount any of your existing partitions, say no. It's important that any filesystem repairs be made on a partition you are NOT currently using.
After making sure that the partition you want to check and repair isn't mounted (the du, mount, and fdisk commands will be helpful here), use the proper command for your filesystem.
For more on Linux partitions and issues such as mounting them, see the Linux Partition HOWTO.
First, become the root user. Then, proceed to the section that matches your distribution.
Repairing ext3 Filesystems
If you're using Fedora, Kubuntu, Mandriva, or Ubuntu, the command is e2fsck. Type:
e2fsck -fy partition
e2fsck -fy /dev/sda3
Repairing ReiserFS Filesystems
If you're using openSUSE, the command is reiserfsck. Type:
reiserfsck --check partition
reiserfsck --check /dev/sda3
From there, follow instructions, as reiserfsck may tell you to run particular additional commands to repair issues. In general, allow the fsck commands to make all repairs. Again, it is important that you do not attempt to repair a partition you have mounted and are using.
For more information, see Repairing ReiserFS file system with reiserfsck
Keep Your System Up to Date
The key to computer stability and security is keeping your operating system and programs up to date. This is the case for Linux as well. Checking once a day is recommended, and at minimum you should accept any updates involving security or bug fixes. To update your distribution:
- Fedora - See the Fedora Project update documentation
- Kubuntu - Read the following from KUDOS Unofficial Kubuntu FAQ.
- Mandriva - Read the Mandriva update documentation
- openSUSE - Read the package management documentation for your update options and pick the one you like best
- Ubuntu - For package management documentation, read this.
Linux and Drive De-Fragging
In the Windows world you're used to needing to occasionally de-fragment your drive, so that the data isn't scattered all over the place. Doing so both speeds up interactions with your hard drive and can have the handy side-effect of freeing up space.
There really isn't a need for this regular activity in Linux. Linux approaches file storage on a hard drive differently from Windows, keeping the drive's internal layout in mind in a more efficient manner, and that of the heads that read and write the data. The point isn't to avoid fragmentation, that's nearly impossible, and some might even say undesirable. Instead, the point is to lay out the data in such a way that it's most efficient to access.
Since fragmentation is a given, Linux makes sure that it isn't slowed down by seeing what data requests are coming up and grabbing that information earlier than necessary (called reading ahead), along with other optimization measures that make it unnecessary to go through the defragmentation ritual for the sake of speeding up performance.
If you are bound and determined to defrag anyway, see the previous "Filesystem Check and Repair" section.