Linux用户管理操作杂谈

来源:互联网 发布:和男闺蜜做过的事 知乎 编辑:程序博客网 时间:2024/05/18 03:54

1、设置账户相关信息

ubuntu@ubuntu:~$ chfnPassword: Changing the user information for ubuntuEnter the new value, or press ENTER for the default        Full Name: ubuntu        Room Number []: 53D@tanglan        Work Phone []: null        Home Phone []: 1866595****
2、查看账户相关信息

ubuntu@ubuntu:~$ finger ubuntuLogin: ubuntu                           Name: ubuntuDirectory: /home/ubuntu                 Shell: /bin/bashOffice: 53D@tanglan, null               Home Phone: 1866595****On since Mon Nov 25 08:57 (CST) on tty7 from :0    1 day 1 hour idleOn since Tue Nov 26 08:56 (CST) on pts/0 from 192.168.1.45 (messages off)No mail.No Plan.
3、添加用户user1、user2、user3,用户组group_test,将user1划定为组管理员,测试添加组员权限

root@ubuntu:~# groupadd group_test//建立群组group_testroot@ubuntu:~# gpasswd group_testChanging the password for group group_testNew Password: Re-enter new password: root@ubuntu:~# useradd user1root@ubuntu:~# useradd user2root@ubuntu:~# gpasswd -A user1 group_test//设定user1为组管理员
root@ubuntu:/home/ubuntu# passwd user1Enter new UNIX password: Retype new UNIX password: passwd: password updated successfullyroot@ubuntu:/home/ubuntu# exitexitubuntu@ubuntu:~$ su user1Password: $ id uid=1001(user1) gid=1003(user1) groups=1003(user1)$ gpasswd -a user1 group_testAdding user user1 to group group_test$ gpasswd -a user2 group_testAdding user user2 to group group_test$ su root -lPassword: root@ubuntu:~# useradd user3root@ubuntu:~# passwd user3Enter new UNIX password: Retype new UNIX password: passwd: password updated successfullyroot@ubuntu:~# passwd user2Enter new UNIX password: Retype new UNIX password: passwd: password updated successfullyroot@ubuntu:~# su user2//测试其他账户对组的管理权限$ gpasswd -a user3 group_testgpasswd: Permission denied.//操作被拒绝

4、/etc/shadow 和/etc/passwd 字段解析

root:x:0:0:root:/root:/bin/bash<1>帐号名称<2>密码<3>UID:0=系统管理员;1-499=系统帐号;500-65535可登入帐号<4>GID<5>用户信息栏<6>家目录<7>shell
root:$6$F/:16029:0:99999:7:::<1>帐号名称<2>密码<3>最近更动密码的日期(1970-1-1)<4>密码不可更动的天数<5>密码需要更新变更的天数<6>密码需要变更期限前的警告天数<7>密码过期后的帐号宽限时间(密码失效日)<8>帐号失效日期<9>保留











原创粉丝点击