Next Up Previous Contents Index
Basic System Tasks

6.2 Basic System Tasks

Remember when everyone upgraded from Windows 3.1 to Windows 95? For a while, people scrambled to figure out how to do the same things under '95 that they had done for a years under 3.x. It's no different here. If you have experience with other operating systems, but not with Linux, you'll need to adjust to different ways of doing things. Some tasks may be similar, some may be entirely different, and some may have no equivalent to anything you've ever done before.

Let's start by going through a few of the more common tasks.

6.2.1 Booting Your Red Hat Linux System

The process required to get your computer running Red Hat Linux may vary a bit from what you're used to. If you have no other operating system installed on your computer, just apply power, and wait. You'll see the computer pause for a moment while it says something about ``LILO'', but it should continue, displaying all sorts of strange messages.

However, if you are sharing your computer between Red Hat Linux and another operating system, you may have one of the following tasks to perform:

6.2.2 Logging In, Logging Out

After Red Hat Linux boots, you'll see something similar to this on your screen:

Red Hat Linux release 5.1 (Manhattan)
Kernel 2.0.34 on an i586
login: 

As you might guess from the last line, it's time to log in...

6.2.2.1 Logging In

The first time you log into your Red Hat Linux system, you'll have to log in as ``root''. This is the name of the user account that has full access to everything on the system. Normally, the root account is only used when performing system administration tasks, such as creating new user accounts, shutting down the system, etc. That's because root's unrestricted access can wreak havoc if you enter the wrong command. So be careful when logged in as root, and use the root account only when needed!

To log in, enter root at the login: prompt. Press the [Enter] (or [Return]) key. A Password: prompt should appear. Type the same password you entered back in Section 5.7, pressing [Enter] when done. You should then see something like this:

[root@bigdog /root]#

Congratulations! You've successfully logged in! Next, it's time to learn how to log out.

6.2.2.2 Logging Out

When you're done using your Red Hat Linux system, you should log out. Although many shells have a logout command, most people simply type [Ctrl]-[D]. This should return you to the login prompt you first saw when you booted your Red Hat Linux system.

Please Note: If you're using the X Window System, your log out procedure will be different, depending on how you've started X. We'll cover this in more detail later.

Now that you know how to log in and out, let's move on...

6.2.3 Accounts and Passwords

As we mentioned earlier, it's a bad idea to use the root account all the time. Inevitably, you'll end up making a mistake, and the access checks that normally protect you won't be there.

Well, if you're not supposed to log in as root, who exactly are you supposed to log in as?

Yourself, of course.

But to do that, you'll need to know how to add user accounts to your Red Hat Linux system.

6.2.3.1 Accounts

As it turns out, there are several different ways of creating new accounts. We'll use the most basic method; the useradd command. Basically, all you need to enter (as root, remember!) is:

[root@bigdog /root]# useradd blarg
[root@bigdog /root]#

That wasn't very exciting, was it? Well, let's try to login:

Red Hat Linux release 5.1 (Manhattan)
Kernel 2.0.34 on an i586
login: blarg
Password: 
Login incorrect

login:

Not knowing what blarg's password was, we just pressed [Enter]. Guess that wasn't the right password. Say, how do you specify a password for a new account?

6.2.3.2 Passwords

The passwd command can be used to:

The first two scenarios are really one and the same; there's really no difference (as far as passwd is concerned) between an account that's just be created, or one that has existed for the past five years. All you need to remember is that you must be logged in as root, and that you must specify the account name whose password you want to change. Using the account we just created as an example, let's give passwd a try:

[root@bigdog /root]# passwd blarg
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully
[root@bigdog /root]#

As you might have guessed, the password is not displayed when you enter it. You also have to type the password twice, to make sure you didn't make a mistake while entering it. Let's try logging into the new account again:

Red Hat Linux release 5.1 (Manhattan)
Kernel 2.0.34 on an i586
login: blarg
Password: 
[blarg@bigdog blarg] 

Once you're logged in to an account, you can change that account's password by using the passwd command without the account name. In this case, you will be asked for the account's current password, followed by the new password:

[blarg@bigdog blarg] passwd
Changing password for blarg
(current) UNIX password: 
New UNIX password: 
Retype new UNIX password: 
passwd: all authentication tokens updated successfully
[blarg@bigdog blarg]

It's as simple as that.

6.2.3.3 The su Command

There may be times when you'd like to issue a command or two as another user. Normally, system administrators need this capability -- they (like all good sysadmins) use their personal, non-privileged account most of the time. But maybe a user's password needs to be changed, or the permissions on a system file need to be modified. Such things only take a minute, so it's a pain logging out, logging in as root, doing whatever it was they needed to do as root, logging out, and -- finally -- logging back into their personal accounts.

A much simpler approach is to use the su command. With su, your current login session can ``become'' a root (or other user's) login session. In the following example, user blarg decides they need to do something as root:

[blarg@bigdog blarg] su
Password: 
[root@bigdog blarg]# 

As you can see, after issuing the su command, the user is prompted for a password -- the root password. After it's been entered correctly, the usual shell prompt is displayed. But if you look closely, you'll note that the shell prompt is different. For one, it starts with root, indicating that the current user has changed. The other difference is the prompt's ending character, which changed from a dollar sign ($) to a pound sign (#). This is a traditional way of indicating whether a shell is running as root or not.

It's also possible to use su to become another user. To do this, run su, giving only the user's account name. So, to become user blarg, one need only issue the command su blarg. If you ran su from your own account, you'll need to enter the other user's password (in our example, user blarg's password would be required). However, if you were already root, no password is required, as it would be somewhat redundant.

You'll find that su will come in handy, particularly if you, like most Linux users, act as your own system administrator.

6.2.4 Shutting Down Your Red Hat Linux System

When you're done using your Red Hat Linux system, you'll need to shut it down. However, this is a bit more involved than simply pressing the power switch. Here's why:

Even though you may not be running any programs when you're ready to shutdown, that doesn't mean there's nothing running on your Red Hat Linux system. To see what we mean, issue this command:

ps ax

Each one of the lines displayed by ps represents a process. You can think of each process as being a ``running program''. Each process may be working with files, and if you simply turn off your computer, these processes won't have a chance to close those files, and finish running in a clean manner. So when the time comes to shut your system down, you'll need some way of telling all these processes to finish up, and exit cleanly. And the way this is normally done is with the shutdown command.

The shutdown command can only be run by root, so you'll need to either be logged in as root, or you can use the su command to ``become'' root. The basic syntax for shutdown is:

shutdown <options> <time>

Please Note: The shutdown program resides in /sbin. If your PATH environment variable does not include /sbin, you will need to include the full path when you enter the command (i.e.,
/sbin/shutdown -h now).

In most cases, you should include one of the following options:

If you don't include either option, shutdown will bring your system into ``single user'' mode. Unless you know why you want to be in single-user mode, you probably don't want to be in single-user mode. Simply enter the shutdown command (this time with -h or -r), and the shutdown will complete normally.

The shutdown command also gives you quite a bit of flexibility in terms of timing. If you want the shutdown to proceed right away, just enter the word ``now''. If you want to shut the system down five minutes from now, you can enter ``+5''. Therefore, this command:

shutdown -r +15

means, ``shut the system down starting fifteen minutes from now, and reboot after the shutdown has completed''. While shutdown has more options available, we've only described the basics necessary to perform a clean shutdown. If you're interested in learning more, enter man shutdown to learn more about shutdown's capabilities.


Next Up Previous Contents Index