linux给用户一些命令,Linux关于用户信息的一些命令

1.用户增加删除

[root@VM_0_13_centos ~]# useradd better407 #添加 better407 用户

[root@VM_0_13_centos ~]# passwd better407 #设置 better407 密码

Changing password for user better407.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

[root@VM_0_13_centos ~]# cat /etc/passwd # 查看本机所有用户

#用户名:口令(passwd):用户标识号(UID):组标识号(GID):注释性描述(users):主目录(home_directory):登录shell

better407:x:501:502::/home/better407:/bin/bash

[root@VM_0_13_centos ~]# userdel 123 #删除用户123

[root@VM_0_13_centos ~]# ls -l /home #不带选项使用 userdel,只会删除用户。用户的家目录将仍会在/home目录下

total 12

drwx------ 2 502 503 4096 Aug 10 10:06 123

drwx------ 2 better407 better407 4096 Aug 10 09:47 better407

drwx------ 3 centos centos 4096 Aug 1 10:10 centos

[root@VM_0_13_centos ~]# rm -rf /home/123 #删除用户123的家目录

[root@VM_0_13_centos ~]# ls /home

better407 centos

注:删除用户时完全删除家目录,使用 -r 选项 userdel -r 123

userdel 提供 -f 选项来强制删除用户。当用户已经登入 Linux 系统时此选项仍旧生效

2.查看用户创建日期

[root@VM_0_13_centos ~]# ls -l /home/better407/.bash_logout

-rw-r--r-- 1 better407 better407 18 Mar 23 2017 /home/better407/.bash_logout

3.登录用户

[root@VM_0_13_centos ~]# w

#查看登录用户正在使用的进程信息

10:23:34 up 9 days, 13 min, 2 users, load average: 0.00, 0.00, 0.00

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

root pts/0 XXX.XXX.242.227 09:15 1:08m 0.00s 0.00s -bash

root pts/1 XXX.XXX.242.227 09:42 0.00s 0.03s 0.00s w

[root@VM_0_13_centos ~]# who

#查看(登录)用户名称及所启动的进程

root pts/0 2018-08-10 09:15 (49.77.242.227)

root pts/1 2018-08-10 09:42 (49.77.242.227)

[root@VM_0_13_centos ~]# users

#打印输出登录服务器的用户名称root root

[root@VM_0_13_centos ~]# whoami

#当前登入的用户名称root

[root@VM_0_13_centos ~]# id -un

#当前登入的用户名称root

[root@VM_0_13_centos ~]# last root

用户名称 tty设备号   ip地址:     历史登录时间日期:登出时间日期:总工作时间root pts/1 XXX.XXX.242.227 Fri Aug 10 09:42 still logged in

root pts/0 XXX.XXX.242.227 Fri Aug 10 09:15 still logged in

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值