In this edition of Newbies, we're going to talk about a number of administrative tasks that are essential for getting the most out your new Linux system. While some distributions do have slightly different administrative tools available, most versions of Linux are pretty much the same under the hood.
In this edition of Newbies, we’re going to talk about a number of administrative tasks that are essential for getting the most out your new Linux system. While some distributions do have slightly different administrative tools available, most versions of Linux are pretty much the same under the hood.
Red Hat 6.0, for example, offers a number of improvements to the Linux desktop environment, but the majority of the tools discussed in this article are available in Red Hat 5.2 and most other popular Linux distributions.
Adding User Accounts
Though you normally login to your Linux machine with your username and password, you can also login as “root.” During the installation process, a root account and password was created on your Linux system. This is also known as the “superuser” account, because whomever is logged in as root is able to read from or write to any file on the computer. For reasons I’ll explain in a moment, you need to be logged in as root to have the complete level of access and control required to do some administrative tasks. You’ll need to be logged in as root to do everything I describe in this column.
Now I don’t recommend that you login as root on a regular basis. Even the most experienced Linux user can make a mistake, after all, and when you’re logged in as root, mistakes can have some unfortunate consequences. Linux tends to assume that whoever is using the root account knows what they’re doing and means what they say. So, if you’re logged in as root and you tell your system to delete a directory, it does so — without asking, without checking, without any sort of verification whatsoever. It’s possible for you to do enough damage as root that you will not be able to recover your system without doing a full reinstall of Linux.
Since you don’t want to use the root account for most of the things you do on your computer, you will have to set up other, less privileged, accounts. It is possible that a user account was set up for you as part of the installation, but if it wasn’t, you’ll need to add one at this point. You will also need to add a user accountfor each person who willbe using the system. Of course, to dothis you’ll have to be logged in as root.
The simplest way to add user accounts is with the linuxconf (Linux Configuration) utility. Logged in as root, you can access linuxconf either through the control panel or from the command prompt.
From the GNOME desktop press thelarge GNOME “launcher” button at the bottom left of the task bar. Under the “System” selection you should find entries for both “Control-panel” and for “linuxconf.” With KDE you can bypass linuxconf completely. Press the large “KDE” launcher button at the bottom left. There, under the “System” selection is a tool named “User Manager.” This tool will prompt you for all the needed information.
|FIGURE 1: The Control Panel.|
If you can’t find the control panel (Figure 1), you can start the linuxconf utility froma command prompt. One of the easiest ways to get to the command prompt is by opening an X terminal, or “X term”. To start an X term, search through the menus that are available on your desktop (check in the “utilities” submenu if there is one). The menu option you’re looking for
is probably called “X term” or “termi-nal” or something similar. When you select the proper option, a window should open that displays a command prompt.
Type linuxconf & at the prompt, and press enter. A new window will open, displaying the linuxconf utility.
Once linuxconf is started, adding a new user is simple. First, you have to find the “User accounts” sub-menu in the left-hand pane of the linuxconfwindow. If you can’t see it, expand the “Config” menu. Below that will be a submenu called “Users accounts” (note the extra “s” in “Users.” This is not the “User account” submenu you are looking for). Under “Users accounts”, expand the “Normal” submenu. The “User accounts” entry will be in the “Normal” submenu. Click on “User accounts”, and the right hand side of the linuxconf window will display a list of the user accounts that aleady exist (see Figure 2).
|FIGURE 2: The linuxconf window.|
You might be surprised to see that there are already a number of user accounts on your system. Don’t be alarmed. Most of these accounts are created during the Linux installation process, and exist for things like your ftp server and Web server. Don’t delete these accounts, because they are required for the normal operation of your Linux system. For the most part, however, you won’t have to deal with these accounts, so don’t worry about them at the moment.
Beneath the list of existing user accounts, you will see an “Add” button. As you might suspect, this is how you start adding new users to your system. Press the “Add” button, and the right hand side of the window will change to display a form (Figure 3). To add a new user, fill in the two “required” fields (“login name” and “full name”), then press the “Accept” button.
|FIGURE 3: The user account creation form.|
You will now be prompted to enter a password for the new account. Enter a password in the “New user password” field. The password you type in will not be shown. Instead, a series of asterisks will appear in the field. Click the “Accept” button when you have finished typing the password. To ensure that you didn’t make a typo, you’ll be asked to enter the password a second time. Do this, click “Accept” again, et voila! you have now added a new user to your Linux system. Follow this procedure to add as many new user accounts as you like, then click “Quit.” Then activate the changes when you are prompted to do so, and you’re done.
The Word on Passwords
Choosing good passwords for the accounts on your Linux system is extremely important. When it comes to system security, passwords are the first line of defense in stopping unauthorized people from accessing your system. Be sure not to underestimate the value of a well-chosen password, and try to ensure that all the people who use your system understand this as well.
When you assign a password to a new account, you should make it memorable enough that it doesn’t need to be written down, but it should also be difficult to guess. Obvious passwords like birthdates, significant others’ names, and nicknames should not be used. Linux actually imposes some restrictions on the passwords that you can assign to new accounts. For example, you cannot have a password that can be found in a dictionary.
The best passwords have eight or more characters and are a mix of lowercase and uppercase letters, numerals, and punctuation marks. For example, “Fo0B @rbAz” would be a good (although difficult to remember) password, because it’s difficult to guess andit doesn’t appear in any dictionary that I know of.
When you’re logged in as a regular user, you have much more limited privileges than you have as “root.” This means that you can muck about all you want with much (much) less chance of doing any irreparable damage to your system. This is especially important when you’re a newcomer to the Linux world, because you will (I guarantee) make a couple of mistakes. Even the most seasoned Linux administrators make mistakes. It’s just part of the territory.
As the old joke goes, “If you sit a monkey in front of a computer, the first thing he’ll type is a Linux command.” There are literally thousands of Linux commands that you can issue at a command prompt, many of which are pretty obscure. Luckily, you won’t have to learn thousands. In fact, you won’t have to learn a fraction of those thousands. For now, six will get you started.
When you want to turn off or reboot your Linux system, you should not just hit the on/off switch and hope for the best. Like most operating systems, Linux should be allowed to go through a proper shutdown procedure. There’s a lot of stuff going on behind the scenes when your Linux system is running, and it’s important that these behind the scenes tasks are allowed to finish what they’re doing and shut down gracefully. So, while you can just hit the power button to turn your Linux machine off, you should avoid doing this unless it’s absolutely necessary.
Fortunately the new window environments like KDE and GNOME offer you another way to shut down your computer. Move your cursor outside of any application windows on your desktop and right-click your mouse. One of the options you will see will be “logout.” Choosing this will get you out of your window-like interface to Linux. If you have your computer set up to start up right into KDE or GNOME then you’ll see the “Welcome” (or “login”) screen, with its “shutdown” and “reboot” options. Otherwise, you’ll be put into the command prompt.
You can shut down your Linux machine down by using the shutdown command, issued at a command prompt. To do this, log into your system as root, launch an X terminal, and type the following on the command line:
The -h is short for “halt.” If you use -h, your system will shut down and stay shut down. If you want the system to shut down and then start up again, use -r (short for “reboot”) instead of -h.
When you’re logged into your system as a regular user (i.e. not as root), there will be times when you will want to temporarily get administrator access to do things such as install new software packages, or to do other administrative work. Rather than logging out and then logging back into your system as root, you can use the su command to switch your user identity within an X terminal window.
Launch an X terminal and issue the following command at the command prompt:
This will log you in as root within that window. Enter the root password when prompted. The next command prompt that appears shows that you are logged in as root. While in that window, you can execute any command as root.
When you want to stop using the root account, simply type exit at the command prompt. This will not close the X term, but it will switch it back so you’re no longer logged in as root in that window. Typing exit again will close the X term.
You can use the su command to become any user on your system, assuming that you know the password for that user’s account. For example, if you wanted to do things on your system as bob, you would use the following command:
Enter bob’s password when prompted, and you’ll be logged in as bob within that X terminal. Anything you do within that X terminal will be done as user “bob” rather than as you.
man and xman
One command that you, as a new user, will learn to know and love is man. man is short for “manual,” and you use it to access the handy built-in Linux help resource known as the manual pages. You can use the man command to display the manual page for the vast majority of Linux commands. For example, typing the following command at the command prompt will display the manual page for the su command:
If the man page contains more than one screen of information, you can advance to the next screen by pressing the space bar. Use the up and down arrow keys to scroll the man page up and down. To exit the man page, press the q key.
Unfortunately, Linux man pages are generally written as references rather than as tools for learning Linux. As a result, they tend to be pretty technical and concise. While it’s possible to learn all sorts of stuff about Linux through the man pages, reading through a beginner-level Linux book is probably a more effective, more efficient, and less frustrating way to learn the Linux basics.
The xman command, issued at a command prompt, will launch a manual page browser. The man page browser is currently a pretty crude tool, but it is a good way for you to see what the various Linux commands are and what they do.
In Microsoft Windows, a hard drive is either installed or it isn’t. Linux, on the other hand, lets you mount disk partitions while the computer is running. The default KDE desktop contains icons labeled “CDROM” and “FLOPPY”. If you click once on these icons with the left mouse button then a “file browser” pops up, and your CD-ROM or floppy disk is automatically mounted for you. When you’re finished you can “right click” on the cdrom icon to unmount the device. Note that you won’t be able to eject the cdrom as long as it is mounted.
The GNOME desktop doesn’t yet offer an icon like this to automatically mount and unmount CD-ROMs or floppies. Stay tuned however, GNOME is fairly new and is developing very rapidly.
Under normal circumstances, the mount command can only be executed by root. In my dual-boot computer, I use /dev/hda1 as my DOS partition, which is where Windows is installed and runs. The Linux partition is /dev/ hda2, and this is where Linux is installed and runs. If I want to, I can access the contents of /dev/hda1 (the DOS partition) from Linux by using the mount command:
Note that this command assumes that there is a /mnt/dos directory as part of my Linux filesystem. If you don’t have this directory, you’ll have to create one (see below).
Once /dev/hda1 is mounted, I can access the contents of that drive as part of the normal Linux filesystem. For example, I can switch to the /mnt/ dos directory and view it’s contents. After the partition is mounted, the fact that it’s actually a separate partition is irrelevant. For all intents and purposes, it simply acts as if it were just another directory.
If you’re paranoid (like I tend to be), you can mount disk partitions in “read only” mode by using the -o ro option at the tail end of the mount command:
This will ensure that you won’t accidentally mess up anything on the /dev/hda1 partition when you’re accessing it under Linux.
If you want to access the contents of a cd-rom, you will also use mount:
mount /dev/cdrom /mnt/cdrom
Or to access a floppy disk:
mount /dev/fd0 /mnt/floppy
In this command, fd0 is short for “floppy drive zero.” If you had a second floppy drive, it would be fd1, a third would be fd2, and so on. Remember that in the Linux world people tend to start counting at zero.
/mnt/cdrom and /mnt/floppy are standard directories that are automatically created by most Linux distributions. These directories are intended to be used with the mount command for this very purpose.
Mounting a Partition
If you want, you can have your Linux system automatically mount a disk partition when it boots. This is done in the /etc/fstab file. First, you must create a directory where the partition will be mounted, using the mkdir command. For example, I’ll create a directory called /dos where I will have my Linux system automatically mount my DOS partition:
Then, as root, I add the following line to the /etc/fstab file, using my favorite text editor:
/dev/hda1 /dos msdos defaults 0 0
The next time I boot my Linux system, the /dev/hda1 partition will be automatically mounted at the /dos directory. If I wanted the partition automatically mounted as “read only,” I would replace defaults with ro in the line I added to the /etc/fstab file.
When a partition is mounted, it is available to any user on your system, assuming that the user has permissions to the directory where that partition is mounted. If I mount /dev/ hda1 as root, for example, I can access it from my non-root user account.
|FIGURE 4A: The GNOME file manager.|
There are a number of graphical tools that you can use to browse your Linux filesystem. One, available if you’re using the GNOME desktop environment, is the “GNOME File Manager,” (Figure 4A) which you can access through the main GNOME menu.
KDE also has its own very useful file browser (Figure 4B). Look for an icon on your desktop or on the “taskbar” at the bottom of the screen that looks like a file folder. It may be called “HOME.”
Another is “xfm,” which you can launch from a command prompt by typing xfm &.
All of these tools allow you to view the contents of the various directories on your computer in much the same way that the “Windows Explorer” tool allows you to view the contents of a Windows-based system.
|FIGURE 4B: The KDE file manager.|
Log into your normal user account and launch one of the graphical file managers. Use it to browse around your file system, just to learn how the file system is arranged, and what it contains. You probably won’t know what the majority of the files and directories are for, but don’t worry about that for now. You’ll learn about most of it as you become more comfortable and familiar with your Linux machine.
You’ll notice that there are some directories you aren’t allowed to access when browsing your system as a regular user. As root you would be able to browse any part of your system, but for now it’s best that you poke around without the full suite of root privileges. As we discussed before, you can make some pretty complicated mistakes when you’re messing around using the root account.
For now, you should take the time to poke around and explore your Linux system. Play with the man pages and sniff around your filesystem a little bit. Linux is a strange and exciting world, and you’ll find that the more you learn about the operating system, the easier it all becomes.
Hal Moroff has been developing Unix systems and applications for 20+ years. He’s new enough to Linux that he’s finding new things every day. He can be reached at firstname.lastname@example.org.