⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch06.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 3 页
字号:


means that it's suggesting a GID of 100. This is the default choice.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading20<FONT COLOR="#000077"><B>TIP:</B> </FONT>In this <TT>adduser</TT>



	script and many other Linux programs, default choices are presented in square brackets.



	Simply press the Enter key to accept the default, or type the new value if you don't



	want to accept the default value. Sometimes (as you will see a little further on



	in the <TT>adduser</TT> utility) you are given two choices--usually <TT>y</TT> for



	yes and <TT>n</TT> for no--separated by a <TT>/</TT> or <TT>|</TT> character. The



	item in uppercase is the default choice, which you can use by pressing Enter. The



	other choice must be typed explicitly. In the following examples, yes is always the



	default choice: <TT>[Y/n]</TT>, <TT>[Y|n]</TT>, <TT>[Yn]</TT>. 



<HR>







</DL>







<P>The default Group ID of 100 is fine for this new user, so simply press Enter.



In most cases you will not want to change the suggested Group ID.</P>



<PRE><FONT COLOR="#0066FF">GID [100]:



Group 'users', GID 100



First unused uid is 501



UID [501]:



</FONT></PRE>



<P>The <TT>adduser</TT> utility did not echo your Group ID choice to the screen.



This can be a little disconcerting if you're not used to it, especially if you look



back and try to figure out what you've done! Most Linux commands don't echo what



you have done, though, so this is a good time to get used to it.</P>



<P>The <TT>adduser</TT> utility now asks for a UID or User ID. Linux suggests a default



value of 501. Again, the default is fine in this case, so just press Enter.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading21<FONT COLOR="#000077"><B>NOTE: </B></FONT>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; <TT>root</TT>'s UID is 0. Regular users get UIDs starting at 501. 



<HR>







</DL>







<P>The <TT>adduser</TT> utility then shows two more prompts asking for the user's



home directory and the shell:</P>



<PRE><FONT COLOR="#0066FF">Home Directory [/home/fido]:



Shell [/bin/bash]:



</FONT></PRE>



<P>Choose the default values for <TT>Home Directory</TT> and <TT>Shell</TT>. I'll



explain more about directories in Chapter 8 and look at different shells in Chapters



10, &quot;<TT>bash</TT>,&quot; 11, &quot;<TT>pdksh</TT>,&quot; and 12, &quot;<TT>tcsh</TT>.&quot;



The default values are suitable for most user IDs.</P>



<P>As a last step, the <TT>adduser</TT> program asks for a password for the new user.



At the prompt, enter a suitable password. If you press Enter without typing anything



else, the password is set to the same string as the login. This is not recommended,



because it is easy to guess. Even a simple password is better.</P>



<PRE><FONT COLOR="#0066FF">Password [fido]:







Information for new user [fido]:



Home directory: [/home/fido] Shell: [/bin/bash]



uid: [501] gid: [100]



Is this correct? [y/N]:



</FONT></PRE>



<P>The <TT>adduser</TT> program now verifies that you are happy with all the information



you have entered. If you are, type <TT>y</TT> for yes, and press Enter. The default



value (shown by the capital letter) is <TT>N</TT> for no. If you choose the default,



you are telling the script that the information displayed is not correct, and you



have to start the whole process over again.</P>



<P>When you answer <TT>y</TT> to the question <TT>Is this correct?</TT>, the <TT>adduser</TT>



program creates the new user's directory and adds the user information to the system



configuration files. You see the following information appear on the screen as the



<TT>adduser</TT> utility does its work. When the utility has finished, you see the



Linux shell prompt again:</P>



<PRE><FONT COLOR="#0066FF">Adding login [fido] and making directory [/home/fido]







Adding the files from the /etc/skel directory:



./.less -&gt; /home/fido/./.less



./.lessrc -&gt; /home/fido/./.lessrc



darkstar:~#



</FONT></PRE>



<P>We will look at how to remove unwanted users from your <TT>/etc/passwd</TT> file



in Chapter 41, &quot;Users.&quot;



<H3 ALIGN="CENTER"><A NAME="Heading22<FONT COLOR="#000077">Logging Out</FONT></H3>



<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 <TT>root</TT>, log out of the system



by typing <TT>logout</TT>:</P>



<PRE><FONT COLOR="#0066FF">



darkstar:~# logout



Welcome to Linux 2.0.0.



darkstar login:



</FONT></PRE>



<P>You see the login prompt displayed again. At this point, you can log back in as



<TT>root</TT>, or as the new user you have just created.</P>



<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:</P>



<PRE><FONT COLOR="#0066FF">Use &quot;logout&quot; 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.



<H3 ALIGN="CENTER"><A NAME="Heading23<FONT COLOR="#000077">Trying Out Your



New Login</FONT></H3>



<P>Now we can try out our new login. We can also look at some of the interesting



features and capabilities of Linux.</P>



<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.</P>



<P>You should now see the following:</P>



<PRE><FONT COLOR="#0066FF">darkstar login: fido



Password:



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



Linux 2.0.0.







Quiet!  I hear a hacker....



</FONT></PRE>



<PRE><FONT COLOR="#0066FF">darkstar:~$



</FONT></PRE>



<P>Note that your prompt looks different from the <TT>root</TT> prompt. The <TT>$</TT>



prompt indicates that you are a regular user running under the <TT>bash</TT> shell



(which was the default choice presented by the <TT>adduser</TT> program). Also, there



is no <TT>You have mail</TT> message.







<DL>



	<DT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading24<FONT COLOR="#000077"><B>NOTE: </B></FONT>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. 



<HR>







</DL>







