📄 rhl06.htm
字号:
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:-# adduser fido
Looking for first available UID_ 505
Looking for first available GID_ 507
Adding login: fido_done.
Creating home directory: /home/fido_done.
Creating mailbox: /var/spool/mail/fido_done.
Don't forget to set the password</FONT></PRE>
<P>To complete adding the user, you'll need to use the passwd command to set password.
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">Darkstar:-# passwd</FONT></PRE>
<P>The adduser command included with Red Hat automatically assigns the UID, GID, and the home directory for the user added. The adduser command included with other Linux distributions will prompt you for these parameters.
<BR>
<P>An even more user-friendly method of adding users is to use the "user and group management" portion of the control-panel available under X.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>The User ID is used by Linux whenever it is referring to something you have done. The operating system is designed to use a number rather than the full login name because it takes up less room and is easier to manipulate. The User ID is important,
and each login on the system has its own unique number. By convention, UIDs of 500 or less are special system UIDs; root's UID is 0. Regular users get UIDs starting at 501.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BR>
<A NAME="E68E37"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Logging Out</B></FONT></CENTER></H3>
<BR>
<P>Now that you have created a new user, you can use it in the next couple of chapters to explore Linux. To finish with your session as root, log out of the system by typing logout:
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~# logout
Welcome to Linux 1.2.13
darkstar login:</FONT></PRE>
<P>You see the login prompt displayed again. At this point, you can log back in as root, or as the new user you have just created.
<BR>
<P>Some systems enable you to log out with the Ctrl-D sequence. If the shell you are using supports Ctrl-D as a logout command, the login prompt reappears. Otherwise, you may see a message such as this:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">Use "logout" to leave the shell.</FONT></PRE>
<P>If you have used other UNIX systems before, you may be used to using Ctrl-D to log out. The default shell used by Linux does not support Ctrl-D unless the keymappings are changed to allow it.
<BR>
<BR>
<A NAME="E68E38"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Trying Out Your New Login</B></FONT></CENTER></H3>
<BR>
<P>Now we can try out our new login. We can also look at some of the interesting features and capabilities of Linux.
<BR>
<P>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.
<BR>
<P>You should now see the following:
<BR>
<PRE>
<FONT COLOR="#000080">darkstar login: fido
Password:
Last login: Sun Dec 11 19:14:22 on tty1
Linux 1.2.13.
Quiet! I hear a hacker....
darkstar:~$</FONT></PRE>
<P>Note that your prompt looks different from the root prompt. 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.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<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.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>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.
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~$ adduser
bash: adduser: command not found</FONT></PRE>
<P>The message you get looks somewhat cryptic. However, it has a typical Linux error message structure, so it's worth taking a little effort to understand it.
<BR>
<BR>
<A NAME="E69E38"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Linux Error Messages</B></FONT></CENTER></H4>
<BR>
<P>First of all, the program that's 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 object that is causing it problems (adduser), and the problem with this object: the command (adduser) can't be found.
<BR>
<P>If the error message were expanded into real English, it would go 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.
<BR>
<BR>
<A NAME="E69E39"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Search Paths</B></FONT></CENTER></H4>
<BR>
<P>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 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 10 or more seconds, and cause needless wear and tear on your hard drive.
<BR>
<P>Therefore, Linux has search paths for finding commands (discussed in <A HREF="rhl08.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl08.htm">Chapter 8</A>). Usually, only a small part of the entire Linux file system is on the search path, which literally is the 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.
<BR>
<P>However, if you explicitly tell Linux where a file is located, it does not need to look through its search path. As it happens, adduser is found in the /sbin directory. Try running /sbin/adduser.
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~$ /sbin/adduser
bash: /sbin/adduser: Only root may add users to the system.</FONT></PRE>
<P>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.
<BR>
<BR>
<A NAME="E68E39"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Virtual Terminals</B></FONT></CENTER></H3>
<BR>
<P>Linux, as mentioned earlier, is a multiuser, multitasking system. This means that more than one login can access the system at the same time, and that each login can be doing one or more different things all at the same time. A serious multiuser system
will have several terminals (consisting of a keyboard and a display screen) wired or networked to the main computer unit.
<BR>
<P>Although you probably don't have any terminals attached to your system, you still can log in several times under the same or different login names, using your single keyboard and screen! This magic is performed by using virtual terminals.
<BR>
<P>Press Alt-F2. When you do so, everything on your screen should disappear, to be replaced by the following:
<BR>
<PRE>
<FONT COLOR="#000080">Welcome to Linux 1.2.13
darkstar login:</FONT></PRE>
<P>Log in as your "regular" login (not root). When the shell prompt is displayed, type who at the prompt and press Enter. You should see the following:
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~$ who
fido tty2 Dec 14 01:42
fido tty1 Dec 14 01:40</FONT></PRE>
<P>When you run the Linux command who, your screen displays the names of all logins currently logged into the system, and where they are logged in from. (Your login name will appear, of course, instead of fido in the preceding example.)
<BR>
<P>By convention, tty1 is the main console screen. It is the "normal" one that appears after Linux has started up, so you don't have to do anything special to get it. If you have switched to any other virtual consoles, you can return to tty1 by
pressing Alt-F1.
<BR>
<P>How many virtual screens are active on your system? Try going through all the Alt-Fn keys. Alternatively, you can scroll through the virtual screens by using the Alt-right arrow combination to move up through the screens, or Alt-left arrow to move down.
<BR>
<P>Quite often you find yourself doing something, perhaps in a long and complicated program, and realize that you should have done something else first. Flip to another virtual terminal and do whatever it is.
<BR>
<P>Another handy use of virtual terminals is when, through experimentation or otherwise, your screen locks up or starts typing in strange symbols. From a different virtual terminal, you can try to fix things, or restart the system if necessary.
<BR>
<P>Linux also comes with a very powerful multitasking windowing environment called X. Installing and running X Window systems is described in <A HREF="rhl21.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl21.htm">Chapter 21</A>, "Installing X Window on Linux."
<BR>
<BR>
<A NAME="E68E40"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Commands and Programs</B></FONT></CENTER></H3>
<BR>
<P>"Run the who command" and "Run who" are much more common ways of saying "Type who at the prompt and press Enter." We will use the shorter expressions wherever their meaning is clear. Sometimes people familiar with Linux
drop the word "run," so that one user might tell another, "I tried who but didn't see anything unusual." It's understood by the context that when they "tried who," they actually ran it.
<BR>
<P>Something else you will notice if you are reading carefully is that there seem to be both Linux programs and Linux commands. A command is what you type at the shell prompt. For this reason, the combination of the shell prompt and what you type after it
is often called a command line. When you press the Enter key, Linux takes the command you've entered and tries to perform it. The Linux system has built-in responses to some commands; for other commands it finds the appropriately named program on your hard
disk and executes that program.
<BR>
<P>In the strictest sense, then, the command is what you type, and the program is what performs your command. However, very simple programs with straightforward results, such as who, are often referred to as commands, although there is actually a who
program on your hard disk. More complicated programs, usually interactive such as adduser, or open-ended such as a text editor, are called programs. So you might hear one experienced user tell another, "The adduser program worked fine. I tried the who
command 15 minutes later and the new user had logged in already."
<BR>
<BR>
<A NAME="E68E41"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>
<BR>
<P>In this chapter, we assigned a password to the root login and created a new user ID to be used in the next few chapters. We tried out Linux multitasking, and we learned some useful Linux terminology tips that will serve us well in the future (we will
try to avoid seeing too many error messages, though). At this point, you can either ensure that you have logged out of all virtual terminals, or move on to the following chapters.
<BR>
<P>In the next two chapters, we will become more familiar with using Linux. In <A HREF="rhl07.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl07.htm">Chapter 7</A>, "Basic Linux Commands and Utilities," we try out a variety of Linux commands as we exercise our Linux muscles. In <A
HREF="rhl08.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl08.htm">Chapter 8</A>, we learn more about how Linux stores its programs and data, and explore some of the interesting terrain on your hard drive.<A NAME="I2"></A>
<P ALIGN=LEFT>
<A HREF="rhl05.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl05.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>
<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="rhl07.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl07.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -