Tuesday, June 13, 2006

Getting into the shell

One of the components of Linux that many Windows users might not be ready for is the shell. The shell, as you might recall from an earlier column, is the layer of the operating system that fits between the desktop and the kernel. It allows you to directly interact with the various components of your computer without going through the graphical interface.

Of course, there are several graphical interfaces, or desktops, available for Linux -- KDE and Gnome are chief among them. These desktops allow you to accomplish even very complex tasks pretty easily. However, there is no easier way to get a lot accomplished quickly than by using the shell -- once you get used to it.

Windows, of course, used to have a real shell -- the DOS window. In the DOS window, you could easily view, load, copy, and erase files, format hard drives, and even reconfigure parts of the computer. As Windows progressed through 98 to XP, DOS became less and less powerful. Now, you have to jump through hoops to get to a real DOS window from Windows.

With Linux, however, the "DOS" window reappears, in the form of a "console", or shell window. From the shell, you can do all of the tasks you once c0uld perform from the DOS window. Of course, you can still use the graphical interface to do many of these tasks, but the console window can let you do it faster. You can generally find an icon to open up a console window on one of the menus within your desktop environment.

Users accustomed to DOS have some adjustments to make, though. Many of the commands ("dir", "copy", etc.) have new equivalents in Linux ("ls", "cp", etc.). Rather than catalog all of the shell commands here, I'll run through some of the most helpful:

ls -- list files
cp -- copy file(s)
mv -- move file(s); use this instead of "rename"
rm -- remove file(s)
tar -- compress or decompress files
man [command] -- display help file associated with [command]
more -- display contents of a file one screen at a time

One of the handiest features of the shell is the wildcard. If you want to list all the files in a directory that start with "amy", for example, you can type "ls amy*". Try that with your desktop. There are plenty of resources available to help you learn to use wildcards to your advantage. They are one of the best reasons to jump into a console from time to time.

You can also run most software from the shell, by typing the name of the program. For example, to run the Email program "Evolution", you can type

evolution

from the console prompt. When you do this, though, your console will be completely occupied with running the software until you exit it. You may want to run it as a background task -- allowing the console to do other things (including taking other commands from you) while it runs it. Add an ampersand (&) to the end of the command.

evolution &

The "Superuser"
From Windows, you'll recall the concept of having different users logging into the same computer, each having access to private (user-only) and shared files. Linux continues this concept -- you can add users ad infinitum. One user always remains the same -- the root user. This "user" has access to every file on the machine.

As a regular user, when you log into the desktop or use the shell, you'll only have access to your own files and any files that other users are sharing. Even if you're the only user on your computer, the operating system will automatically limit your ability to get to system and protected files. This is for your own protection, so you don't accidentally disrupt things that will make your operating system not work anymore. In order to access, change, or delete system files, you will have to log in as the root.

This is not as much of an issue with the graphical interface, because you should never log into the desktop as the root user. Really. We mean it. The root restrictions are the most powerful protection your computer has against viruses and against your own bad behavior. If you log into the desktop as root, both of these protections are gone. When you're logged into the desktop as a regular user, you (and any virus you may contract) can only destroy your personal files, but the system will live on no matter what.

There are reasons to log into the shell as the root user, though. If you need to look at or copy files in the protected area of the system, which you might from time to time, you'll need to log in as root to do so. You'll also need to log in as root to install software or reconfigure your system.

Be very careful, though. You can make your system completely unusable by deleting even one critical file. Don't even think about using wildcards to delete multiple protected files unless you really know what you're doing -- this is a recipe for disaster. In general, until you know what's what, you should not log in as root unless people who know what they're doing tell you to.

To log in as the root user from the shell, type

su

from the command prompt. You will then be asked for the "root password" you created when you installed the system. When the prompt reappears, you will have access to every file on your system. Only this window, however, and any program you run from this window, will have root access. On your desktop, you'll still be logged in as yourself, a regular user. You can then go about your business. When you're done, you can close this window, and the root access will disappear. You can also type

su [username]

to log back in as yourself. It's probably safer, though, to simply close out the window.

Once you get comfortable with the shell, you'll probably find yourself popping in and out of it to perform certain tasks, rather than spending lots of time working within it. But it's handy when you need it.

Regards.

Sunday, June 04, 2006

Partition Perdition

Once you've chosen a distribution to install, the actual installation process is relatively easy. One question that will confront you (for which you may not be prepared) relates to partitioning. By partitioning your hard disk(s), you will decide how much space to dedicate to Windows, and how much to dedicate to Linux.

File System Wisdom
One of the tasks of the operating system is to move information to and from your hard drive. Every time you copy, delete, move, or save a file on your computer, the operating system tells the computer how to handle the information. Windows and Linux have entirely different ways of doing this. Predictably, they do not share the same space on a hard disk very well. Instead, to allow them to coexist peacefully, you will have to construct two separate spaces on your hard disk -- one for Windows, and one for Linux. This process is called partitioning.

Most likely, your computer came pre-installed with Windows, meaning you never had to break out the Windows installation disk to get your computer up and running. Even if you did install the operating system yourself, you probably never dealt with the issue of partitioning your hard drive. When Windows was installed, it claimed all of the available space on the hard disk, whether it needed it or not.

Since Linux will need its own space to operate in, you will need to "repartition" the hard disk to make room. Most of the Linux distributions are fully capable of repartitioning your hard disk. You will simply have to decide how much space to leave for Linux. Most distributions these days will happily install in a 10 gigabyte partition (give or take a few gigabytes), but you may want to leave more room for data.

Before you repartition your hard disk, you must back up the information on the disk. There is a chance your data could become corrupted during the partitioning process. This is not optional. Really. I did it, and so can you.

To repartition the disk, your distribution's installation software will have to read your Windows files and move them all to one part of the hard disk. Some distributions do a better job at this than others. But all of them are doing very little better than you would do reading a foreign language you learned in high school. You might do a passable job, but you may miss some things here and there. So make a backup. You've been warned.

If you choose, you can leave the partitioning to software like Norton Partition Magic. This does not keep you from having to back up your Windows data, but you might have a bit more confidence in it. It can read a few types of Linux file systems, and even create Linux partitions for your installation program to use.

If you have any discomfort with the partitioning process, don't install Linux. You can work off the Live disk, or ask one of your computer-expert buddies to help. Partitioning hard disks is not for the timid.

Choosing a file system
When you partition the hard disk, you'll have to choose a file system for Linux to use. Just as Linux offers any number of kernels, shells, and desktops, it also offers different ways to store information on the hard disk. The two principal systems are Reiserfs and ext3. Other file systems may be available, but you should probably choose one or the other of these unless your installation software recommends otherwise.

For practical purposes, there is little to recommend one file system over the other. Technical types will find advantages and disadvantages of each. My experience leads me to believe that ext3 is a bit more widely used, and Reiserfs is a bit of a bias of SuSE. I've also found my ext3 partitions to be a bit more stable and somewhat easier to recover when errors occur, but you may have a different experience. If your installer has default file system options, you're probably best off agreeing with them.

