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

📄 634-636.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Users and Logins</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=35//-->

<!--PAGES=634-636//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="631-634.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch36/637-640.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading17"></A><FONT COLOR="#000077">Adding a User to New Groups</FONT></H4>

<P>Users can belong to many groups, in which case their user IDs should be on each group line that they belong to in the file <TT>/etc/group</TT>. Each username on a line in the <TT>/etc/group</TT> file is separated by a comma. There is no limit to the number of users that can belong to a group, in theory, but in practice, the line length of the Linux system (255 characters) acts as an effective limiter. There are ways around this limit, but few systems will require it.</P>

<P>The following excerpt from a <TT>/etc/group</TT> file shows several groups with multiple members:</P>

<!-- CODE SNIP //-->

<PRE>

accounts::52:bill,yvonne,tim,roy,root

prgming::53:bill,tim,walter,gita,phyliss,john,root

cad::54:john,doreen,root

scanner::55:john,root,tim

</PRE>

<!-- END CODE SNIP //-->

<P>The usernames on each line do not have to be in any particular order. Linux searches along each line to find the usernames it wants.

</P>

<P>A user can be a member of only one group at a time while logged in, so he must use the command <TT>newgrp</TT> to change between groups they are members of. The starting group a user belongs to when he logs in is given by the GID field in the <TT>/etc/passwd</TT> file.</P>

<H4 ALIGN="LEFT"><A NAME="Heading18"></A><FONT COLOR="#000077">Deleting a Group</FONT></H4>

<P>If you decide you don&#146;t want a particular group to exist anymore, you can simply remove the group name from the <TT>/etc/group</TT> file. You should also check the <TT>/etc/passwd</TT> file to see if any users have that group ID as their startup GID, and change it to another group they are members of. If you don&#146;t change the GIDs, the users will not be able to log in because they have no valid group membership. You should also scan the entire file system for files and directories that are owned by that group and change them to another group. Failure to make this change may prevent access to the file or directory.</P>

<P>Some Linux versions have shell scripts that remove group lines from the <TT>/etc/group</TT> file for you. The utility is generally called <TT>delgroup</TT> or <TT>groupdel</TT>. However, most versions of Linux don&#146;t bother with this utility.</P>

<H3><A NAME="Heading19"></A><FONT COLOR="#000077">The su Command</FONT></H3>

<P>Sometimes you want to execute a command as another user. If you are logged in as super-user and want to create files with <TT>bill</TT>&#146;s permissions and ownership set, it is easier to log in as <TT>bill</TT> than work as root and then reset all the parameters. Similarly, if you are logged in as a user and need to be superuser for a little while, you would have to log out and back in to make the change. An alternative is the <TT>su</TT> command.</P>

<P>The <TT>su</TT> command changes your effective username and grants you the permissions that username has. The <TT>su</TT> command takes the username you want to change to as an argument. For example, if you are logged in as a typical user and want to be root, you can issue the following command:</P>

<!-- CODE SNIP //-->

<PRE>

su root

</PRE>

<!-- END CODE SNIP //-->

<P>The Linux system prompts you for the root password. If you supply it correctly, you will be root until you issue a Ctrl&#43;D to log out of that account and back to where you started. Similarly, if you are logged in as root and want to be a user, you can issue the command with the username, such as the following:

</P>

<!-- CODE SNIP //-->

<PRE>

su tparker

</PRE>

<!-- END CODE SNIP //-->

<P>You won&#146;t be prompted for a password when changing from root to another user because you have superuser powers. When you Ctrl&#43;D out of the login, you are back as root. If you are logged in as a normal user and want to switch to another non-root login, you have to supply the password, though.

</P>

<H3><A NAME="Heading20"></A><FONT COLOR="#000077">Summary</FONT></H3>

<P>In this chapter we&#146;ve looked at the basics of the <TT>/etc/passwd</TT> and <TT>/etc/group</TT> files, the two files intimately connected with user access to Linux. As you have seen, these are simple files and can easily be modified by a system administrator to add users and groups at any time. Always bear in mind that these are vital files, and they should be copied to a backup filename, then edited carefully and their permissions checked after each edit. From here, you can explore the following topics:</P>

<DL>

<DD>Learn more about SCSI (Small Computer System Interface) devices and how they add to your Linux system&#146;s flexibility in Chapter 36. &#147;SCSI Device Support.&#148;

<DD>Learn more about setting up e-mail on your Linux system in Chapter 40, &#147;Configuring Linux for Mail.&#148;

<DD>Learn more about the <TT>tar</TT> command, backups, and the importance of making backup copies of your system in Chapter 45, &#147;Backups.&#148;

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="631-634.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch36/637-640.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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