TechRepublic's Linux primer (Originally published 4/29/01. Updated 12/09/04) This primer is meant to serve as a comparative walk-through for many aspects of Linux. The comparative aspect of this primer takes into consideration that most readers will have a basic familiarity and understanding of Windows 2000 or Windows XP and a desire to learn something challenging, fulfilling, and rewarding. For every Windows action, there's a comparative Linux action, and with every action, there's an operating system (OS) response. Throughout this document, I'll explore various commands and events that both operating systems share and I’ll show how to invoke simple processes and parallel applications. Because of the distinct individuality of the various Linux distributions (Red Hat Linux, Caldera Open Linux, SuSE, Debian, and Mandrake), this primer will take the liberty of dealing with one particular distribution. Red Hat Linux has risen above all other flavors of Linux to become the most popular and hottest-selling Linux product to date. This is not to play favorites or to say that one distribution is better than the other. Choosing one distribution as a focal point is merely a matter of convenience. This primer is divided into individual sections: system layout, startup and shutdown, basic file processes, using removable and irremovable drives, the desktop, program installation, system configuration, network configuration, maintenance, basic help systems, and dual booting. Let's begin by examining the system layout. System layout The Windows system layout is a fairly straightforward. The C: drive resides on the DOS partition and contains all of the system and non-system folders and files. On the C: drive, you’ll typically find: A set of folders that houses applications (Program Files). Windows general files (Windows). Files and settings users have created or chosen (Documents and Settings). User and application files created in the file tree. Within the Windows directory, you’ll find the various system folders and files necessary for the basic functionality of Windows. Housed within this same directory (Windows) are the .ini, .bat, .com, and various other files that make up the heart of the Windows operation. It is possible to make the system unbootable, or unstable, by making changes to these files. This problem is somewhat negated in the more recent versions of Windows by having an Administrator and regular users. Page 1 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. The Windows file tree structure shown here doesn’t include all existing files and folders, but it should look familiar (Figures A and B). FIGURE A FIGURE B The top half of the Windows file tree structure Prior to Windows NT, the Windows OS was a single-user environment. Windows 9x was configured with one user who uses, administers, and maintains the The lower half of the Windows file tree structure system. In this configuration, it's very possible for a user to accidentally take the system into an irreversible state. Linux doesn't allow this behavior. Like UNIX, Linux is based on a multiuser environment in that there is an administrator (called root) who is the only user allowed to execute many tasks. Root can do such things as: Add users Delete users Create dial-up accounts Configure networking Install and uninstall programs Make changes to global configurations Access all user accounts Page 2 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Windows NT, Windows 2000, and Windows XP have added the concept of multiuser systems and the administrator account, thus relieving many of the issues of prior versions. The user, in Linux, is the everyday user. Users have a limited set of permissions that allow them to execute certain tasks and control only limited environmental variables. It's very easy for a user to break his or her account or desktop. However, if users break, or corrupt, their desktop in Linux, all other users, including root, will still have the use of their own accounts. This design makes for a very safe and secure environment. The first postinstall task is to have root set up the various user accounts. If you're using the machine as a single-user desktop, simply create a user that will be used for everyday computing. The new user is created in one of two ways: through linuxconf or at the command line. The simplest method is through linuxconf; which is where root can create the new user, give the new user permissions, and add groups to the user. At a prompt (and as root), type linuxconf. Once the linuxconf application has started, scroll down to User Accounts and choose Add. In the Username field, provide a name for your user. Feel free to be creative. The only other field in this tab that you’ll need to concern yourself with is the Full Name field. Provide the requested information and move to the Privileges section. For safety’s sake, leave the new user’s permissions set to the minimum level. Now activate these changes. Once this user is created, log out of root and log in as the new user. The security of running under user instead of under root is well worth the hassle of having to su to make system changes (more on su later). At first, this will seem more of an annoyance than a feature. However, the ability to retain global configurations and control all levels of setup, permissions, and customizations while being free to tinker with user accounts will quickly win you over to the multiuser environment. With the multiuser environment, a single controlling unit acts as a sort of overlord to the entire system. Yes, it sounds daunting, but the tasks of setting up devices and altering critical file systems and processes should be left to those with the knowledge of administering a system. If you don’t possess such knowledge, then you won't have to worry about harming your desktop system—it’s as simple as that. Linux uses the concept of directories, instead of folders. This comes from the character-based roots of Linux. A directory is also a collection of related files and directories. Directories are represented in the Linux GUI as a folder, making the distinction mostly semantic for average users. The administrative user will need to understand the directory concept. Now that you have a basic understanding of the multiuser structure, let's look at the Linux layout. As mentioned previously, instead of folders, Linux uses directories, and each directory is stored in a mountpoint. This mount-point acts as a sort of logical location so that the OS can remember where each file is placed. The main directory for the system is simply /. Yes, it's that simple; / is where it all begins. Housed within / are the following directories: bin, dev, home, /usr/bin, /usr/sbin, var, /boot, and /etc, among others. Here is a basic listing of what resides in each of these directories: bin: This directory contains the most essential UNIX commands, such as ls, awk, cat, chmod, chown, cp, dd, df, mount, mkdir, rm, rmdir, and touch. These essential commands are the backbone of the Linux/UNIX command environment. The bin directory is, by default, located in the $PATH so that all commands residing within bin are global. (They can be executed from any directory.) dev: This directory holds the files that communicate with the machine’s hardware. This directory contains devices that connect your modem, your CD-ROM, your Ethernet, your floppy drive, and your hard drive to your OS. Almost the entire configuration of these devices is handled during the install. home: Home is literally where the heart is! After you have added your user account, home will contain a subdirectory with that user name. For example, if you added the user Chuck, /home will Page 3 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. contain the Chuck directory. The explicit path to Chuck's home directory is /home/Chuck. All of the working directories and configurations are housed within the user’s home directory. Note that a user has no access to the other users' home directories; therefore, each user's configuration is local to only that user. This setup also aids in security. For example, you have a Bob and a Chuck on your system. Bob will not be able to change directory (cd) into /home/chuck, nor will Chuck be able to cd into /home/bob. Likewise, Bob won’t be able to read Chuck's files (as long as Chuck has not set the permissions of his files to global—more on permissions later). /usr/bin: This directory contains other commands, and the difference between /bin and /usr/bin is arbitrary. The split between /bin and /usr/bin was merely a way to divide the vast number of commands local to a UNIX-like system. /usr/sbin: This directory houses commands that are used only by superuser (root). Such commands include netcfg, sndconfig, linuxconf, and netconf. These commands are critical, and improper use can bring a system to a screeching halt. /var: This directory contains most administrative files, including the log files used by various utilities. These log files are invaluable tools if your system develops a problem. All logins and boots are recorded in this directory. One of the most useful of these files is /var/log/messages. Most of these files are accessible only by root. /boot: This directory contains the kernel and other files used during booting. It is crucial that only the well-versed toy with these files. /etc: This directory contains files used by subsystems, such as networking, network file systems (NFS), and mail. This directory also contains tables of networking services and mountable disks. /opt: This is the directory which contains many applications users will use, and install. This is a simple—not complete—listing. Each distribution adds various directories and files to this basic setup (Table A). TABLE A Windows C: Program files System Start menu E: (CD-ROM) Control Panel Linux / /home/user /usr/sbin and /boot /usr/bin /mnt/cdrom (when mounted) Linuxconf This is a simple side-by-side comparison of the Windows and Linux directories. Again, this is a very minimal comparison, meant only to provide an overview of the comparative structure between Windows and Linux. In Linux, drives fall under a completely different naming system (Table B). TABLE B Windows A: (first floppy drive) B: (second floppy drive) Entire first hard drive C: (first HD partition) D: (second HD partition) E: (CD-ROM) Linux /dev/fd0 /dev/fd1 /dev/hda /dev/hda1 /dev/hda2 /dev/cdrom Linux drive names are quite different than their Windows counterparts. Page 4 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Startup/shutdown Now that you have a basic understanding of the Linux file structure, let's examine how to start your machine. Startup The Linux boot process differs from the very beginning. After the BIOS posts, a Linux native application (named LILO) starts. LILO is a general-purpose boot manager that can boot nearly any type of OS. Typically, LILO will reside on the master boot record (MBR) and will be the first piece of code executed after the BIOS. At the LILO prompt, you can press [Tab] to display the various operating systems available at boot. As previously stated, LILO can boot nearly any type of OS. However, in the case of dual booting between Linux and Windows, the Windows OS must be installed first. (Otherwise, the Windows boot loader will overwrite LILO, and Linux will be unbootable without the aid of a boot disk.) If your machine is configured to dual boot between operating systems with LILO resting on the MBR, simply press [Tab] at the LILO: prompt, and you'll get a listing of the commands to boot each OS. Typically, the commands are as follows: To boot Linux, either press [Enter], or type linux and then press [Enter]. To boot Windows, type dos and press [Enter]. On a properly installed Linux system, the difference in the boot process doesn’t end at the initial load. During the boot process, the various file systems (listed earlier) are mounted, and the boot process stops at either the login prompt or a graphical log in (depending on how you configured the system at installation). When the boot process stops at login, you'll be greeted with either the login: prompt or the GUI. Regardless of whether it's text or graphical, you’ll provide your username (assuming you've set up a user account) and then your password. If this is your first install and you haven't added a user, you will be required to type (at the login prompt) root, followed by the root password you entered during the last phase of the installation process. If your machine is configured for text-based login, once you've logged in as user, you'll see another prompt: [username@localhost username]$ This prompt accepts all the various commands (either essential or nonessential) in Linux. One of these commands is startx, which starts the Linux X Window System. The X Window System is the application that allows the various Linux GUIs to communicate with the OS. The Linux GUI (as a standard Red Hat 6.0 install) has many features found in the Windows 95 environment (Table C). TABLE C Windows Taskbar Start menu Desktop icons Program menu DOS window Mouse pointer Copy/Paste Linux GNOME panel or fvwm2 taskbar GNOME menu or fvwm2 Start button Desktop launchers User menus/Application menus Console terminal Mouse pointer Copy/Paste Many Linux GUI and Windows features are similar. Page 5 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Shutdown The Linux shutdown process is very similar to its Windows counterpart. If the Linux system isn’t shut down properly, the file systems won’t be able to unmount properly, thereby forcing a check during the next boot. This is similar to the event that Windows doesn’t shut down properly and must run ScanDisk. To log out properly, you must go through the main GNOME menu and select Log Out. Once the Log Out option is selected, you will be given another set of options: Log Out, Halt, and Reboot. To shut down the system, choose Halt; to reboot the system, choose Reboot; and to log out, choose Log Out. Another option included on the Log Out screen is Save Current Setup. It is always wise to select this check box so that your desktop will return to its current state upon logout. In order to log out properly from KDE, select Log Out from the main menu, and you will be returned to the command prompt. To reboot from the command prompt, change to the root user (run the su command by typing su and pressing [Enter]) and then provide the root password when prompted. Once you have root access, you will run one of the following commands: To reboot: /sbin/shutdown -r now To shut down: /sbin/shutdown -h now Once the logout process is successfully executed, the OS will begin to unmount the file system and, depending on the option selected, begin the process of shutting down, logging out, or rebooting. Basic file processes Now, let's look at the basic tasks of computing. In Linux, there's almost always more than one way to accomplish a task. In this primer, we’ll deal with both the command-line process and the GUI process. Understand, however, that the command-line mode is much simpler and more efficient, but it’s often not as user-friendly. (You actually have to type!) For the sake of this primer, we'll deal with only the basics: reading files, copying files, deleting files and directories, searching for files and directories, changing a file’s permissions, and renaming files. In Windows, all of these commands are taken care of in a GUI environment. You can perform most of these Windows commands by right-clicking the mouse or using the drag-and-drop operation. To perform the above-mentioned file processes in a console-type Windows environment, the computer must be shut down and restarted in MS-DOS mode. (I purposely do not mention the DOS window due to its inability to function as a true console emulator.) Linux, however, has the power to perform most of these functions in both the console and GUI environments. Why would you want to manage these tasks with the commandline interface when using the GUI is so simple? In console mode, these tasks can take on many arguments and details that the GUI mode (in both operating systems) couldn't possibly handle. Using the command-line interface, you can pipe output to other files (meaning you can take the output from your commands and send it to a file to be analyzed later). You can also move around more quickly and not overwhelm your processor with the load of the GUI. Another benefit to learning the command-line structure is that it allows you to command and control machines remotely. With the help of secure shell (or even the less secure telnet), you can log on to a machine and run commands as if you were sitting in front of that very box. C AND G Throughout the following descriptions, each OS will be listed and each style will be represented with either C (for command line) or G (for GUI). The Windows GUI will often refer to Windows Explorer, and the Linux GUI will often refer to GNOME's GMC (GNOME Midnight Commander). Page 6 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Let's compare the basic manipulation of files. Reading files A key difference between Linux and Windows is the versatility that Linux has in reading files. Linux can read any file, be it binary, hex, text, doc, wpf, and so forth. The list goes on and on. Linux also has a number of different ways in which it can read a file (Table D). TABLE D Windows None Right-click open with (G) Linux less (C) Right-click open with (G) Linux offers different methods of reading a file. The less command allows you to view the contents of just about any file. Let's say you have a .txt file called budget.txt. In order to view the contents of that file, simply type less budget.txt, and the contents of that file will appear on the screen. A word of warning: Typing less budget.txt works only if the file contains 20 lines or less. If the file is longer, you'll have to pipe the command to more. In basic terms, this means you'll add the more argument to the command. By adding more, you'll see the file only one screen at a time. In order to scroll down the listing, press any key to move down a screen. To get out of less, type q for quit. Like Windows, the latest Red Hat Linux has the GUI functionality associated with file manipulation. Within the GNOME menu, there is an application called GMC, which is similar to Windows Explorer. GMC produces the graphical interface to all files on the system. With the graphical interface, you can drag and drop, right-click, and open files. To view the contents of a file in File Manager, right-click the file and select View. This command opens the GNOME file viewer and displays the contents of the file. The GNOME file viewer also enables you to perform string searches within a file, go to a particular line in a file, and make a symbolic link to a file (similar to a Windows shortcut). In the newer releases of Linux (i.e., Red Hat 7.1 and Mandrake 7.2), KDE2 is installed. KDE2 includes the very powerful Konqueror, which is not only a Web browser (and a darn good one at that) but also a file manager. The Konqueror file manager is very flexible and highly configurable—in fact, it can be set up and used exactly like Windows Explorer. There are many other ways to read a file in Linux, including various text editors and word processors. Linux runs three office suites that make any Windows user feel right at home: WordPerfect, StarOffice, and Applixware. WordPerfect surpasses Microsoft Word in the desktop publishing battleground. All three Linux office suites behave exactly as a Windows user would expect them to behave. Surprisingly enough, these applications will remove a great deal of the fear from using Linux. Copying files Copying files in Linux can be either a simple drag-and-drop operation or a few keystrokes away. Not only is the command line for copying a file simple but it's also powerful (Table E). TABLE E Windows None Right-click drag and drop (Explorer) (G) Linux cp (C) [Ctrl] drag and drop (File Manager) (G) Linux offers different methods for copying files. Page 7 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Again, let’s work with our budget.txt file. Suppose the file currently resides in the /home/bob directory and you want to copy it to the /home/bob/work directory. While in the /home/bob directory and at a command prompt, type cp ~/budget.txt ~/work/, and the file budget.txt will be copied from /home/bob to /home/bob/work. And just what does the ~/ mean? Basically, ~/ tells your system that you are in that particular user's home directory. (The user is who you are logged on as.) Using ~/ is merely a way to eliminate keystrokes. If you want to avoid confusion or you don't like to avoid keystrokes, you could type the entire path of both directories (i.e., /home/bob and /home/bob/work). The cp command is not limited to the current working directory. Let's use the same example, but we’ll say you are in the /usr/bin directory. To copy the budget.txt file from the /home/bob directory to the /home/bob/work directory, you'd have to type the entire path of both directories. Even from an obscure directory deep within your system, you could type cp /home/bob/budget.txt /home/bob/work/, and the file would still be copied exactly as commanded. Similar to Windows 9x/Windows NT, Linux is able to copy files with a simple drag-and-drop procedure. To copy files in the GNOME File Manager, hold down [Ctrl], click the left mouse button, and drag the file to where you want it copied. (If you don't press [Ctrl], the file is moved and not copied.) Another easy way to copy files with File Manager is to highlight the file by single clicking, go to the File menu, select Copy, and use the Browse button to select your file's destination. This menu also enables you to open, copy, delete, and move files. Deleting files Deleting files with any of Linux’s graphical file managers such as GMC and Konqueror is similar to deleting files in Windows Explorer; select the file you want deleted and then select File | Delete. You can also delete a file by selecting it and then right-clicking and selecting Delete from the resulting shortcut menu. From the early stages of Linux, the command-line interface has ruled. In order to delete files at the command line, use the rm command. This exquisitely powerful command contains numerous options that make it one of the most flexible methods of removing a file (Table F). TABLE F Windows None Right-click | Delete (Explorer) (G) Linux rm (C) Right-click | Delete (File Manager) (G) There are several ways to delete files in Linux. To remove a file with rm, type (at a command prompt) rm filename, and the file will be deleted. This is the most basic command. Now let's look at some of the options: rm f filename: The force command forces the file's removal, ignoring nonexistent files and never asking for a prompt. rm i filename: The interactive command prompts you before any deletion—a very wise precaution to take when you’re just getting started. Remember, a deleted file in Linux is just that—deleted! rm r directoryname: The recursive command removes the contents of a directory recursively. What actually happens is that the command will dive into a directory and remove its contents and will then exit the directory and remove the directory itself. Be very careful with this command. Should you execute rm rf / (as root), your entire drive will be deleted. rm v filename: The verbose command provides an explanation of everything that’s being done during the deletion. Searching for files Page 8 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. The Windows Find application is quite a powerful tool. Windows Find is relatively fast and accurate, and it's as stable as a Windows application can be. Linux has a variety of options for find—both command-line and GUI (Table G). TABLE G Windows Find (G) None None None None None Linux find (C) whereis (C) locate (C) AfterStep's Find module (G) GNOME search tool (G) KDE find files (G) Linux offers many different ways to search for files. Let's examine the GUI applications first. The applications most similar to Windows Find are the GNOME Search Tool and the KDE Find Files tool. You can find the GNOME Search Tool in the main menu under the Utilities submenu. The KDE Find Files tool is found in the main menu. When the Search Tool window opens, you’ll see two places to input text: The first area tells the application where to start looking, and the second is the name of the file. Beyond the text entry is a very helpful drop-down list of addendums you can use with the find command, such as Don't Search Subdirectories, File Owner, and many others. These addendums expedite the process of searching a large disk. You can also use both search tools to remove files. AfterStep has its own version of the search tool that isn’t as elegant as GNOME's, but it’s just as reliable and efficient. AfterStep's Search tool is located in the Root menu under Modules. When the Search tool opens, you’re greeted with a window containing a single text area. Type the name of the file and select Go, and the program will find the file. It's not as pretty as the GNOME Search Tool, but it’s just as effective. Changing permissions Since the Linux environment is a multiuser environment, it’s necessary to add permissions to the OS for security. Windows requires third-party software to achieve this effect, but it attains only a fraction of Linux's simplicity and security. Permissions dictate who can and cannot read, write, or execute a file (Table H). TABLE H Windows None None None Linux chmod (C) GMC (G) Konqueror (G) Linux offers multiple methods of changing file permissions. Suppose that on your desktop machine at work, you have a document that is critical for you to complete during a given week. However, it is well known throughout the office that one particular joker is fond of hindering your progress. To prevent this from occurring, Linux sets up each user so that he or she declares who can edit the user's files. In our example, the document is called work.doc (notice the standard Word 97 extension that a program such as StarOffice can read and write), and the user is named Chuck. Should Chuck want to keep anyone else from reading or changing work.doc, he would simply set the permissions so that only user (Chuck) can read, write, or execute work.doc. To do this, Chuck types (at a command prompt) chmod 700 work.doc. Let's decipher this command. Page 9 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. You issue the chmod command to change the mode of the file. The next element, 700, is a bit more complex, but once you understand it, it's a real time-saver. There are three types of users you want to think about in Linux: user, group, and other. Each type of user is thought of in octal notation. In other words, think of user in hundreds, group in tens, and other in ones. Each type of permission—read (r), write (w), execute (x)—is given a corresponding number that is related to the type of user assigned (Table I). TABLE I User rwx 400 200 100 Group rwx 40 20 10 Other rwx 421 There are three types of users in Linux. As shown in Table I, each number corresponds to both a permission (read, write, or execute) and a user (user, group, or other). When you decide which permissions you want to assign, you simply add the numbers together to form a command. For group to have only read access, the number is 40. For group to have both read and write access, the number is 60. For group to have complete access, the number is 70. For example, Chuck wants to allow group to read the file work.doc (in addition to the existing permission set detailed above) but not to write to the file. To do this, Chuck would add the number 40 to the first number, so chmod 740 work.doc will allow user total access to the file, but group may only read the file. Let's say that later, Chuck wants to change the permissions to add the write privilege for group. Typing chmod 760 work.doc will do the trick. There's another, easier way to add and remove permissions. With the plus [+] symbol, a user can add or remove r, w , or x permissions to a file. So, to use the above example, chmod g+rw will give group read and write privileges. The command chmod g-rw will remove the privileges. Even simpler is the GUI of GNOME Midnight Commander (GMC). GMC allows you to set permissions using the right-click menu. From the right-click menu, click Properties | Permissions, and you can easily set permissions with the click of a button. It couldn't be any easier. At first, assigning p -user desktop, it may be. But for a business that has many users, permissions can certainly save a great deal of valuable work time and eliminate frustration. Renaming files The command line mv is a very easy-to-use command. Used with move, mv tells the OS, ''I'm moving this file to this location and giving it this name.'' For instance, in order to rename the file work.doc (in the /home/chuck directory) to work-backup.doc, you would type mv /home/chuck/work.doc /home/chuck/workbackup.doc, or even shorter, mv ~/work.doc ~/work-backup.doc (Table J). TABLE J Windows None None Right-click | Rename (G) None Linux mv (C) cp (C) GMC: Right-click file | Properties | Statistics Konqueror: Right-click file | Rename (G) You have several options for renaming files in Linux. Like all good Linux commands, mv comes with a family of flags. However, using mv as a rename command does not require the aid of flags. Note: Using the mv command will remove the original file. It is wise to use the i flag to prevent overwriting important files. Page 10 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. The cp command also acts as a simple renaming command without removing the original. This command is great for making backups. To rename the above-mentioned file, type cp ~/work.doc ~/workbackup.doc, and both files will remain. When using the cp command (like the mv command) to rename files, it's wise to use the i flag to prevent overwriting files. To rename files via the GUI, think of Windows Explorer. GMC enables you to right-click a file and act upon that file in numerous ways. To rename a file with this method, you’d right-click the file, choose Properties, and rename the file in the File Name dialog box. Using removable and nonremovable drives and media Using a drive in Linux is somewhat different than in Windows. In Windows, you can select the drive and view its contents, insert the floppy disk, and save, or you can insert the CD-ROM and install it. Linux, on the other hand, requires a few more steps (at least in most distributions) (Table K). TABLE K Windows None None Linux mount (C) floppy/cdrom icons (G) (GNOME and KDE) Using a drive in Linux is a bit different than in Windows. To many users, the mount command is merely another hurdle in the way of simple computing. Why mount? Why doesn’t Linux recognize the drives (both floppy and CD-ROM) right away? Mounting a drive is a way of telling a system (in very basic terms), "I need to use this device, and I want to read it from this directory." You don't see the true necessity of mount until you are on a networked system where users can share a single drive by simply mounting it (one user at a time). Before we get into the actual mounting commands, we first want to set up the system so that users can mount and umount drives. As root, type linuxconf and scroll down to Filesystem | Access Local Drive. In this configuration tool, you will be able to edit the options of both the CD-ROM and the floppy drives. To edit the /dev/fd0 (floppy) drive, select the name of the drive to open the configuration tool for that particular drive. Under the /dev/fd0 tab, you'll want to do two things: First, you'll tell the system that the type will be vfat. By doing this, your Linux system will automatically read and write to Windows-type disks (thereby retaining their Windows 9x readability). Second, select the Options tab and then click the User Mountable button so that the system does not require root access to mount the floppy drive. Once the floppy is configured, move on to the CD-ROM (/dev/cdrom). Here, you have only one change to make: You must make the file system user mountable. You handle this change in the same way as you would the floppy drive. The mount command also allows you to read many other types of file systems, including the Windows 9x VFAT system and the Windows NT file system. Let's assume that your system has either a Windows partition or drive, as well as a Linux partition or drive. In order for your Linux system to read the Windows partition, you must mount the system to a directory. In our case, we'll first create a directory (for our Windows needs) called win. This directory will be located in the /mnt/ directory. At the command line, type mkdir /mnt/win. Depending on where your Windows partition/drive is located, you'll use certain names for the drive itself. Remember that the Linux naming system varies from the standard Windows naming system. Typically, a Windows partition will lie under either /hda, /hdb, or /hdc. Let's assume that your Windows drive is housed on the same drive as your Linux drive (/had) and was installed prior to the Linux installation. To mount the Windows drive, at the command line type: mount t vfat /dev/hda1 /mnt/win Page 11 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Now, to view or navigate around your Windows directories, cd into /mnt/win95, and you'll be in Windows 9x. Linux is very powerful in that it allows you to copy to and from the Windows drive from Linux—everything is readable. This directory is now treated like a standard Linux drive, and the typical Linux commands will function (including cp, mv, ls, and less). Both GNOME and KDE offer another route to mounting various drives that allows you to mount and unmount drives via the GUI. Both environments create desktop icons for the floppy and CD-ROM drives that mount the respective drives with a single click (KDE) or double-click (GNOME). Once the drive is mounted, you’re greeted with a window that shows the contents of the drive. This window allows you to drag-and-drop and associate an application. To unmount the system using the desktop icons, you must right-click the icon and select Unmount Device. The system will sync, and the drive will unmount. GNOME also allows for the mount applets to be placed on the GNOME Panel. These applets act as simple buttons that you can click to mount and unmount. The applets are better suited to users who will be doing most of their work from the command line, while the icons are designed for the GUI lover. To add these applets, right-click the GNOME Panel and choose Add Applet | Utility | Drive Mount. The default drive applet is for the floppy drive, so when a second applet is added, you must change the properties (by right-clicking) to tell the applet to mount the CD-ROM as opposed to the floppy. REMEMBER TO UNMOUNT When you've finished with the Windows drive or any mountable drive other than the Linux drive, it’s very important to unmount this drive so the system can be shut down properly. Some of the more recent distributions, such as Mandrake 7.2, include a utility called supermount that allows you to access and remove floppy disks and CDs without having to run any of the cumbersome mount commands. This, of course, is unique to some distributions. If you’re interested in this type of functionality, you’ll want to select a distribution that includes this utility. The desktop Let's first take a look at what a Linux desktop is, and then we'll explore the particulars. The basics A Linux GUI-based system has multiple layers that make up its environment. On top of the Linux kernel lays the X Window System. The X Window System acts as a mediator between the desktop GUI and the kernel. According to the X main page: “X Window System server distributes user input to and accepts output requests from various client programs through a variety of different interprocess communication channels.'' On top of the X Window System lies the desktop environment. Two common desktop environments are GNOME and KDE. Finally, on top of the desktop environment lies the window manager (WM). According to the official AfterStep site: “A window manager (briefly) is a program which controls the way various windows interact during an X session.'' There are many Window Managers available, with Linux distributions and from various individuals and companies. All of these are completely configurable environments that allow you to customize the desktop to the limits of your imagination. Like other Linux components many of the Window Managers include source code, which allows customization at a programming level. Page 12 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. In essence, X allows the desktop environment to communicate to the kernel, and the window manager allows the user to communicate to the desktop. By employing these components, Linux contains all of the GUI tools that Windows has set as standard for the desktop GUI user. See Table L for a comparison of the functionalities. TABLE L Windows Taskbar Start button Desktop icons Drag and drop Linux Kpanel (KDE) Panel (GNOME) K button (KDE) Main menu (GNOME) Desktop icons Drag and drop The Linux desktop offers the same functionality as its Windows counterpart, with added stability and efficiency. Now we can compare the two popular desktops mentioned above. KDE KDE has, by default, all of the elements that comprise what is considered the standard desktop environment: Taskbar User menus Clickable icons Configurable window elements Wallpaper and color configurations Launchable applications via the taskbar A clock Like the whole of Linux, these configurations are limited only by the imagination. Let's take a look at the largest visual component of the KDE desktop: the taskbar. Much like its Windows counterpart, the KDE taskbar's most prominent element is the K button, which is the same as the Windows Start Button. The K button is the menu on which most KDE applications can be found. Using this menu, it is possible to conduct the entire Linux session without typing a single command on the command line. This will make most Windows users feel more comfortable if they are migrating to a Linux environment. Let's run through a quick session. This session will assume many of the components have been preconfigured. You want to check your e-mail? Click the K button, go to Internet, and then click Kppd, the Internet dialup connection application. Once kppd has connected to your ISP, again click the K button and choose Internet. This time, click Kmail or Netscape, and you'll be off and running with your e-mail. Kmail is the KDE mail client which is similar to other email clients such as Eudora or Outlook. All applications within the KDE environment are run in a similar fashion. The K menu contains everything you’ll need to run, configure, personalize, shut down, play, browse, find, and control, all with the click of a button. The K menu user-configurable. You'll find the primary tool for configuring the menu within K | Utilities | Menu Editor. This GUI application enables you to create new menu items within the Personal menu entry that you can later add to the panel as clickable buttons. The feel of KDE has brought Linux as close to a Windows-esque environment as possible. Much of this success is brought about with the aid of the K panel. The K panel is a taskbar-like element that rests at the bottom (or top or right or left) of the screen and contains the various menus, buttons, and clocks native to KDE. This panel is highly configurable, going well beyond its Microsoft counterpart. Not only can the K panel contain clickable icons (like Internet Explorer 4, which was added to Windows 95 and was Page 13 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. then added to Windows 98), but it can also be hidden in multiple ways. To hide the K panel, you can take the Microsoft-friendly route of using Autohide or use the KDE default of sliding the panel in and out. The actual desktop space of the K environment is also very similar to its Microsoft counterpart. Clickable icons are easy to use and configure, and they’re much more aesthetic than their counterparts. Adding a new icon is as easy as a right-click: Just select New | Application and then provide the requested information. KDE has the added bonus of being able to add a clickable URL icon or a handy Mailto icon. For example, suppose you have a particular person you e-mail frequently, and you want to be able to send that person an e-mail on a moment's notice. With KDE, this is not a problem. Right-click the desktop area, choose New | Internet Address, give the icon a name (for example, the person's name), click the URL tab, and in the text area, type mailto:EMAILADDRESS (where EMAILADDRESS is the particular address where you wish to send mail). Once the information is complete, click OK. Now every time you click that icon, K mail will open with the recipient's address ready to go. GNOME Like KDE, GNOME contains many of its own unique applications, utilities, and configuration tools found on the GNOME main menu. Sporting the GNOME footprint, the main menu consists of the same menus found in KDE, with the addition of a separate KDE menu entry and another level (fvwm) menu entry. So extensive are these menus that, after months of operation and just plain playing around, there are still many menus I have yet to discover. Again similar to KDE, GNOME's desktop contains clickable icons that simplify your experience even more. Upon installation, the icons are a mix of URLs (mostly Red Hat sites) and the GNOME File Manager (GMC). Adding a new desktop icon is as easy as right-clicking the mouse and adding a new launcher. GNOME has made the task of adding desktop URLs even easier. While in Netscape Navigator, you only have to move the Location button to the desktop using the drag-and-drop operation. This will create an icon that you can double-click to open the browser or right-click to alter the properties (such as the icon itself and the name of the icon). The drag-and-drop operation has also been implemented into GNOME. On the desktop area, dragging a file into a folder is accomplished in the same manner as in Windows. Click the left mouse button and drag the file into the folder. All GNOME applications support drag-and-drop. The GNOME desktop can also be configured as easily as KDE. The desktop can be rendered as close to or as different from Windows as is desired. Desktop configurations Each Linux desktop is as unique as its owner. From the standard out-of-the-box to the fully tweaked and twisted, Linux can please everyone. The standard Linux desktop is sure to satisfy any migratory Windows user because it comes complete with a taskbar, a Start menu, and desktop icons. The fully-configured Linux desktop will certainly please those who like their computing environment tailored exactly to fit their needs and tastes. For example, using a GNOME/AfterStep combination, you can call aterm with transparent windows and with either tint or no tint. For example, the command: aterm -tr -tint yellow -fg white -bg black +sb will call aterm with a transparent background, yellow tint, white text, black highlighting, and a scroll bar. Although this seems like a lot of command typing, you can easily type this in one of the AfterStep menus (or even in a launcher icon in either GNOME or KDE). This option allows you to see the wallpaper behind the window—an awe-inspiring effect indeed. The standard GNOME terminal and the Kconsole can achieve the same effect of transparent windows. Page 14 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Each window manager also allows the integration of various themes into the desktop. A theme, according to David Coulson (of themes.org), is: “...considered to be a script and images which alter the way in which an application, window manager, or toolkit looks, works, and feels.'' Each window manager such as; AfterStep, Sawfish, Enlightenment, Window Maker, IceWM, Blackbox, FVWM2, and KWM, has its own themes, which in turn, all configure the Window Manager to different extremes. The FVWM window manager stands on the lighter side of configuration with backgrounds, title bars, and taskbars, while Enlightenment goes so far as to reshape windows. Each window manager handles its theme installation differently. Some of the higher-end window managers, such as Enlightenment and KWM, have applications that install the themes for the user. Here's a partial listing of resources offering the best help on downloading various window managers and installing predefined desktop themes: themes.org Enlightenment AfterStep FVWM IceWM KDE Window Maker Take a moment to visit these sites. You'll notice how varied the desktops are. This is the very reason why making a head-on comparison of a Linux desktop and a Windows desktop is preposterous. All of the window managers listed above will work in conjunction with Linux, and nearly all of them are interchangeable with the various desktop metaphors (GNOME and KDE, for example). When choosing your window manager, note the resource needs of each. It is a general rule of thumb that FVWM has the smallest resource requirements while Enlightenment has the largest. With a Pentium 100 or less, you would be best to stick with the likes of FVWM. I would rank the window managers from least resource-intensive to most as follows (this is, of course, untested conjecture): FVWM, IceWM, Window Maker, AfterStep, Sawfish, KWM, and finally, Enlightenment. Although this list is untested, after taking a quick look at the various sites, you will likely come to the same conclusion. Each window manager has its own personality and way of doing things. Finding a perfect fit is simply a matter of try-before-you-buy. Program installation To the uninitiated, installing or upgrading an application in Linux is a seemingly insurmountable task. This is far from the truth, of course. One of Windows' strengths is also one of its weaknesses. The amazing user-friendliness of the Windows installation method effectively hides the entire task from you. The closest you get to being involved with an installation on a Windows machine is choosing the directory path and possibly the various packages native to the program being installed. Linux, on the other hand, allows you to work as removed or as hands-on as you choose (Table M). TABLE M Windows Autorun Setup – clickable(G) None Zip Linux None Grpm (GNOME) – Kpackage (KDE) (G) rpm (C) tar and zip Installing and upgrading applications in Linux is a relatively easy task. Page 15 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Let's begin the installation by looking at the packing tools. Windows has the Zip command; Linux has tar and zip. Windows' Zip is simple; Linux's tar can be simple. In Windows, you download a third-party program, usually WinZip or PKZip and usually as a trial version, and run its proprietary GUI to pack and unpack archived applications and files. Linux has two different tools at its disposal: zip and tar. Both tools come with nearly all distributions and are almost always cross-distribution. The biggest difference, and most frightening to the new user, is that Linux uses the command line to pack and unpack files. Although this process is intimidating at first, it quickly becomes second nature and is very versatile. There are also GUI applications for pack and unpack available. Let's work with an imaginary file: this_program-1.1.0.tar.gz. Notice the .gz extension? This extension means that this archive has been compressed to make the file smaller. One very misunderstood fact is that tar does not shrink the size of a package; it merely takes a group of files and/or directories and archives them into one file, hence the term packing. In Linux, when you come across a file that has been zipped, you will want to first unzip the archive. Unzipping, in Linux, is achieved with a simple command. Using our sample file, the command would be: gunzip this_program-1.1.0.tar.gz or gzip –d this_program-1.1.0.tar.gz This command will extract the following file: this_program-1.1.0.tar Now you have the uncompressed archive file that is ready to be unpacked. Unpacking an archive will explode the contents back to their original state. Let's say that this_program-1.1.0.tar, in its unpacked form, has the following structure: The main application folder is named /this_program, and the following files will be housed in the application folder: README: A README file about the program and what it does INSTALL: A README file describing the installation process Fil e_1: An application file file_2: An application file file_3: An application file data_file: A data file this_program: Either the install script (compared to Install.exe in Windows) or the application's run script (compared to This_program.exe in Windows) You will see the contents shown above when you execute the following command on the this_program1.1.0.tar file: tar xvf this_program-1.1.0.tar Yes, there are flags, or arguments, involved in the untarring of an application. The flags shown in the above command are the most common of all the tar flags and mean the following: x tells tar to extract files from the archive. v tell tar to be verbose and display filenames. f tells tar that the file following the flags is the file to unpack. There are many more flags for the tar command. Thirty-one are commonly used, but the above three are the basic flags. These arguments should get you through untarring most of your application files. As stated earlier, tar merely unpacks the files; it does not, however, install the application. That task is left to you. Once the archive is unpacked, the next step is to cd into the newly created directory (in our example, this_program) and poke around to see what's what. In a Windows environment, README files typically tell you where to purchase upgrades or how to contact the company, and occasionally it warns of known installation issues or bugs. Linux README files offer a variety of information, and there is no Page 16 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. standard file. Typically, a README file will contain general information about the application, show how to build (install) the application, explain how to run the program, contain configuration variable/file listings, show the location of source code, and provide author contact information. It's good computing practice to read README files in Linux. Windows README files are generally safe to ignore; Linux README files are not. Now, let’s proceed to the installation. This topic is a bit more difficult to outline because every installation that’s not an RPM is different. Although it would seem that you’d need near-programmer status to install an untarred package, that is not true. Generally, the command configure or the one-two punch of make followed with make install is the standard. However, there are exceptions. Again, this is where the README files come in handy. Even better, if the programmer is smart, he or she will include an INSTALL file that outlines the installation process. Note here a Linux convention is most files, regardless of name, which are in all capital letters should be considered README files. The make command is not an installation command. It is the command to compile an application from the source code. Compiling translates source code into machine-readable binary files. The make command is a convenient front end for compiling. It reads special files that assure the same compiled version each time. When you've untarred an application, what you have done is unpack all the source code for that program. With make, the source code is then translated into something the machine can read. Once the source code is compiled, the command make install takes this process one step further by actually putting the new machine-readable code, or executable, into the default, or user specified location. Once make install has accomplished its mission, return to the README file to find the executable command. Linux does not use .exe files for executable programs; an executable file can have any name. Often, Linux uses wrapper files or shell scripts to execute an application. So, in place of This_program.exe, as in Windows, in the program directory you will see a file called this_program. To run the program type: $ ./this_program In order to assure the program would be executable from anywhere, the new program directory would need to be added to the shell variable PATH. rpm The rpm utility is a very powerful application that allows you to manipulate the installation and removal of any package that has the .rpm extension. Many Linux distributions support the rpm utility. The rpm utility is not limited to the installation and removal of packages. For the developer, rpm can also build. Of course, build is a bit beyond the scope of this document, so I'll stick with install/remove. With the latest distribution releases, rpm has been enhanced with nice GUI front ends. For example, GNOME has gnorpm, and KDE has kpackage. There is one thing you will want to be aware of when getting rpm packages to install onto your system: rpm has many different flavors, and only one will work on your system. A typical Red Hat system uses either the i386.rpm or the i686.rpm format. As long as you pay attention to the following instructions, you don’t need to worry that you may destroy a system with the wrong flavor of rpm package. The fundamental flags for rpm are shown below in Table N. Page 17 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. TABLE N Flag -I -v -h -q -U -R -I Action Install Verbose Print hash marks for progress status Query (ask the system what version of a package is installed) Upgrade List the packages on which this package depends List files in package There are several flags for rpm. Note, you must have root privileges to use rpm. If you attempt to rpm a package as user, you will get an error similar to this: failed to open //var/lib/rpm/packages.rpm error: cannot open //var/lib/rpm/packages.rpm If you see this error, don’t worry. You can su to root and run the command again. Installing with rpm Installing with rpm is a very simple process. There are two ways in which to install: GUI or non-GUI. Let's look at GUI first. To install a package with Kpackage, one of the GUI rpm choices, you have four options: Locate the package you wish to install in kfm (the K file manager) and use the drag-and-drop operation to move it to a working copy of Kpackage. Select a package file in kfm and start a new copy of Kpackage. Use the Open menu items in Kpackage. Select an uninstalled package in the package tree. The simplest methods of installing packages are the first two methods using Kpackage. Here’s how to perform each method: Method 1: With Kpackage, open as root (su to root at a bash prompt and type Kpackage), open a kfm window, and navigate to the package to be installed. Select the file you want to install and use the drag-and-drop operation to move the file into Kpackage. Once the file is in Kpackage, click Install, and the system will run standard dependency checks. If the package passes the dependency checks, Kpackage will install the package. If there are errors, the report will offer feedback. Although this method is not as quick as using the command-line interface, it is certainly easier than remembering all of the flags and arguments. Method 2: Open an su kfm by selecting K | System | File Manager (superuser mode)navigate to the package to be installed, and select it. Kpackage will then proceed through the steps shown above, starting with Click Install. The command-line option for installing rpm packages is much more versatile than the GUI front ends, because rpm is complex and has many options. The fundamentals of rpm, fortunately, are not complex. Let's go back to our this_program example. Suppose you’ve downloaded this_program-1.1.0.i386.rpm and are ready to install it. Here are the basic steps, with the necessary fundamental options. The package you want to install, this_program-1.1.0.i386.rpm, is now located in your home directory. The first step after opening a console is to su to root. As root, you will then issue this command: rpm -ivh this_program-1.1.0.i386.rpm Page 18 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. This line of code says is that you are going to install (i) with verbose (v) output and that you want a printout of hash marks (h) to indicate progress. Now, let's say you already have the above program installed, you want to upgrade to a recently released, newer version. In order to upgrade this program, issue this command: rpm -Uvh this_program-1.1.1.i386.rpm The difference in the –U option indicates you want to upgrade an existing program. Lastly, if you've found a better program, called that_program, that performs the same task as this_program, you will probably want to uninstall this_program. Before you run the rpm -ivh on that_program, you would uninstall this_program using the command: rpm -e this_program The –e option tells rpm to uninstall this_program. Although this method may not seem like the easiest method to use, it is certainly the most efficient. With the command line, it is also possible to rpm an entire group of packages. Let's say you are using GNOME, and you want to take all the upgrades, download them, and install them. Create a directory called gnome and dump all of these packages into that directory, cd into that directory, and then, as root, run the following command: rpm -Uvh *rpm This command will check all dependencies and install all of the packages in the correct order and in the right places. This is truly the most efficient means of upgrading a system. Once all of these packages are upgraded, it is safe to delete the rpm files to save disk space. System configuration Within the Linux environment are many configuration tools that do many different jobs. Some of these tools are all-powerful and encompass nearly every aspect of Linux configuration, while some are limited to only one aspect. Most of the tools you will see are interfaces for script-writing commands, making Linux configuration more point-and-click as opposed to hack-and-save. The tools for Linux configuration, assuming Red Hat Linux, include: linuxconf Xconfigurator XF86setup netconf sndconfig netcfg mouseconfig timeconfig kbdconfig The tools are in order from top down of most functionality to least functionality. All of the above tools must be run as root and should be used with caution. linuxconf The linuxconf utility, is launched by root, but clicking on the icon if it has been created or issuing: # linuxconf Page 19 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. linuxconf allows the administrator to handle all aspects of system configuration, from printers and networks, to adding users. There is no equivalent to linuxconf in Windows. Figures C through H show linuxconf under Red Hat. FIGURE C FIGURE D Once you get below the network configuration, you will see the user accounts and filesystem configurations. The top section of the linuxconf tool holds many of the networking configuration utilities. Page 20 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. FIGURE E FIGURE F Beyond account configuration within linuxconf lies configuration sections for miscellaneous services, peripherals, boot mode, and cluster configuration. On the second linuxconf tab, you will see configuration tools for the various control panel subsets, the mounting and unmounting of filesystems, control files, date/time, and features. Page 21 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. FIGURE G FIGURE H On the Status tab, you can configure the various log files within your system. The final linuxconf tab contains gurus (wizards) that help you configure various services. In linuxconf, the most logical location to begin with is under Users Accounts | Normal | User Accounts. This is where you would add, remove, and edit user accounts. Here, root can edit any of the existing user accounts, add new user accounts to the system, disable user accounts, change the user’s group, change the user’s password, add groups to a user, change the home directory, change the user shell, change the user ID number, change the user mail alias, add mail redirect, and change the user’s privileges. For the new user, the primary benefit of this section of linuxconf will be adding user accounts and changing passwords. Adding a new user with linuxconf is a simple matter of opening the Users Accounts section and clicking Add. Once this section is open, you simply enter the proper information, such as login name and full name. These are the only two required options. There are many other options, but for this discussion simply adding a regular user is what is needed. Once this information is correct, click Accept, which will then take you to the password prompt. A Linux password must meet two requirements: It must be over five characters long, and it must not be based on a word found in the dictionary. Capitalization is your friend: "Coffee” is not a valid Linux password, but "cOfFeE” is valid, as is ”12drinkCoffee.” Use your imagination because it might be your best defense against possible break-ins. It is also important to note that linuxconf offers the ability to change users’ passwords. The regular changing of passwords is a valuable security solution. In linuxconf, changing passwords is very simple: You open the same tab you were just using and click the user whose password you wish to change. Once you’re in the user’s account, click the Passwd button, enter the new password, and then reenter the new password when prompted. In order to enable this change, you must click Act/Changes (for activate changes), which brings up the Status Of The System tab. In this tab, click Activate The Changes. Once you've activated the changes, you can quit linuxconf (by clicking Quit in the main menu and then clicking Page 22 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Quit again in the Status Of The System tab). If you have changed your own password, you will have to exit out of your account and log back in for the change to take effect. Note that it is also possible to change a user password in a terminal window, or in the console. A sample console session for changing a user’s password might look like the following: $ passwd Changing password for fred (current) UNIX password: chump New UNIX password: jarhead BAD PASSWORD: it is based on a dictionary word New UNIX password: chumpzilla BAD PASSWORD: is too similar to the old one New UNIX password: cHuMpZiLlA Retype new UNIX password: cHuMpZiLlA passwd: all authentication tokens updated successfully You should note the password text such as chump and chumpzilla would not be seen, they are normally hidden. They are shown here for illustration. The new password is now in effect. This is a much simpler method of changing a user password than using the GUI. Console Linux is a beast that many new users avoid learning. However, it is to your benefit to familiarize yourself with the basics of console commands and applications. By default the passwd command changes the current user password. As root it is possible to change another user's password. The command to change a user password is: $ passwd <username> root will not need to know the current password for the user, and will be able to assign any password to the user. The next most popular area of linuxconf is the networking sections. The linuxconf application contains many sections that involve networking options. Depending on what type of networking you wish to configure, you may have to visit various sections of linuxconf. The primary sections for basic networking are: Host name and IP network devices, under client tasks: The administrator can set up the host name of the machine; the primary name and domain name; the IP address; the Netmask; the Ethernet device; whether the machine uses Manual; DHCP; or Bootp Network config mode; the I/O port; and the IRQ. These settings are for LAN usage, not dial-up. Special Accounts, under client tasks: The administrator can add or edit PPP, SLIP, or PLIP dialup connections. The setup of this section is very similar to the netcfg application. This section closely resembles the Windows dial up networking application. The linuxconf application goes well beyond dial-up networking, allowing the user to configure LAN, Samba (Windows-to-Linux connectivity), and NFS networking protocols. In addition, linuxconf allows the user to mount various file systems, configure sendmail (not for the weakhearted), server tasks, and many other Linux systems. Windows does not have a comparable over-all administration tool. netconf Launch this command: netconf. The netconf application is simply all of the networking configuration routines from linuxconf included in one package, providing all network configuration tools in one place. Page 23 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. netcfg Launch this command: netcfg. The netcfg application is another network configuration application that adds a few features to netconf. With netcfg, the administrator can configure PPP, SLIP, PLIP, Ethernet, Arcnet, Token Ring, and Pocket (ATP), as well as configure PAP authentication, Nameserver information, and Routing information. What is missing from netcfg is the ability to configure NFS, Samba, and other crucial networking services. Xconfigurator Launch this command: Xconfigurator. The Xconfigurator application gives the user or administrator the ability to configure the X Windows environment in Linux. Before we get into Xconfigurator, let's examine X itself—what it is and what it does. X stands for X Window System, and X does not stand for anything but X. Read this excerpt from www.x.org (the official X Window System site): “History The X Protocol was developed in the mid 1980's amid the need to provide a network transparent graphical user interface primarily for the UNIX operating system. X provides for the display and management of graphical information, much in the same manner as Microsoft's Windows and IBM's Presentation Manager. The key difference is in the structure of the X Protocol. Whereas Windows and Presentation Manager simply display graphical applications local to the PC, the X Protocol distributes the processing of applications by specifying a client-server relationship at the application level. The what to do part of the application is called an X client and is separated from the how to do part, the display, called the X server. X clients typically run on a remote machine which has excess computing power and displays on an X server. The benefit is true client-server and distributed processing. Definition The X Protocol defines a client-server relationship between an application and its display. To meet this the application (called an X client) is divorced from the display (known as the X server). X further provides a common windowing system by specifying both a device dependent and an independent layer, and basing the protocol on an asynchronous network protocol for communication between an X client and X server. In effect, the X Protocol hides the peculiarities of the operating system and the underlying hardware. This masking of architectural and engineering differences simplifies X client development and provides the springboard for the X Window System's high portability.” X Window is a very powerful system and so requires a very powerful configuration application. Xconfigurator is just that—a tool to configure the display properties of your system. The primary configurations accomplished through Xconfigurator are the video card and the monitor. When running Xconfigurator, the administrator needs to know the following information about the system: Video card Type Memory Monitor Refresh rate Resolution Vertical sync range Linux can probe your system to assign default values for color depth and default resolution, and oftentimes it’s best to go with the suggested settings. A big word of warning here: Choosing the wrong Page 24 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. settings in Xconfigurator can do untold damage to your monitor. Use caution! Know your hardware like a good user should. XF86Setup Launch this command: XF86Setup. A braver cousin to Xconfigurator, XF86Setup offers the user a wider array of configuration routines. From mouse to keyboard to video card to video mode to monitor to server settings, XF86Setup extends Xconfigurator’s ability to configure the X Window client while offering a graphical user interface. mouseconfig Launch this command: mouseconfig. The mouseconfig application is a very simple program that allows the user or administrator to configure the type of mouse and whether or not to emulate a three-button mouse. In Linux, the third mouse button is the middle mouse button and is used for pasting from window to window. If you have a two button mouse only, Linux will emulate the third button when the left and right mouse buttons are clicked simultaneously. timeconfig Launch this command: timeconfig. Yet another minimalist configuration tool, timeconfig does one thing and does it well; timeconfig sets the time zone for your system. Believe it or not, there’s a huge repository of possibilities within this tool: countries, states, zones, you name it! There is also one other option—setting the hardware clock to Greenwich Mean Time or GMT. kbdconfig Launch this command: kbdconfig. This simple application allows the user to configure the type of keyboard being used. Most of the options are language options, but a few alternative keyboard layouts are included. Sndconfig Launch this command: sndconfg. The final configuration tool is sndconfig. The sound configuration tool is a bit trickier than what most people are used to because it demands that the user know a bit more information about their sound card. Within this configuration routine, the administrator will need to know such information as type of card, I/O ports, IRQs, and DMAs. Often the application will detect the card, but frequently the detection is in error and so the card won’t work. This tool is only supplied with Red Hat distributions. Configuration files The Linux OS has a keen sense of configuration. In fact, configuration is one of the many aspects that sets Linux apart from all other operating systems. You've heard it said countless times: "Customization of Linux ends with the user’s imagination.” Rarely has such a pithy quote been so true. The Linux desktop is a marvel of customizable wonder. From shapes to colors to sizes, the flexibility of the system is endless. But how is this configuration accomplished? How do the thousands of hackers/users/artists commit those changes to the operating system? One very simple, and global, method is to use a configuration file. A configuration file can take on many forms. Some of these files are resource configuration (.rc) files; some are not. Regardless of nomenclature, the Linux configuration files are a powerful method used to shape your system. Page 25 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Resource configuration files A collection of useful resource configuration files might look like this: .bashrc .procmailrc .xinitrc The above files are hidden files, and each deals with different aspects of the systems. The .bashrc file is the individual per-interactive-shell startup file; .fetchmailrc contains the information your system needs to retrieve mail from your ISP server; .pinrc is the configuration file for the Pine mail system; and .procmailrc is a very powerful file for handling the various routing routines for procmail. Let’s look at the .bashrc file in detail: .bashrc # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi HISTSIZE=50 stty erase "^H" alias AS="cd /usr/share/afterstep/start/" The .bashrc file has long been touted for holding mystical power within the Linux environment. The above .bashrc file is an out-of-the-box, unconfigured file. This example, of course, does not show the power of the .bashrc file. Let's break it down and see just what we can do with .bashrc. The first three lines of this file are comments. Comments are lines of code that do not interact with the system but give the user information about either a line of code or the file itself. The first uncommented line if [ -f /etc/bashrc ]; then . /etc/bashrc fi is an if statement that searches the /etc directory for a .bashrc file. If the system finds a .bashrc file in /etc, it will use that file for the resource configuration. However, if the system does not find /etc/bashrc, then it will then go to the ~/ directory and use the ~`/.bashrc file local to the user. Following the if statement are all of the user-applied configuration files. Of these files, the most useful are history, aliases, and the ever-popular backspace configuration. The line HISTSIZE=50 defines the number of command lines that bash will hold in memory. (You'll see these memorized commands at a bash prompt when you use the up or down arrow.) stty erase "^H" This line from .bashrc can solve a lot of headaches in bash. The Backspace and Delete keys have created much confusion in the Linux community, and with a simple hack of the .bashrc file, each bash prompt you open will bind the erase (or delete) function to the Backspace key (^H). The final line in our .bashrc example offers undoubted relief from typing the myriad of lengthy commands used in Linux. Since my initiation into Linux, I have used the command cd /usr/share/afterstep/start countless times. In order to shorten those keystrokes, I put an alias into my Page 26 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. .bashrc file. An alias, according to Linux in a Nutshell (O'Reilly Publishing: ISBN 1-56592-585-8), "assigns name as the shorthand name, or alias, for command." Let's say for the sake of example that instead of typing cd /usr/share/afterstep/start over and over and over, we want to simply type AS (we can't use as because that is the command to call the GNU assembler). In this case, go to your favorite editor and open that .bashrc file. The alias we are about to enter will go at the end of the file (below the last entry) and will look like this: alias AS='cd /usr/share/afterstep/start' As you can see, creating the alias is as simple as giving the new name a title and setting that title equal to the desired command. .xinitrc According to Running Linux by Matt Walsh (O'Reilly Publishing ISBN: 1-56592-151-8), the .xinitrc file is a "shell script containing X clients to run." The .xinitrc file is located in the user directory /home/USERNAME and is used by X Window to call user-specified programs that are to run as the X Window System boots. When the command startx is run, the X server begins its startup process and runs the commands found in the .xinitrc file. These commands range from calling a desktop environment to calling a window manager, to calling various programs and setting program environments (such as geometry and color). A typical .xinitrc file looks like this: !# /bin/sh aterm -tr -fg white -bg purple -e pine & #to startup pine at X boot /sbin/ifup ppp0 & #to bring up dial-up connection at X boot afterstep & #to start window managers (afterstep) exec gnome-session #to begin desktop environment (gnome) This file is a very basic example of the power of .xinitrc. What you see here, in order of execution, is a call to open pine, followed by a call to start the dial-up process, followed by a call to begin the window manager AfterStep, and finished with a call to begin the GNOME desktop. Take note of the ending ampersand [&] characters. The & following a line in the .bashrc file tells the system to go to the next line and not wait for the application to launch. This is a simple way to make the startx process more efficient. The number of applications that you can begin upon starting X Window (via .xinitrc) is unlimited; however, take note that the more applications called from .xinitrc, the slower the boot process will be. The best philosophy, with regard to .xinitrc, is to call the programs most often used or critical to the system. With this method, the boot process will be more efficient, and X Window will be ready to roll with whatever application you need to run. The addition of the dial-up command (/sbin/ifup ppp0) within .xinitrc is a nice touch and ensures you a connection to your ISP when your GUI begins. .procmailrc For an introduction to the .procmailrc file, read ”All the wonders of procmail, part 1” and “All the wonders of procmail, part 2: Lockfiles and nondelivering recipes.” Primarily, that discussion focused on playing distinct sounds when various e-mails arrived via the procmail routine. For this discussion, we’ll focus on using the .procmailrc file to redirect mail to specific mailboxes. The .procmailrc file begins with the configuration of the user-defined inbox: MAILDIR=$HOME/mail #you'd better make sure it exists DEFAULT=$MAILDIR/linux #completely optional #LOGFILE=$MAILDIR/from #recommended As a refresher, the .procmailrc sound configuration looks like this: Page 27 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. :0: * ^TO.*linux@techrepublic.com.* | cat >> /home/linux/mail/linux ; esdplay ~/sounds/w_strange.wav This code tells the system, “When mail comes into /home/linux/mail/linux and it is addressed to linux@techrepublic.com, play the .wav file w_strange.wav.” This is a very simple method to alert the user when mail has arrived from a certain someone. Let's make this .rc file more useful. Let's say you’re using procmail to retrieve e-mail, and a vast majority of the mail is split up among mailing lists. A simple way to filter those lists is to use procmail to sort them. We'll use redhat-list@redhat.com (the Red Hat mailing list) and gnome-list@gnome.org (the GNOME mailing list) as examples. The first task is to send all of the redhat-list mail to its own folder, which we'll call redhat. :0 ^From.redhat-list@redhat.com redhat And the next example, gnome-list@gnome.org, will filter to its own folder, called gnome: :0 * ^From.gnome-list@gnome.org gnome This particular filtering system can save a great deal of time and effort in the war against digging through tons of mail, as well as getting rid of spam. With the procmail filtering capabilities, it’s possible to toss known spammers into what has been called a killfile. Let's create a little trash compactor for spammers: :0 * ^From.spamers@address.com /dev/null Ker-flush! Above and beyond the resource-configuration files, Linux uses a number of other very important utilities. The X Window configuration relies heavily on a file called .Xdefaults. The .Xdefaults file allows the user to add many (and various) configurations within one source. From aterm to xterm, from Netscape to StarOffice, the .Xdefaults file configures them all. Here’s a sample from .Xdefaults: ! Parts (C) 1996 By Greg J. Badros gjb@cs.duke.edu ! You may use this file as specified under the GNU General Public License !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! emacs, xemacs emacs*Background: DarkSlateGray emacs*Foreground: Wheat emacs*pointerColor: Orchid emacs*cursorColor: Orchid emacs*bitmapIcon: on emacs*font: fixed emacs.geometry: 80x25 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! xterm (and friends) Netscape*background: black Netscape*foreground: green Netscape*troughColor: green Page 28 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Netscape*XfeToolBar*highlightcolor: yellow Netscape*blankBackground: black Netscape*cellBackground: green xosview*background: aterm*scrollBar: aterm*Foreground: aterm*Background: black false #FFFFFF #000000 This segment represents the beginning one-fourth of an .Xdefaults file that has been modified to add Netscape, xosview (a resource monitor), and aterm (a console emulator). One of the more eccentric aspects of the .Xdefaults files is the use of capitalization, which is crucial for any of the configurations to take effect. Take note of the capitalization of the word scrollbar: scrollBar. Without the proper syntax, the X Window System will not pick up on the configuration. The typical setup of the configurations within .Xdefaults is: application*configuration: flag The standard configurations for .Xdefaults are: background (3-D objects), foreground (text), troughColor (scrollbar trough), blankBackground (an empty window), scrollBar (this is a Boolean flag—true or false), cursorColor (color of the cursor when in the window), and geometry (size of window). Many other applications carry program-specific configurations, and they can be found in either that program’s man page or README file. It is also quite possible to add a background image to certain console emulators; rxvt allows the use of .xpm files as background images that can be configured with the .Xdefaults file. The stock .Xdefaults file will not contain any references to rxvt, but putting them in is an easy matter of adding the following entry: rxvt*backgroundPixmap: /path/to/.xpm Note that it’s necessary to implement the .xpm file format for the background image. Configuring the rxvt term to behave with this attribute is an interesting way to add a bit more spice to the desktop. Be warned, however, that this configuration will use up more of your precious resources. The number of resources you can use to configure X Window is limitless. I’ve given you only an introduction to the vast world of user personalization within the Linux desktop. Any time a new application is installed onto a machine, a wise user will look to see if an .rc file has been implemented into the design scheme. If the .rc file has been used, then configuration is a snap. Network configuration A small home network can be assembled with the following hardware: Two computers either preinstalled with Linux or available for a Linux installation. Two network interface cards or NICs. Be sure to check the compatibility of the cards you would like to use before purchasing them. Most Linux distributions recognize most common cards, but some will not work. A common card, the 3c59x will be assumed for this example. One network hub or switch. A switch is helpful to reduce network traffic. Cables to connect both machines to the hub or switch. The installation of this network is a very simple process. To cover all possible scenarios, we will be looking at both a network setup from the very beginning of the OS install and a network setup post-install. Neither method offers any advantage over the other, with the exception that one method already has a jump start on OS configuration and familiarity. This will not, however, be a vehicle for familiarization with the OS itself. I am making the assumption that you have a basic understanding of Linux and can run such applications as telnet, ping, and ftp. Page 29 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Preinstall preparation Very little preparation is necessary for the small home network configuration. Most of the work will be done during the software installation and configuration. However, there is one easy task that might make things go a bit smoother. You should first come up with names for your machines and then assign each name an IP address. The IP address you want to use must be in one of the private ranges, so you'll want to use something like 172.22.X (where X is unique to each machine on the network). Other ranges include 192.168.X.X and 10.0.0.X. Many networking products, such as cable modems and wireless gateways, automatically default to the 192.168.1.X range. Be sure to check with your ISP or broadband provider to avoid any conflicts, or preconfigure required ranges and names. Let's say you have two machines you are planning to network together. One machine you call Buffy and the other you call Angel (please forgive the reference). If Buffy is to be your main machine, then you might want to assign it the 172.22.1.1 IP address and give Angel the 172.22.1.2 IP address. This numbering system is simply for reference sake and makes it easier to remember that your main machine is 1 and your secondary machine is 2. Actually, all this is rather pointless since we’ll eventually have the machines set up in such a way that they will recognize the command ftp Buffy as opposed to needing to remember that Buffy is 172.22.1.1. On to the install The hardware itself is rather easy to install. Typically, these older NICs will be either PCI or ISA slot-type cards and will plug in as simply as a modem. Once the card is in and the machine is reassembled, you can run your cable. It's actually easiest to have the machines side by side for testing purposes—this saves a lot of running up and down stairs or down hallways in order to type ping Buffy or check on a load. So, put the machines side by side, plug in one end of the twisted pair cable, and then prepare your hub or switch. Now you’re ready to run cable to the hub or switch. Installing the hub or switch is a simple matter of plugging in the power and the twisted pair cables, and it is ready to accept data transfer. Depending on whether or not your machines are up and running at this point, you may or may not have signal lights on your hub. Don't worry yet. Occasionally you must tweak the BIOS, to disable PnP if you're using Linux only. Once the cards are installed, the hub or switch is powered up, and all of your cable is run, it's time to configure. The first route that we will discuss is the preinstalled system configuration. Later we will look at configuring a net during install. As mentioned above Linux offers both GUI and character based configuration tools. We'll examine several aspects of both and a combination of the two. The first step in configuring your network is to run netcfg. Most everything you will do in netcfg can be done in linuxconf, as well. Once netcfg is running, the first steps will involve the Interface tab. From the Interface tab, click Add and then Ethernet. Now, do you remember the IP addresses we discussed earlier? Here's where you'll use them. For the new device you are about to configure, you must type the IP address you wish to assign to that particular machine in the IP text area. For instance, you are running netcfg in Buffy you will enter 172.22.1.1 in the IP area. Once you've entered this number, simply tab down, and the other numbers are filled in for you. Next, select both check boxes to allow the interface to activate at boot time and to allow any user to (de)activate the interface. Now you're finished. Click Done and then Save (when the next window pops up). The next step in configuring this simple network involves going back to that all-powerful tool, linuxconf. Page 30 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. What we are going to do is set up a very basic Linux-to-Linux network. Our goal is the ability to ftp, ping, telnet, and perform remote login. Within this setup, we won’t be dealing with NFS or Samba. Eventually, we’ll cover network printing. The first section to focus on in linuxconf is the basic host information. Here, you will more than likely see the information you entered into netcfg. There are some additions to make however. Let's doublecheck our setup. On the first tab in the Host Name And IP Network Devices section, you should see the name you gave the machine—Buffy. If Buffy is not in the hostname box add it here. With the host name correct, move on to the next tab—Adapter 1. In the Adapter 1 tab, you should see all the information for the card you set up in netcfg: Primary name and domain: Buffy; IP Address: 172.22.1.1; Netmask: 255.255.0.0; NetDevice eth0; kernel module: 3c59X. Once all of this information is correct, activate these changes to linuxconf and move on to the first necessary script changes. The files you will be dealing with reside in your /etc directory, and only root can manipulate them. As usual, take caution when working around as root. The files you want to edit are hosts, hosts.allow, hosts.equiv, and hosts.lpd (for printing). The first file, hosts, is a listing of hosts on your network which will translate from the name to the IP address. The first line: 127.0.0.1 localhost is necessary and is the loopback name and number. Do not tamper with this line. Following this line, you will add in the IP addresses and names of all the machines on your network. So, for our example, enter: 172.22.1.1 172.22.1.2 Buffy Angel Once you've typed these entries, save and exit the editor. The next file we must alter is hosts.allow. This file tells your local machine which networked machines have which privileges. More than likely, this file will consist of only approximately five commented lines, meaning that they are not read by the compiler or the application. The line you want to add in hosts.allow is: in.ftpd, telnetd: 172.22.1.1, 172.22.1.2 This tells your machine that both Buffy and Angel have ftp and telnet privileges. It is important to note that this example should be used only for a local network. If your network will interface with the Internet, more secure connections are available with ssh and scp. Both telnet and ftp are considered security risks since user name and password are transmitted as clear text. In order to add a bit of preventive security, set up the hosts.deny file so that outsiders cannot use the services, local to your new network, that could wreak havoc upon your machines. The hosts.deny file is very simple: ALL:ALL This file will keep all outsiders from using either the ftp or telnet daemons. This method is, of course, no replacement for solid firewall or ipchain ruleset; however, it is a quick fix that will keep a minimum of security on your net. Next we add or edit the file called hosts.equiv. This file acts as a secondary checkpoint for your system. When your remote machine attempts to telnet or ftp into the local machine, the local machine makes a check on hosts.allow to see if the machine in question has permission, then it makes a quick stop at hosts.equiv for a secondary check. This file will contain only the name(s) of the remote hosts—in our case, Angel. Page 31 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Once this last file is finished, you will then have to move over to the other machine (we're calling it Angel) and make the same alterations, keeping in mind the correct IP address and the substitution of Buffy for Angel in files like hosts.equiv. The final step is getting the ftp daemon running. By default, this process will not be in the background. The easiest method is to download wu-ftpd . Use an Internet search engine to download the latest version. Most distributions also include a native ftp and telnet daemon. Once the remote machine is properly set up, it's time to test your setup. At this point, depending on your hub or switch, several connection lights are probably lit, indicating working connections between the hub and the NICs. Now, for the test. At a command prompt, type: ping localhost If all is well, you should start seeing something like: 64 bytes from 127.0.0.1: icmp_seq=0 ttl=225 time=0.1 ms repeatedly displayed. If this is working, press [Ctrl]C to escape. Now we'll test the host names. Once again, using ping, type: ping Buffy You should get the same feedback, with the IP address assigned to Buffy. If that's the case, you are connected to your local machine. Escape this process, and we'll try to ping the remote machine: ping Angel should return to you the same output with the IP address assigned to Angel. If so, success! Let's get fancy: telnet Angel If all is well you should be greeted with a login prompt: login: Here you enter the username that exists on the remote machine. You'll then be asked for the username's password. Once you are logged in to that machine, you can move around and run console processes as if you were sitting in front of the machine. Now comes the big test: ftp. At a command prompt, type: ftp Angel If all is well, and the ftp daemon is running correctly, you should be greeted with a name: (Angel:USERNAME): prompt where USERNAME is the username of the machine you are working with. Be aware that ftp can sometimes be flaky. Here, type the username you want to use to log in and, when asked, enter the password for that user. Sometimes ftp will work right off, sometimes not. If the ftp login fails, type user at the prompt and then, when asked, enter the username and the password. You should now be logged into the remote machine via ftp. Should you not be able to ftp into the remote machine, you should first double-check the files that you altered or created. If these all check out, then more than likely the ftp daemon is not running correctly. If this is the case, reboot your machine to get the ftp daemon up and running. From here on out, the ftp daemon should begin running at boot. Page 32 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. As I said, ftp is rather tricky at times. The command-line structure is a bit hard to master (with get and put). Instead of running a tutorial on ftp, I will direct your attention to gftp (in the GNOME environment). With gftp, you can simply go to the Remote section, choose the Connect Manager, fill in the hostname (in our case, Angel), the username, and the password, and click Connect. Once you are logged in to the remote machine, it's all click and move from there. Copying files from machine to machine couldn't be easier. Without gftp (or another front end to the ftp command), you must navigate the command line. Actually, ftp is not horribly difficult to grasp. The command get (when already ftp'd into a machine) “gets” a file from a remote machine to a local machine. The command put takes a file from the local machine and “puts” it onto a remote machine. A command-line ftp transaction, sending a file (thisfile.txt) from Buffy to Angel, would look like this: ftp Angel username: password: USERNAME PASSWORD ftp> put (enter) (local-file) thisfile.txt (enter) (remote-file) thisfile.txt (enter) There are many other aspects of networking we have not touched on. Most of these areas (IP Masquerading, NFS) are a bit more complex and sometimes require kernel manipulations. The nature of this document, however, is a primer, so we'll discuss these topics later. Maintenance Surprisingly enough (and quite unlike its Windows counterpart), Linux requires little-to-no maintenance. In the Windows world, routine maintenance such as defragmenting the hard disk, scanning for viruses, and checking the hard disk is a regular task. The Linux native file system Extension 2, or ext2 for short, was written in such a way that it does not allow the traditional holes that the Microsoft FAT16 and FAT32 file systems allow. The ext2 file system manages to keep all file blocks contiguous so that any time a block of data is placed back into hard disk storage, it is placed next to another file. This system keeps the hard drive from filling up with holes—thus no fragmentation. The Linux ext2 file system has an equivalent to the Windows Scan Disk utility. This equivalent is called file system check (fsck) and is used primarily by the system itself, as a background maintenance tool that keeps blocks of data from duplicating. It also checks for the standard errors on a disk drive. Below is an explanation of fsck. fsck As I said, fsck is a Linux utility used to check and repair the ext2 file system. There are many situations that could arise to call for the invocation of fsck. Such problems include an unclean shutdown of the system (i.e., a power failure) or a system crash. From the fsck man page we find: “fsck is used to check and optionally repair a Linux file system. filesys is either the device name (e.g., /dev/hda1, /dev/sdb2) or the mount point (e.g. /, /usr, /home) for the file system. If this invocation of fsck has several filesystems on different physical disk drives to check, then fsck will try to run them in parallel. This reduces the total amount of time it takes to check all of the filesystems, since fsck takes advantage of the parallelism of multiple disk spindles.” Before we get into outlining fsck's ability to save a file system, let's look at its ability to simply check a system. It is sometimes necessary to check the Linux file systems for consistency. Think of this check as MS-DOS's Scan Disk. The fsck check will run a scan of the entire file structure and report back its Page 33 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. findings. Typically, the findings will only pertain to noncontiguous, or fragmented blocks of data. There can, of course, be other errors: bad or duplicate blocks, incorrect block count, Inode bitmap differences, and incorrect Inode counts. In order to run a check on your system close the window manager and log into the console as root, or open a terminal window, and su to root. As root, you will have to run a check on an already mounted file system; if any errors are found (and corrected), you will have to reboot the system. You will receive a nasty warning message when attempting this check, so don’t proceed if you are afraid of disabling a critical system. Generally there should be no problems with this check; however, there are exceptions to every rule. Execute this command: /sbin/fsck -t ext2 /dev/hda5 and you will begin the following session: Parallelizing fsck version 1.14 (9-Jan-1999) e2fsck 1.14, 9-Jan-1999 for EXT2 FS 0.5b, 95/08/09 /dev/hda5 is mounted. ####WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage.### Do you really want to continue (y/n)? yes /dev/hda5 was not cleanly unmounted, check forced. Pass 1: Checking inodes, blocks, and sizes Deleted inode 164077 has zero dtime. Fix<y>? yes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information Block bitmap differences: -2071 -2072 -2073 -2074 -2075 -2076 -2077 -91734 -91735 91736 -91737 -91827 -91828 -91829 -91830 -91831 -91832 -93664 -93665 -93666 -93667 93668 -656772 -656773 -656774 -656775 -656776 -656777 -656778 -2205683 -2205684 2205685 -2205686 -2205687 -2205688 -2205689 -2426413 -2426414 -2426415 –2426416 Fix<y>? yes Free blocks count wrong for group #0 (5814, counted=5821). Fix<y>? yes Free blocks count wrong for group #11 (5895, counted=5910). Fix<y>? yes Free blocks count wrong for group #80 (0, counted=7). Fix<y>? yes Free blocks count wrong for group #269 (6200, counted=6207). Fix<y>? yes Free blocks count wrong for group #296 (6, counted=10). Fix<y>? yes Free blocks count wrong (1005747, counted=1005787). Fix<y>? yes Inode bitmap differences: -164077 Fix<y>? yes Free inodes count wrong for group #80 (1809, counted=1810). Fix<y>? yes Free inodes count wrong (673732, counted=673733). Fix<y>? yes Once this check has run (the above check ran into some errors), you will be given a report such as: /dev/hda5: ***** FILE SYSTEM WAS MODIFIED ***** /dev/hda5: 88123/761856 files (1.5% non-contiguous), 2038341/3044128 blocks If you receive the File System Was Modified report, it is crucial that you reboot the machine. Once you reboot the machine it is a good idea to run fsck again, to be sure all errors have been found. Page 34 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. You can run this type of check on a regular basis, but is not necessary to do so. One of the ways in which Linux is smarter than many other operating systems is that it allows only so many boots before it forces this check upon the system. Once you have reached that limit, you will get a message like Maximum Mount Count Reached, Check Forced. This is standard operating procedure and should be allowed to run its course. But what if you run into a problem and you cannot boot your system? Generally with these problems, if they are block errors, you will be prompted to log in as root and manually run a check. The warning, however, does not give you all the gory details. Although the first check you should run is a standard check (simply type fsck as root), it’s important—and sometimes imperative—to run an interactive check as we did above. An interactive check allows the administrator to answer questions in order to fix any problems. However, by running the standard check, fsck, the system will report back if there are any block-type errors that are in need of repair. Should there be block-type errors, you can then run the interactive check to take care of any problems. Viruses While Windows is a victim of countless viruses, Linux rarely experiences them. It’s very difficult for a virus to be effective in such an environment because of the likely need for root access. There are a many files—critical files—that only root has both read and write access to and a virus running under a regular user account would not be able to alter them. Needing root access is not the only hurdle for the proliferation of a Linux virus. The primary transportation method of viruses is in either macro or executable form via e-mail. Since Linux does not use .exe files and the macro languages are not compatible with it, the spread of the common virus is even less of a hazard. As with Windows, proper security, and regular backup are good ways to minimize the damage caused by a virus. Help systems Since Linux is an Open System OS, help systems are abundant. The primary help systems in Linux come in the form of man pages, How-tos, and the Linux Documentation Project (Table O). TABLE O Windows Help files Linux Man pages How-tos Linux Documentation Project There are multiple Linux help systems. Man pages Man pages are to Linux what help files are to Windows—but with a twist. Most programs that are installed onto Linux include what is called a man page (manual page). In truth, man is a program that formats and displays the online manual pages. From the man man page (you read that correctly): “This version knows about the MANPATH and (MAN)PAGER environment variables, so you can have your own set(s) of personal man pages and choose whatever program you would like to display the formatted pages. If section is specified, man only looks in that section of the manual. You may also specify the order to search the sections for entries and which preprocessors to run on the source files via Page 35 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. command-line option or environment variables. If name contains a /, then it is first tried as a filename, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz.” The man pages are somewhat of a philosophy on their own. All man pages are set up with the same information: Name: The name of the command/application/program Synopsis: How the command or application is invoked Description: A brief description of the command/application/program Options: Command flags and arguments that can be passed to the command/application/program Author: The writer of the man page Files: Related files (related to the command/application/program) See Also: Related applications/man pages One thing to keep in mind is that man pages are typically set up by and for those who write and develop for the Linux OS. Because of this, the files seem rather cryptic. Without some knowledge of flags, arguments, and command-line structures, the man pages will seem rather useless to the uninitiated. The man pages, however, are a very simple beast to tame. The primary hurdle for understanding man pages is knowing when to use them. The best reason for using man pages is not learning the rudiments or fundamentals of a command/application/program, but exploring the details of an application. For instance, instead of learning how to use the command fsck, a user would read man fsck to learn the details of the command arguments and flags. When examining the man page for fsck, the user learns about such arguments as these: -R: When checking all file systems with the A flag, skip the root file system (in case it's already mounted as read-write). -T: Don't show the title on startup. -N: Don't execute; just show what would be done. -P: When the A flag is set, check the root file system in parallel with the other file systems. This is not safe to do, since if the root file system is in doubt, files like the e2fsck980 executable might be corrupted. This option is mainly provided for those systems administrators who don't want to repartition the root file system to be small and compact (which is really the right solution). -s: Serialize fsck operations. This is a good idea if you are checking multiple file systems and the checkers are in an interactive mode. Note: e2fsck(8) runs in an interactive mode by default. To make e2fsck(8) run in a noninteractive mode, you must either specify the \p or \a option if you wish for errors to be corrected automatically or the \n option if you do not. -V: Produce verbose output, including all file system-specific commands that are executed. Of course, in order to use these flags, you must know how to run the basic command itself. At the beginning of the man page, you see the following: SYNOPSIS fsck [ -AVRTNP ] [ -s ] [ -t fstype ] [ fs-options ] filesys [ ... ] This explanation provides a map of how to use the command and the various arguments and switches. Here’s the breakdown: fsck: This is the actual command. [ -AVRTNP]: These are the main options for the command. Generally a minimum of one option is required. [ -s ]: This represents the secondary options. These are typically optional. [ -t fstype]: The t option is set up for describing a type of file system (such as when mounting a system). [ fs -options]: This is yet another optional argument. In this case, it defines whether the fsck session will be either automatic (-a) or interactive (-r). Page 36 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Each command will have a different command/argument setup because of the varying nature of the command structures. Fortunately, the man pages are all set up in the same manner. If you have a basic understanding of how the Linux command line works, the man pages are a snap to translate into a useable form. How-tos Linux has come a long way, and a big part of that evolution is due in part to the Linux How-tos. The Linux How-tos are a large set of documents that hold the single purpose of enlightening and educating the general public about Linux and about many of the operating system’s common problems. The main complaint about many of the How-tos is that they are out of date. The problem with this system is that a majority of the documents were created as Linux was putting down its roots; hence, there are a great many references to 1.x kernels or pre-5 releases of many distributions. This datedness of the material does not mean that it has worn out its welcome. Quite the opposite is true. A vast portion of the Linux How-tos have stood the test of time and their relevance is still strong. The Linux How-tos can be found on many Web sites and come in two different types: How-tos and mini How-tos. The regular How-tos are generally longer, more detailed articles that cover more complex topics such as: 3Dfx-HOWTO: How to use 3Dfx graphics accelerator chip support AX25-HOWTO: How to configure AX25 networking for Linux Access-HOWTO: How to use adaptive technology with Linux Alpha-HOWTO: Overview of Alpha systems and processors Assembly-HOWTO: Information on programming in x86 assembly Bash-Prompt-HOWTO: Creating and controlling terminal and xterm prompts Belgian-HOWTO: Information on using Linux with Belgian-specific features Benchmarking-HOWTO: How to do basic benchmarking Beowulf-HOWTO: Introduces the Beowulf Supercomputer architecture and provides background information on parallel programming BootPrompt-HOWTO: List of boot time arguments and overview of booting software Bootdisk-HOWTO: How to create a boot/root maintenance disk for Linux Busmouse-HOWTO: Information on bus-mouse compatibility with Linux The mini How-tos are a group of topics that can be dealt with in a much more expedient fashion. The range of topics includes: Three-Button-Mouse: How to configure your mouse to use three buttons ADSL: Asymmetric Digital Subscriber Loop (ADSL), a new high-speed digital access line technology ADSM-Backup: How to install and use the ADSM backup program AI-Alife: Information about AI software for Linux Advocacy: Suggestions on how to advocate the use of Linux Alsa-sound: Describes the installation of the Alsa sound drivers for Linux Apache+SSL+PHP+fp: How to build a multipurpose Web server Automount: Describes the autofs automounter, shows how to configure it, and points out some problems to avoid Backup-With-MSDOS: How to back up Linux machines with MS-DOS Battery-Powered: How to reduce a Linux system's power consumption Often, How-tos and Mini-How-tos can be downloaded for offline browsing and reference. Page 37 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. The Linux Documentation Project The Linux Documentation Project (LDP) has become one of the largest documentation projects to date. The LDP is dedicated solely to documenting the Linux OS, attempting to keep the How-tos up-to-date and keep the users as informed as possible. The primary feature of this site is its compilation of the various help systems for Linux. At the LDP, you can read the man pages, How-tos, FAQs, and the Linux Gazette all in one sitting. The biggest problem with this particular site is its scope. At first glance, the uninitiated user is overwhelmed by a barrage of text and hyperlinks. This is unfortunate for the new Windows convert, who is used to buttons and bars. The other drawback to the site is the lack of a search engine. Regardless of its drawbacks, the LDP is a massive undertaking that acts as the single largest repository of Linux information. Other help systems As with any computer technology, numerous help systems are available for Linux. There are Web sites, books, newsgroups, mailing lists, Linux User Groups (known as LUGs), magazines, and software designed to aid the user. Take your pick of what is right for you. Just be cautious that the information you’re getting is current and that you aren’t being told to use kernel 2.0.x or any GNOME releases prior to 1.0.41. Conclusion This primer was meant to be an introduction to the Linux OS. Although there is much more to know, you should now have a foundation of knowledge about Linux. Page 38 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. Related TechRepublic resources: TechRepublic books and CDs: Quick Reference: Linux Commands Quick Guide: Network Security Policy Quick Guide: Network Auditing Downloads: Point & Click Linux!: Dipping a toe into the command-line waters Make Linux act like DOS with these shell scripts Linux Commands Articles and columns: Ready for prime time: Linux is now hassle-free and enterprise-ready Tech Tip: Set up RAID in Linux with mdadm Evaluate a switch to Linux with these resources Page 39 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html. TechRepublic: The collective voice of IT professionals TechRepublic communities engage IT professionals in the ultimate peer-to-peer experience, providing actionable information, tools, and services to help members get their jobs done. TechRepublic serves the needs of the professionals representing all segments of the IT industry, offering information and tools for IT decision support and professional advice by topic. TechRepublic site features Free e-newsletters: Keep up-to-date on any aspect of the IT industry with e-newsletters—from tech stocks to daily software tips, from IT careers to hot trends—delivered right to your e-mail Inbox. Free downloads: We've collected resources to make your job easier, including ready-to-use IT forms and templates, checklists, tools, executables, Gartner product analyses, and white papers. TechRepublic's books and CDs: Find the latest books and CDs about today's critical IT topics, including PC troubleshooting, VPN, TCP/IP, Windows client and server issues, and Cisco administration. Discussion center: Open a discussion thread on any article or column or jump into preselected topics: career, technology, management, and miscellaneous. The fully searchable Discussion Center brings you the hottest discussions and threads and allows you to sort them by topic. Our online IT community provides real-world solutions and the latest articles, resources, and discussions affecting frontline IT pros. Get access to more than 250 full-text IT books, along with exclusive downloads and in-depth articles on network and system administration, PC troubleshooting, help desk and support issues, and more. Page 40 Copyright ©2004 CNET Networks, Inc. All rights reserved. To see more downloads and get your free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html.