-->
Previous | Table of Contents | Next |
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 dont 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 its worth making a little effort now to understand it.
First of all, in the error message shown previously theres 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 shells monologue. Being the strong and silent type of character, bashs 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) cant be found.
If the error message were expanded into real English, it would read something like this: Hi, Im bash. You know that adduser command you gave me? I looked everywhere for adduser but I couldnt find it, so I couldnt perform whatever actions adduser would have specified. With time, you will get quite good at understanding Linux error message grammar.
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 roots 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 doesnt 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. (Well talk about privileges in Chapter 9.)
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. Heres 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 well 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 (well 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 |