Centos用户管理笔记

《Centos用户管理笔记》

查看

查看所有可登录的用户:
# cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
------------------
 root
 sync
 shutdown
 halt
查看系统中有哪些用户:
# cut -d : -f 1 /etc/passwd
------------------
 root
 bin
 daemon
 adm
 lp
 sync
 shutdown
 halt
 mail
 operator
 games
 ftp
 nobody
 systemd-network
 dbus
 polkitd
 sshd
 postfix
 chrony
 nginx
 mysql
 apache
 redis
 postgres
 zabbix
 weiguo
 tss

新增

//新增用户:
# adduser admin1
//新建用户同时增加工作组
# useradd -g group1 admin1               //新建admin1用户并增加到group1工作组
//给admin1用户设置密码
# passwd admin1
 Changing password for user it.
 New password: xxx
 BAD PASSWORD: it is based on a dictionary word
 BAD PASSWORD: is too simple
 Retype new password: xxx
 passwd: all authentication tokens updated successfully.

//新增组:
# groupadd group1  //新建group1工作组
# usermod -G group1 admin1 //给已有的用户增加工作组

删除

//删除用户:
# userdel peter
//删除工作组
# groupdel peter

禁止root登录

# vi /etc/ssh/sshd_config
PermitRootLogin no  //将#PermitRootLogin yes修改
# service sshd restart
点赞

发表评论

邮箱地址不会被公开。 必填项已用*标注