1 用户信息
创建用户一个名为 webuser 的账号,并填写相应的信息:
root@iZ94fabhqhuZ:~# adduser webuser Adding user `webuser' ... Adding new group `webuser' (1000) ... Adding new user `webuser' (1000) with group `webuser' ... Creating home directory `/home/webuser' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for webuser Enter the new value, or press ENTER for the default Full Name []: web publish user Room Number []: 102 Work Phone []: 15298098787 Home Phone []: 010-99877890 Other []: no other Is the information correct? [Y/n]
查看用户:
root@iZ94fabhqhuZ:~# cat /etc/passwd root:x:0:0:root:/root:/bin/bash ... webuser:x:1000:1000:web publish user,102,15298098787,010-99877890,no other:/home/webuser:/bin/bash
将里面的webuser信息展开:
- webuser
- x
- 1000
- 1000
- web publish user,102,15298098787,010-99877890,no other
- /home/webuser
- /bin/bash
按照分号划分,一共有7个字段,分别是:
- 登录用户名
- 经过加密的口令或者口令占位符
- UID(用户ID)
- 默认的GID(组ID)
- GECOS信息:全名,办公室,手机号,座机号,其它
- 主目录
- 登录的shell
关于最后一点:登录的shell。一个系统是可能有多个shell的,通过如下方式可以查看系统有哪些shell:
➜ etc cat /etc/shells # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh
以上显示的是一个安装了第三方shell:z-shell的一个linux机器。通过命令可以对不同的用户设置不同的shell操作界面。
2 组信息
查看组信息:
root@iZ94fabhqhuZ:/etc# cat /etc/group root:x:0: adm:x:4:syslog sudo:x:27: www-data:x:33: webuser:x:1000:webuser,www-data
一共分四段:
- 组名称
- 加密的口令或者一个占位符
- GID号(组ID)
- 成员列表,用逗号隔开(注意不要加空格)
3 查看登录日志
(pyvenv) webuser@iZ25o2yyyoeZ:~$ sudo tail -n 10 /var/log/auth.log May 4 14:35:30 iZ25o2yyyoeZ sudo: pam_unix(sudo:session): session closed for user root May 4 14:35:47 iZ25o2yyyoeZ sshd[27149]: Received disconnect from 183.94.93.12: 11: disconnected by user May 4 14:35:47 iZ25o2yyyoeZ sshd[27131]: pam_unix(sshd:session): session closed for user webuser May 4 14:35:54 iZ25o2yyyoeZ sshd[27206]: Accepted publickey for webuser from 183.94.93.12 port 50555 ssh2: RSA 2b:4c:a0:ca:73:eb:63:2e:24:87:6b:d2:48:2f:fd:e5 May 4 14:35:54 iZ25o2yyyoeZ sshd[27206]: pam_unix(sshd:session): session opened for user webuser by (uid=0) May 4 14:36:25 iZ25o2yyyoeZ sudo: webuser : TTY=pts/0 ; PWD=/home/webuser ; USER=root ; COMMAND=/usr/bin/tail -n 20 /var/log/auth.log May 4 14:36:25 iZ25o2yyyoeZ sudo: pam_unix(sudo:session): session opened for user root by webuser(uid=0) May 4 14:36:25 iZ25o2yyyoeZ sudo: pam_unix(sudo:session): session closed for user root May 4 14:40:58 iZ25o2yyyoeZ sudo: webuser : TTY=pts/0 ; PWD=/home/webuser ; USER=root ; COMMAND=/usr/bin/tail -n 10 /var/log/auth.log May 4 14:40:58 iZ25o2yyyoeZ sudo: pam_unix(sudo:session): session opened for user root by webuser(uid=0)
可以看到某用户在干什么时候做了哪些主要的操作。
转载:http://www.cnblogs.com/beer/p/5590708.html