<P>To see an example of the difference between the <TT>root</TT> login and a regular



user login, type <TT>adduser</TT> at the shell prompt and press Enter.</P>



<PRE><FONT COLOR="#0066FF">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.



<H4 ALIGN="CENTER"><A NAME="Heading25<FONT COLOR="#000077">Linux Error Messages</FONT></H4>



<P>First of all, the program that's giving you the message is your shell, <TT>bash</TT>.



It therefore announces itself with <TT>bash:</TT>, somewhat like the character in



a play script. Next is the shell's &quot;monologue.&quot; Being the &quot;strong



and silent&quot; type of character, <TT>bash</TT>'s monologue is very terse and to



the point. It declares the object that is causing it problems (<TT>adduser</TT>),



and the problem with this object: the command (<TT>adduser</TT>) can't be found.</P>



<P>If the error message were expanded into real English, it would go something like



this: &quot;Hi, I'm <TT>bash</TT>. You know that <TT>adduser</TT> command you gave



me? I looked everywhere for <TT>adduser</TT> but I couldn't find it, so I couldn't



perform whatever actions <TT>adduser</TT> would have specified.&quot; With time,



you will get quite good at understanding Linux error message grammar.



<H4 ALIGN="CENTER"><A NAME="Heading26<FONT COLOR="#000077">Search Paths</FONT></H4>



<P>Why can <TT>root</TT> find <TT>adduser</TT>, but an ordinary user cannot? Linux



has many directories, and each directory can hold many files (one of which can be



the elusive <TT>adduser</TT>). In theory, Linux could go search through the file



system until it found <TT>adduser</TT>. But if <TT>root</TT> accidentally mistyped



<TT>adduser</TT> as <TT>aduser</TT>, 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.</P>



<P>Therefore, Linux has search paths for finding commands (discussed in Chapter 8).



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 <TT>root</TT> makes



use of many system administration programs such as <TT>adduser</TT>, the directories



that hold these programs are in <TT>root</TT>'s search path. Ordinary users do not



have system administration directories in their search path.</P>



<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, <TT>adduser</TT> is found in the



<TT>/sbin</TT> directory. Try running <TT>/sbin/adduser</TT>.</P>



<PRE><FONT COLOR="#0066FF">darkstar:~$ /sbin/adduser



</FONT></PRE>



<PRE><FONT COLOR="#0066FF">bash: /sbin/adduser: Permission denied



</FONT></PRE>



<P>This time, <TT>bash</TT> could find <TT>adduser</TT> (because you told it exactly



where to look), but discovered that an ordinary user does not have permission to



run <TT>adduser</TT>. As you can see, Linux limits the actions of logins to their



privilege level.



<H3 ALIGN="CENTER"><A NAME="Heading27<FONT COLOR="#000077">Virtual Terminals</FONT></H3>



<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.</P>



<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.</P>



<P>Press Alt-F2. When you do so, everything on your screen should disappear, to be



replaced by the following:</P>



<PRE><FONT COLOR="#0066FF">Welcome to Linux 2.0.0.







darkstar login:



</FONT></PRE>



<P>Log in as your &quot;regular&quot; login (not <TT>root</TT>). When the shell prompt



is displayed, type <TT>who</TT> at the prompt and press Enter. You should see the



following:</P>



<PRE><FONT COLOR="#0066FF">darkstar:~$ who



fido     tty2     Dec 14 01:42



fido     tty1     Dec 14 01:40



</FONT></PRE>



<P>When you run the Linux command <TT>who</TT>, 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 <TT>fido</TT> in the preceding example.)</P>



<P>By convention, <TT>tty1</TT> is the main console screen. It is the &quot;normal&quot;



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



<TT>tty1</TT> by pressing Alt-F1.</P>



<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.</P>



<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.</P>



<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.</P>



<P>Linux also comes with a very powerful multitasking windowing environment called



X. Installing and running X Window systems is described in Chapter 21, &quot;Installing



XFree86.&quot;



<H3 ALIGN="CENTER"><A NAME="Heading28<FONT COLOR="#000077">Commands and Programs</FONT></H3>



<P>&quot;Run the <TT>who</TT> command&quot; and &quot;Run <TT>who</TT>&quot; are



much more common ways of saying &quot;Type <TT>who</TT> at the prompt and press Enter.&quot;



We will use the shorter expressions wherever their meaning is clear. Sometimes people



familiar with Linux drop the word &quot;run,&quot; so that one user might tell another,



&quot;I tried <TT>who</TT> but didn't see anything unusual.&quot; It's understood



by the context that when they &quot;tried <TT>who</TT>,&quot; they actually ran it.</P>



<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.</P>



<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 <TT>who</TT>, are often referred to as commands, although there is actually



a <TT>who</TT> program on your hard disk. More complicated programs, usually interactive



such as <TT>adduser</TT>, or open-ended such as a text editor, are called programs.



So you might hear one experienced user tell another, &quot;The <TT>adduser</TT> program



worked fine. I tried the <TT>who</TT> command 15 minutes later and the new user had



logged in already.&quot;



<H3 ALIGN="CENTER"><A NAME="Heading29<FONT COLOR="#000077">Summary</FONT></H3>



<P>In this chapter, we assigned a password to the <TT>root</TT> 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.</P>







<P>In the next two chapters, we will become more familiar with using Linux. In Chapter



7, &quot;Basic Commands,&quot; we try out a variety of Linux commands as we exercise



our Linux muscles. In Chapter 8, we learn more about how Linux stores its programs



and data, and explore some of the interesting terrain on your hard drive.



















</td>
</tr>
</table>

<!-- begin footer information -->



</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -