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

📄 用户(user)和用户组(group)配置文件详解 linuxsir_org.htm

📁 linuxSir 网站的精华文章
💻 HTM
📖 第 1 页 / 共 4 页
字号:
      /bin/bash<BR>Office: Office Dalian, +1-300-000-0000<BR>Never logged 
      in.<BR>No mail.<BR>No Plan.</CODE></DIV>
      <P></P>
      <P><FONT size=2><B><BR>2)修改用户所归属的组,可以通过/etc/group 
      修改实现;<BR></B></FONT><BR>当然修改用户和用户组,不仅能通过修改配置文件来实现,还能过过 usermod 
      及chfn来实现;我将在以后的文档中写一写,也比较简单;您可以通过man来查看用法;在这里我们先讲一讲如何通过修改配置文件来达到目的;</P>
      <P>如果我们想把lanhaitun 这个用户归属到root用户组,所以我们还能修改/etc/group 的办法来达到目的;找到/etc/group 
      中的root开头的一行,按其规划加入lanhaitun;<BR>
      <DIV class=codeblock><CODE>root:x:0:root,lanhaitun</CODE></DIV>
      <P></P>
      <P>如果不明白,看前面/etc/group的解释,谢谢;</P>
      <P>然后执行 grpconv 命令来同步/etc/group 和/etc/gshadow两个文件的内容;<BR>
      <DIV class=codeblock><CODE>[root@localhost ~]# grpconv</CODE></DIV>
      <P></P>
      <P>查看lanhaitun归属组的信息;<BR>
      <DIV class=codeblock><CODE>[root@localhost ~]# id 
      lanhaitun<BR>uid=508(lanhaitun) gid=508(lanhaitun) 
      groups=508(lanhaitun),0(root)</CODE></DIV><BR><FONT 
      size=2><B><BR>3)删除用户及用户组的办法;<BR></B></FONT>
      <P></P>
      <P>这个比较简单,我们可以通过删除/etc/passwd 和/etc/group 相应的用户和用户组记录就能达到目的,也能过过userdel 
      和groupdel 来实现对用户及用户组的删除;</P>
      <P>如果是通过修改用户和用户组配置文件的办法来删除用户,就是删除相应的记录就行了,如果不想保留其家目录,删除就是了。</P>
      <P>
      <DIV class=codeblock><CODE>[root@localhost ~]# userdel 
      lanhaitun<BR>[root@localhost ~]# userdel -r lanhaitun</CODE></DIV>
      <P></P>
      <P>注:可以用userdel 来删除lanhaitun 用户,我们看到第二个例子中多了一个参数-r 
      ,第一个例子是说只删除lanhaitun用户,其家目录和mail等仍会保存;加上-r 
      参数,是删除家目录及mail等;所以要小心操作;用userdel 删除用户的同时,也会把其用户组删除;我们可以通过/etc/passwd 
      和/etc/group 的内容变化来查看;</P>
      <P><FONT size=4><B>后记:</B></FONT></P>
      <P>通过对用户和用户组相关文件的解说,能让我们明白在Linux操作系统中,系统配置文件的重要性,另外也从侧面说明了Linux系统的灵活性,解决问题办法有好多,条条大路通罗马;我希望通过本文给初学者一点提示是:Linux的使用并不难,难的是我们不去思考;</P>
      <P>这是我完成的第二篇用户管理的文档,虽然写的可能没有条理,但我实在不知道如何安排文档让其更有条理性,我只是根据自己的学习经历在写,或许对您有所启发和帮助,请多多指正;</P>
      <P>在以后关于用户管理的文档中,我会写通过用户管理工具来实现对用户的管理,最好是我有这个能力,但愿吧;</P>
      <P><FONT size=4><B>参考文档:</B></FONT></P>
      <P>man 和help ,感谢参与Linux的开发者和文档撰写社工;</P>
      <P><FONT size=4><B>致谢:</B></FONT></P>
      <P>对于此文,pandonny 兄和linuxfish兄给了极大的鼓励,感谢之中;</P>
      <P><FONT size=4><B>相关文档:</B></FONT></P>
      <P><A href="http://www.linuxsir.org/main/?q=node/91">《Linux 
      用户(user)和用户组(group)管理概述》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/98">《用户(user)和用户组(group)配置文件详解》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/105">《Linux 
      用户(User)查询篇》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/106">《Linux 用户管理工具介绍》</A><BR><A 
      href="http://www.linuxsir.org/main/?q=node/104">《Linux 
      系统中的超级权限的控制》</A></P></DIV>
      <DIV class=links>By 北南南北 at 2005/10/18 - 16:52 | <A 
      href="http://www.linuxsir.org/main/?q=taxonomy/term/1">Linux</A> | <A 
      href="http://www.linuxsir.org/main/?q=taxonomy/term/25">基础知识</A> | <A 
      title=共享你有关本文的思想和意见。 
      href="http://www.linuxsir.org/main/?q=comment/reply/98#comment">参与评论</A> | 
      4185 阅读</DIV></DIV><A id=comment></A>
      <FORM action=?q=comment method=post>
      <DIV><INPUT type=hidden value=98 name=edit[nid]> <A id=comment-566></A>
      <DIV class=comment>
      <H3 class=title><A class=active 
      href="http://www.linuxsir.org/main/?q=node/98#comment-566">感谢南北兄的努力,一个关于新加用户的问题</A></H3>
      <DIV class=content>
      <P>在“用户(User)和用户组(Group)配置文件详解中“讲了更改配置文件增加用户的方法<BR>但我想知道这种方法比使用其他方法用什么好处</P></DIV>
      <DIV class=links>By Anonymous at 周一, 2006/07/17 - 16:17 | <A 
      href="http://www.linuxsir.org/main/?q=comment/reply/98/566">回复</A></DIV></DIV><A 
      id=comment-565></A>
      <DIV class=comment>
      <H3 class=title><A class=active 
      href="http://www.linuxsir.org/main/?q=node/98#comment-565">感谢南北兄的努力,一个关于新加用户的问题</A></H3>
      <DIV class=content>
      <P>在“用户(User)和用户组(Group)配置文件详解中“讲了更改配置文件增加用户的方法<BR>但我想知道这种方法比使用其他方法用什么好处</P></DIV>
      <DIV class=links>By Anonymous at 周一, 2006/07/17 - 16:16 | <A 
      href="http://www.linuxsir.org/main/?q=comment/reply/98/565">回复</A></DIV></DIV><A 
      id=comment-564></A>
      <DIV class=comment>
      <H3 class=title><A class=active 
      href="http://www.linuxsir.org/main/?q=node/98#comment-564">感谢南北兄的努力,一个关于新加用户的问题</A></H3>
      <DIV class=content>
      <P>在“用户(User)和用户组(Group)配置文件详解中“讲了更改配置文件增加用户的方法<BR>但我想知道这种方法比使用其他方法用什么好处</P></DIV>
      <DIV class=links>By Anonymous at 周一, 2006/07/17 - 16:16 | <A 
      href="http://www.linuxsir.org/main/?q=comment/reply/98/564">回复</A></DIV></DIV>
      <DIV style="MARGIN-LEFT: 25px"><A id=comment-576></A>
      <DIV class=comment>
      <H3 class=title><A class=active 
      href="http://www.linuxsir.org/main/?q=node/98#comment-576">Gpasswd 
      问题</A></H3>
      <DIV class=content>
      <P>首先声明:本人非常愚笨:-)<BR>gpasswd很早以前就接触过,但是好像一直很模糊,看了您的文章以后仍然有很多不明白的地方,例如我这样操作:<BR>useradd 
      test #密码与用户名相同<BR>useradd lab #密码与用户名相同<BR>gpasswd -a lab test<BR>gpasswd 
      -a lab lab<BR>gpasswd lab #组的密码我设置成a<BR>然后以test登录,用newgrp 
      lab命令,要求输入密码,这个时候我无论怎么输入密码(a or lab or test)都返回同样的错误:<BR>newgrp:Permission 
      denied<BR>我不知道问题出现在哪里,希望北南兄帮助!!!!</P></DIV>
      <DIV class=links>By Anonymous at 周三, 2006/07/19 - 12:07 | <A 
      href="http://www.linuxsir.org/main/?q=comment/reply/98/576">回复</A></DIV></DIV></DIV></DIV></FORM><!-- end content -->
      <DIV id=footer>
      <CENTER><A href="http://www.linuxsir.org/"><IMG 
      src="用户(User)和用户组(Group)配置文件详解  LinuxSir_Org.files/logo.jpg"></A> <BR><A 
      href="http://www.miibeian.gov.cn/"><FONT color=blue 
      size=3><B>闽ICP备06025536号</B></FONT></A><BR>
      <SCRIPT language=JavaScript 
      src="用户(User)和用户组(Group)配置文件详解  LinuxSir_Org.files/cyberpolice.htm"></SCRIPT>
      <BR><A href="http://www.linuxsir.org/main/?q=node/78"><FONT color=blue 
      size=3><B>© 2002-2006 LinuxSir.Org</B></FONT></A><BR></CENTER></DIV></TD>
    <TD id=sidebar-right>
      <DIV class="block block-block" id=block-block-2>
      <H2 class=title>基础知识</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/23">安装配置</A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/1/25/">基础入门</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/22/">硬件解决</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/21">软件管理</A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/35/48/">重要资源</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-block" id=block-block-4>
      <H2 class=title>软件应用</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/30">网络工具</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/32">图形图像</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/31">音乐视频</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/49">字体中文</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/33">软件其它</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-block" id=block-block-5>
      <H2 class=title>网络服务器</H2>
      <DIV class=content>
      <UL>
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/27">文件服务器<A> 
        <LI><A 
        href="http://www.linuxsir.org/main/?q=taxonomy/term/28">Web服务器</A> 
        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/29">邮件服务器</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/37">数据库应用</A> 

        <LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/50">服务器其它</A> 
        </LI></UL></DIV></DIV>
      <DIV class="block block-comment" id=block-comment-0>
      <H2 class=title>最新评论</H2>
      <DIV class=content>
      <DIV class=item-list>
      <UL>
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-624">错了</A><BR>7 
        min 58 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-623">q</A><BR>27 
        min 35 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-622">有些道理</A><BR>49 
        min 4 sec 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/219#comment-621">"内置的摄像头也能用这个吗?"</A><BR>13 
        hours 54 min 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/80#comment-620">终于知道了...</A><BR>23 
        hours 9 min 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/106#comment-619">okok</A><BR>2 
        days 14 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/93#comment-618">那要除去阴影呢?</A><BR>3 
        days 19 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/227#comment-617">不错的机会</A><BR>4 
        days 6 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/221#comment-616">配置可执行程序的路径</A><BR>4 
        days 12 hours 前
        <LI><A 
        href="http://www.linuxsir.org/main/?q=node/222#comment-615">修改hostname出现的问题</A><BR>5 
        days 2 hours 
前</LI></UL></DIV></DIV></DIV></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

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