Reading Foreign Systems
After you've installed Linux and it's up and running, the first thing you'll likely want to know is where all of your old data have gone. Your Windows data will be in your Windows partition. You won't necessarily be able to run your Windows software (although we'll discuss in the future some ways to cheat and run it anyway). However, many of your Windows files can still be read by Linux software. For example, your word processing documents and spreadsheets can probably be opened by Linux software such as Openoffice.

Many distributions will read data from your Windows partition from within Linux pretty easily. Windows, however, uses a few different file systems. The main ones these days are NTFS (Windows 2000 and XP) and FAT32 (older versions of Windows). You don't necessarily need to know what file system your Windows software used in order to read the documents you stored on the Windows partition. However, Linux cannot write very well to NTFS -- so if you happen to have used this format, you will need to copy these files over to your Linux partition to edit them. With many distributions, this is as simple as dragging the file over to the desktop, just as you used to in Windows.

There are some "experimental" ways to write to NTFS partitions from Linux (allowing you to edit and save files there). There are just as many horror stories from people who've wiped out their entire Windows life in mere moments by doing so. For now, it might be best to stay away from these methods.

If you need to share data between Windows and Linux, you can create a single FAT32 partition for both to use. Both Windows and Linux can read and write these partitions. The file size is somewhat limited (4 gigabytes), but you shouldn't notice any significant problems unless you're working with really huge files (such as multimedia presentations, which are going to be more challenging to share between Windows and Linux anyway). If you have files that are "mission-critical", you probably should not plan on sharing them -- just in case.

Regards

Saturday, May 27, 2006

Distribution Confusion

One of the most overwhelming aspects of Linux for a former Windows user is the "distribution" phenomenon. You can't just walk into a store and buy--or go online and download--Linux. Instead, you have to choose a "distribution", which is conceptually nothing more complicated than a brand or "flavor".

Windows, of course, comes in a few different "flavors" -- Windows 2000, Windows NT, Windows XP Professional and Home, for example. Initially these different "editions" were nothing more than new versions and updates. These days, however, Windows comes in some more complicated flavors, such as Windows XP Tablet PC edition, Windows XP Media Center edition, and so on. Each edition comes with its own set of capabilities and its own limitations.

Linux, on the other hand, comes in a bewildering array of flavors, called distributions. If you find the link to DistroWatch in the right sidebar, you can see over 100 different distributions tracked (although some of these are for a related operating system, BSD). Each distribution builds on the same architecture (the same, or similar, kernel and shell), but there are significant differences among them. The chief differences include
  • Platform: Some distributions are designed to run on non-Windows computers, such as Macintosh. There are distributions that run on legacy computers like the Commodore Amiga. Other distributions are tailored to notebook and tablet computers. There are even distributions that run on handhelds (although they are more properly viewed as emulators since they sit on top of the native handheld operating system). Some distributions simply won't run properly on certain computers, for reasons that are not always clear. This is why starting with a live CD version may be best.
  • Size: One of the advantages of Linux is its scalability. There are Linux distributions that can run on the oldest, smallest, and slowest computers available. Other distributions are monster systems that run best on powerful computers with large amounts of storage. If your older computer is running too slowly or running out of memory, you might find a smaller Linux distribution to be just the trick to bring it back to life.
  • Features: The primary difference among distributions is the "packages", or software programs, that come along with them. Some distributions include only the operating system and a bare minimum of programs; others have a full panel of both open-source and proprietary software included. Some distributions even include commercial software, although these distributions generally must be purchased, rather than downloaded for free. If you're looking to get up and running with a full set of software right away, one of the more full-featured distributions may be right for you.
  • Software installation: Because of the open-source nature of Linux, there are a number of ways to find and install software once you've installed the operating system. Some of these are a bit cumbersome (compiling and installing the source, for example), while others are simpler (installing binaries directly). Each distribution has its own particular way of installing software, and some ways are more user-friendly than others. Many programs have to be specially-built for a particular distribution; you will find that the more popular distributions have more software pre-built (as "binaries") than the less-popular distributions.
Choosing a Distribution
The debate about which distribution is "best" is lively, and, as yet, unanswered. I will not even attempt to take a position on the issue. The best recommendation I can give is that the less familiar you are with computers, the more you should stick with the "larger" distributions. The DistroWatch website includes a "Page Hit Ranking" sidebar that lists how frequently each particular distribution's page is accessed on the website, which serves as something of a surrogate for how popular the distribution is.

Each distribution's website gives information about the philosophy behind the distribution, the packages that are included, and some of the hardware limitations and bugs they've found. If there is a known issue regarding a component on your own computer, you would be advised to stay away from the distribution until it's addressed.

Once you find a distribution that seems to be a good fit, try downloading the "Live CD". This is a version of the distribution that runs completely on one bootable CD (or, more often, DVD). You will find links to an "iso" file, which you can download and burn directly onto a disc. Boot with the disc in the drive, and you will load the new operating system instead of Windows. You can then try it out to make sure your hardware is compatible. You might need to do some configuration from within the OS to make sure all of your hardware is recognized.

You can even try downloading several live discs to see the differences between different distributions. The only costs will be the time spent downloading and the cost of the blank disc. Many power Linux users actually have multiple distributions installed on the same computer, to take advantage of the strengths and weaknesses of each. You'll probably want to stick to one at first.

Taking the Plunge
Once you've found the distribution you like, it's simply a matter of downloading it from the website. Many websites also have mirrors, which are exact copies of the website in other locations. Instead of going to the main website, you can go to a mirror site closer to you--this will unload the main website and probably give you a faster download time.

Distributions generally come in CD or DVD form. If you have a DVD burner, the DVD iso is usually a better bet, since most distributions will fit on one DVD. If you opt for CD's, you may need to burn and install several CD's worth of data. If you choose, you can also purchase a pre-burned CD or DVD -- follow the links from the DistroWatch website, or find a software retailer for the full retail package.

One caution: when you're looking to download the distribution, beware of "alpha" or "beta" releases, "release candidates", or "unstable releases". These are all code-words for test versions. You will want to find the "stable release".

Installing Linux is a whole separate process, and we'll discuss that in upcoming days.

Regards.

Friday, May 26, 2006

What is an OS, anyway?

Most average Windows users probably have very little idea what an operating system is, let alone how much the operating system influences what they can and can't do with their computers. An (admittedly oversimplified) introduction, then, might be helpful.

Imagine, for the moment, that you're in a restaurant. Your server arrives and presents you with a menu of all of the restaurant's offerings. You look through the menu, decide what you would like to have, and inform the server -- who scurries off to the kitchen to place your order. After a short delay, your food arrives -- hopefully what you ordered, but not necessarily.

Without knowing it, you have used a form of operating system, although it had little to do with computers. Let's look at the steps involved:
  1. You, the user, chose what you wanted from a menu of options.
  2. The server ensured that your selections were legitimate and complete, and corrected you when necessary.
  3. The server communicated your selections to the kitchen.
  4. In the kitchen, the chef matched your selections with pre-built recipes.
  5. After selecting the recipes, the chef carried out the instructions in the recipes -- finding ingredients, mixing them in proper ratios, cooking or chilling them, etc.
  6. Once the instructions were complete, the chef gave the results to the server.
  7. The server brought the results to you, the user.
The operating system (OS) of your computer performs the same functions. When you sit down at the computer, the operating system presents you with a series of options -- you can run programs, copy or delete files, etc. Whether the operating system uses icons that you can drag back and forth or commands that you type in, the OS still translates your requests into a series of instructions that can be carried out by the computer.

Most operating systems (including Windows and Linux) consist of several "layers", or components. In Linux, these components consist of:
  • The "kernel" -- the basic rules the computer follows to interact with all of the hardware on your computer. In our restaurant example, the recipe book is the restaurant's "kernel".
  • The "shell" -- the fundamental means of interacting with the kernel and the computer's components. In our restaurant, the menu is the restaurant's "shell"
  • The "desktop" -- the interface that allows the user to interact with the operating system's shell. The restaurant's server performs the function of the OS desktop, helping you to navigate the options presented in the menu. Of course, you don't need a desktop on a computer any more than you need a server in a restaurant -- if you're willing to read your menu items directly to the kitchen, you might also be willing to use the shell to enter commands directly.
Windows has a similar architecture, although the components are integrated far more than in Linux, so you may not recognize them individually.

Replacing the operating system on your computer is like a restaurant changing its offerings. It will need a whole new set of recipes (kernel) and a new menu (shell). Once you've changed all of this, you will probably need all new waitstaff (desktop). You can, of course, make the new waitstaff look and operate very much the same way the former staff worked.

When you change from Windows to Linux, you will need to install a new kernel, a new shell, and a new desktop. Most of the time, these all come together in one package. Once you're done, you'll still be able to perform the same general functions you did before, but things will look and work a little differently. And, just as your favorite meal might disappear from a restaurant that changes its menu, you probably won't be able to run your favorite Windows applications once you switch to Linux (there are, however, some nice conversion utilities that we'll discuss in the coming days to help with this).

