<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>成刚网志 &amp;amp;&amp;amp; CBolg Application</title>
<link>http://www.chenggang.net</link>
<description><![CDATA[记录我的网事历程，架起沟通的桥梁！欢迎留言！
]]></description>
<lastBuildDate>Sun, 20 May 2012 22:43:39 +0800</lastBuildDate>
<copyright>Copyright &amp;copy; 2012 by CBolg Application.</copyright>
<language>zh-cn</language>
<pubDate>Mon, 21 May 2012 14:45:34 +0800</pubDate>
<item>
<title>Linux添加/删除用户和用户组</title>
<summary><![CDATA[本文总结了Linux添加或者删除用户和用户组时常用的一些命令和参数, 值得Linux初学者一读 1、建用户： adduser linuxsense //新建linuxsense用户passwd linuxsense //给linuxsense用户设置密码2、建工作组 groupadd test //新建test工作组3、新建用户同时增加工作组 useradd -g ]]></summary>
<description><![CDATA[<p>
	本文总结了<a href=":;" target="_self"><u><strong><span style="color: #666666">Linux</span></strong></u></a>添加或者删除<a href=":;" target="_self"><u><strong><span style="color: #666666">用户</span></strong></u></a>和用户组时常用的一些命令和参数, 值得Linux初学者一读</p>
<div>
	&nbsp;</div>
<div>
	1、建用户： 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">adduser linuxsense //新建linuxsense用户<br />
		passwd linuxsense //给linuxsense用户设置密码</span></div>
	2、建工作组 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">groupadd test //新建test工作组</span></div>
	3、新建用户同时增加工作组 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">useradd -g test linuxsense //新建linuxsense用户并增加到test工作组</span></div>
	<p>
		注：：-g 所属组 -d 家目录 -s 所用的SHELL<br />
		&nbsp;</p>
	<p>
		4、给已有的用户增加工作组 </p>
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">usermod -G groupname username</span></div>
	或者：gpasswd -a user group<br />
	<br />
	5、临时关闭：在/etc/shadow文件中属于该用户的行的第二个字段（密码）前面加上*就可以了。想恢复该用户，去掉*即可。<br />
	<br />
	或者使用如下命令关闭用户账号： 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">passwd peter &ndash;l</span></div>
	重新释放： 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">passwd peter &ndash;u</span></div>
	6、永久性删除用户账号 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">userdel peter<br />
		<br />
		groupdel peter<br />
		<br />
		usermod &ndash;G peter peter （强制删除该用户的主目录和主目录下的所有文件和子目录）</span></div>
	7、从组中删除用户<br />
	编辑/etc/group 找到GROUP1那一行，删除 A<br />
	或者用命令 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">gpasswd -d A GROUP</span></div>
	8、显示用户信息 
	<div class="blockcode" style="padding-right: 5px; padding-left: 5px; font-weight: normal; font-size: 100%; padding-bottom: 5px; margin: 0px 0px 10px 20px; padding-top: 5px; font-style: normal; background-color: #eeeeee; border: #cccccc 1px solid">
		<span style="font-family: NSimsun">id user<br />
		cat /etc/passwd</span></div>
	<p>
		更详细的用户和用户组的解说请参考<br />
		<a href="http://www.phpq.net/linux/linux-user-and-group.html" style="color: #313131; text-decoration: none" target="_blank">Linux 用户和用户组详细解说</a><br />
		本文主要讲述在Linux 系统中用户(user)和用户组(group)管理相应的概念；用户(user)和用户组(group)相关命令的列举；其中也对单用户多任务，多用户多任务也做以解说。</p>
	<p style="text-align: right;">
		摘至：<a href="http://www.linuxsense.org/viewnews-369.html">http://www.linuxsense.org/viewnews-369.html</a></p>
</div>
<p>
	&nbsp;</p>
]]></description>
<link>http://www.chenggang.net/posts/55</link>
<pubDate>Tue, 21 Oct 2008 16:20:00 +0800</pubDate>
<author>小豆</author>
<category>Linux</category>
<guid isPermaLink="true">http://www.chenggang.nethttp://www.chenggang.net/posts/55</guid>
</item>
</channel></rss>
