3

shell基础十二篇_学习笔记_2_useradd_groupadd_passwd


useradd与groupadd命令
useradd添加用户,常用的选项有
-m 添加/home/xxx目录
-m, –create-home create home directory for the new user
account

-g 用户组的gid 指定用户所属的gid。
-g, –gid GROUP force use GROUP for the new user account

-G 附加组
-G, –groups GROUPS list of supplementary groups for the new
user account

例如abc用户属于abc的组,也属于root的组,abc组的gid为111
useradd -m -g 111 abc -G root abc

-s 指定用户的登录Shell
-s, –shell SHELL the login shell for the new user account

-p 密码


修改与管理密码 passwd命令
常用的选项有
-S 状态 status
-a ( –all ) 此命令仅与 -S命令一起使用,方便查看所有用户的状态
-d 删除指定用户的密码,使之为空
-e 使用户的密码为过期状态,expire强制用户下次登录的时候必须修改密码
[ 我这里测试过,不修改新密码就无法再登陆了,且新密码不得与旧密码相同 ]
-l 锁定用户,使其无法登陆
-u 为锁定用户解锁
-x 指定密码有效期

/etc/shadow文件
登录名:加密口令:最后一次修改时间:最小时间间隔:最大时间间隔:警告时间:不活动时间:失效时间:标志
得到所有真实存在的用户? [ 不对的话还请指出 ]
cat /etc/shadow|grep -v \*|grep -v \!
root:$1$hOJ/mqf0$EhcLRSXdSd5KWCdXcXGdH.:14183:0:99999:7:::
abc:$1$uZ2qXNMI$RnTfZZgLwhtyuFFMHDSou/:14345:0:99999:7:::

系统中所有 [ 组 group ] 的信息
cat /etc/group

我猜~这些文章你可能也感兴趣

总共有3个留言:

  1. 炜煜 on 四 12th, 2009 - 10:18

    最近好吗?
    我曾经也学过一阵子的SHELL。不过现在忘光了。惭愧呀。



    回复:还可以哦,我找到工作啦~

  2. yadandimao on 四 12th, 2009 - 10:34

    最近工作找的怎么样?



    回复:找到啦,谢谢你的关心!

  3. daniel on 四 12th, 2009 - 14:14

    又是一头雾水~~~\(^o^)/~



    回复:彼此彼此~呵呵!

给我留言:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word