So why do we have operating systems at all? Unless you want to go into the kitchen and cook the food yourself, the operating system is going to save you a lot of time and effort. The OS confers two principal benefits:
  1. It makes your job easier as a user. You can configure your operating system once, and then every program you run within the operating system will (probably) conform to your configuration. Otherwise, you'd have to configure every program you run to know what kind of printer you have, what time zone you live in, and what colors you like to use on the screen.
  2. It makes the programmer's job easier. The programmer doesn't have to know what kind of monitor or printer or disk drive you have to write your word processor. All the programmer has to know is that you have these things. The job of the operating system is to find out what kind of components you have, and then provide a link from the software to those components. Otherwise, the programmer would have to write software for every possible component into every program. With an operating system, this software is written once, and every program "borrows" it.
The next time you order food online, consider that you've just used two operating systems. And bon appetit.

Regards.

Tuesday, May 16, 2006

Why switch to Linux?

The first question any home user contemplating switching to Linux should ask is, "Why bother"?

Most people are intrigued by the fact that it's "free", but if you already have a working OS on your computer, then you don't particularly need another free operating system.

Why I switched
I initially wanted to see what all the fuss was about. I read up on Linux on the internet, and found the concept of an open-source operating system fascinating. The main reason I switched, though, is that my Windows OS has become so corrupted by installing and uninstalling software, crashing software, and occasional power outages that there are certain software packages it won't even let me install anymore, let alone run. So it was a matter of either reinstalling Windows to clean things up, or try something different. I chose the latter.

First I downloaded a "Live" CD, just to see what things looked like. The concept here was interesting, too -- the idea of running an operating system completely from a disc, without changing anything on the hard disk or having to repartition or reinstall anything. The Live CD ran well, although without any significant write access anywhere, there wasn't much one could do with it. It was more of a proof of concept -- the OS would, indeed, work on my system.

Then I read about an "OS anywhere" system. This centered around a self-booting USB hard drive with a Linux OS that you could carry with you anywhere, and that would run on practically any computer. I thought this sounded great. I tried to build my own with the live CD and a USB HD I put together from a blown-out laptop, and discovered that I had a lot to learn about Linux before I could pull off a stunt like that (I have since successfully done so, although you can buy one much easier).

