Linux Note 6 20160717 用户与组

users and groups

  • Every user gets a UserID(UID), the system actually recognizes the ID rather than user name.
  • Each user belongs to a main group and one or many belonging groups.
  • Each group owns a groupID.
  • Each process is ran by an UID and is limited by the user's power.
  • Each login user has a shell.

user

d : 32bit
three kinds.
-root id=0
-system user (1~499)
-common user (500~)
系统中的文件都有一个所属用户和所属组。
使用id可以显示当前用户信息。
使用passwd可以修改密码。

相关文件

/etc/passwd 保存用户信息
/etc/shadow 保存用户密码(加密后,一般不可逆)
/etc/group 保存组信息

查看登陆的用户

whoami 当前用户
who 谁登陆过
w 那些用户已经登陆并且在干什么

创建一个用户

useradd 用户名

  • passwd userName 来为新用户定制密码
  • etc/skel 里的信息会自动复制到 /home/心用户/
    参数
    -d 家目录
    -s 登陆shell
    -u userid
    -g 主组
    -G 附属组(最多31个,用","分割)
    也可以通过直接修改/etc/passwd的方式实现,但是不推荐。

修改用户信息

usermod
-l 心用户名
-u new userid
-d home index position
-g main group
-G belonging group
-L lock the user
-U unlock the user

删除用户

userdel 用户名 (不会删除家目录)
userdel -r username (delete home index)

groupadd
groupmod -n newname oldname
groupmod -g newid
groupdel

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容