-->
Previous Table of Contents Next


Trying Out Your New Login

Now you can try out your new login. We can also look at some of the interesting features and capabilities of Linux.

At the login prompt, type the login name you have just created. If you were conscientious and assigned a nonzero-length password to your new login, enter the password when prompted.

You should now see the following (or something similar to it):


darkstar login: fido

Password:

Last login: Sun Dec 11 19:14:22 on tty1

Linux 1.2.13 (POSIX).



Quiet! I hear a hacker….

darkstar:~$

The messages for the most part are the same as when you logged in as root. Some systems don’t show you anything except the shell prompt, but you can change that. Note that your prompt looks different from the root prompt or the pound sign. The $ prompt indicates that you are a regular user running under the bash shell (which was the default choice presented by the adduser program). Also, there is no You have mail message (because you have no mail).


Note:  
Linux can be configured to automatically mail a message to all new users. This can be a greeting or can give system information and etiquette.

To see an example of the difference between the root login and a regular user login, type adduser at the shell prompt and press Enter.


darkstar:~$ adduser

bash: adduser: command not found

The message you get looks somewhat cryptic. However, it has a typical Linux error message structure, so it’s worth making a little effort now to understand it.

Linux Error Messages

First of all, in the error message shown previously there’s quite a bit of information. The program that is giving you the message is your shell, bash. It therefore announces itself with bash:, somewhat like the character in a play script. Next is the shell’s “monologue.” Being the “strong and silent” type of character, bash’s monologue is very terse and to the point. It declares the program that is causing problems (adduser) and the specific problem with this program: the command (adduser) can’t be found.

If the error message were expanded into real English, it would read something like this: “Hi, I’m bash. You know that adduser command you gave me? I looked everywhere for adduser but I couldn’t find it, so I couldn’t perform whatever actions adduser would have specified.” With time, you will get quite good at understanding Linux error message grammar.

Search Paths

Why can root find adduser, but an ordinary user cannot? Linux has many directories, and each directory can hold many files (one of which can be the elusive adduser). In theory, Linux could go search through the entire file system until it found adduser. But if root accidentally mistyped adduser as aduser, Linux would have to rummage through every nook and cranny before finally giving up. This could take many seconds and cause needless wear and tear on your hard drive (not to mention drive you nuts while every file was searched every time you typed anything).

Therefore, Linux has search paths for finding commands (which we discuss in more detail in Chapter 8). Usually, only a small part of the entire Linux file system is on the search path along which Linux searches. Because root makes use of many system administration programs such as adduser, the directories that hold these programs are in root’s search path. Ordinary users do not have system administration directories in their search path.


Tip:  
Linux search paths are very similar to those you may be aware of for DOS or Windows. The syntax for the paths and the way the directories are written are different but the approach is the same.

There is a way around this problem of not finding a file which is not in your search path, though. If you explicitly tell Linux where a file is located, then it doesn’t have to look through its search path. As it happens, adduser is found on most Linux systems in the /sbin directory. Try running /sbin/adduser.


darkstar:~$ /sbin/adduser

bash: /sbin/adduser: Permission denied

This time, bash could find adduser (because you told it exactly where to look) but discovered that an ordinary user does not have permission to run adduser. As you can see, Linux limits the actions of logins to their privilege level and only root (at least at this point) can run adduser. (We’ll talk about privileges in Chapter 9.)

The who Command

A very simple Linux command, which is also one of the most commonly used when you learn more about working with the shell and shell programming, is the who command. This simple command does one task: It shows you who is logged in at the moment. The who command is unusual in Linux because it takes no arguments. You use it by itself on the command line. Here’s a sample command and its output:


$ who

tparker    tty02      May 18 18:29

root       tty01      May 15 15:18

root       tty03      May 15 15:17

bills      ttyp0      May 18 18:29

ychow      ttyp1      May 25 17:31

The who command shows you three columns of information for each user that is on the system. First it shows the login that the user is employing. The second column shows the terminal the user is using (this is a device name, something we’ll look at in more detail in Chapter 33, “Devices”). The third column shows the time that the user logged in.

If a user is logged in on more than one terminal or virtual terminal (we’ll discuss virtual terminals in the next section), then each login is displayed. In the preceding output, you can see root is logged in twice on two different terminals.

The output of who is generated every time you run the command, so if a user logs off, the output from who is accurate from the moment you issue the command.


Previous Table of Contents Next