Finally, I took the plunge. I figured I had enough unused hard drive space around that I could afford to repartition the hard drive. I figured I would try it out from time to time, just for fun.

The first distribution I chose was Mandriva. Unfortunately, after several attempts at installing it, I simply couldn't get it to boot reliably on my system. I then tried OpenSuSE, and it installed without a hitch. I have been using OpenSuSE ever since (about two months as of this writing).

Repartitioning the hard drive was simple, and I haven't missed the space Linux took up. In fact, I had to repartition again to make even more room for Linux -- which is something of a challenge when you have NTFS and ReiserFS sharing the same hard drive (Norton Partition Magic did the best job of anything I tried, although it's very skittish around ReiserFS).

Why should you switch?
If you're even wondering about Linux, and have read this far, you probably have enough interest in switching. Although there are many lively online debates about why Linux is better than Windows, my experience as a home user leads me to the following conclusions:

1) Linux has been much more stable for me than Windows. This is not to say that I haven't crashed Linux -- in fact, as of this writing, I'll probably have to reinstall KDE because of some kind of corruption I've managed to cause. The stability of Linux comes mostly from the lack of the infernal "registry" that causes so much trouble within Windows. You can install and uninstall software much more cleanly on Linux, which means that programs don't interfere with eachother as much. Just beware of "dependencies". If you don't know what these are, you'll soon come to find out.

2) Linux is, apparently, more secure than Windows. I'm a little concerned about this argument, because it seems fallible to me. Linux is affected by far fewer viruses, but it also has somewhat more rudimentary security. In fact, since it's open source, you would think Linux would be very easy to break into if someone really wanted to. I conceive of the difference this way: suppose you live next door to an art museum. You have a rudimentary home security system, and the museum has a state-of-the-art system. Which one is more secure? More people want to break into the museum, but it's easier to break into your house. In the end, it's hard to tell.

3) Linux is infinitely more configurable than Windows. You can choose from several desktops, you can configure those desktops exactly as you like, and you can even "create" your own OS by building your own kernel and packages. Most entry-level home users won't necessarily go this far, but you can if you like.

4) There are a lot of little things you can do with Linux much more easily than in Windows -- particularly file operations (like backing up your system, creating .iso files, archiving, etc.).

5) Most Linux distributions come with an incredible amount of software already included -- and "free". With Windows, all you really get is Windows.

Why *not* to switch
There are some things you should know about Linux before you decide to take the plunge -- some of which I learned the hard way:

1) Linux is not for people who are uncomfortable searching for, downloading and installing software. If you are not proficient in these three steps, or are unwilling to learn, stick with Windows. And good luck.

2) As far as I'm concerned, it is not practical to install and maintain Linux unless you have broadband internet access. Practically speaking, all of your updates and support are going to be on-line, and if you try dialing up, it's going to take forever to get anything done.

3) Linux is an alternative to Windows. It is not a replacement for Windows. Most of your cherished Windows software will not run properly on Linux, even with many of the ever-improving Windows emulators available. There are myriad alternative applications that run in Linux and perform many of the same functions, but, by and large, they do not have as many features as their Windows counterparts. In most cases, this is a good thing. But if you have a mission-critical application that will not run with Linux, don't switch.

4) Installing Linux is easy, but you will be surprised how much time it can take to get the system up and running -- and keep it that way. There's a steep learning curve for Linux, and you should be prepared for it. Do not attempt to repartition your hard drive and install Linux if you only have an hour to devote to the process.

5) If you're one of those "I know I should back up this system, but I probably won't bother", you'll probably not want to try dual-booting Linux. You never know what could happen.

We'll look in future columns at some more basic issues of switching, as well as some things I've found along the way to make it easier.

Regards.

Welcome

Two months ago, I installed Linux on my home PC and booted Windows XP for the last time*. This weblog will document my journey as a relative computer novice into the often bewildering world of open-source OS.

There are some compelling reasons why home users will prefer Linux to Windows, and some real headaches that this leap will create. I hope to document both here from my perspective, and to help others who are making the transition.

Linux is, by its very nature, a collaborative process -- as I hope this weblog will be. You may see things that are controversial, oversimplified, or just plain wrong. I hope you will take the time to respond, correct, and assist as you are able.

Overall, I have enjoyed Linux, although installing and maintaining it has taken significantly more time than I ever anticipated. It may be free (as in beer), but free beer takes far less time to drink (and to recover from the effects).

Thank you for joining me.

*Technically, I have booted Windows twice since installing Linux -- once to convert Email and some other files over, and once to clean up and defragment the hard disk before (unsuccessfully) attempting to read/write NTFS.