CentOS7 minimal 创建用户user及sudo
2018-03-26 本文已影响0人
余带盐
- 创建用户(在
root下)
- 账号
adduser account
或
useradd -d /home/account -m account- 密码
passwd account- 切换用户
su account- 进入用户目录
cd /home/account或cd $HOME- 切换回
root
su- 给任何非
root用户(如coreteks)用户添加sudo
root用户:visudocoretek ALL=(ALL) ALL切换回
coretek
- 用
account用户执行root权限
sudo+ 命令
- 无需密码使用sudo
- 添加sudoers文件的写权限
chmod u+w /etc/sudoers- 配置sudo无需密码
vi /etc/sudoers
root ALL=(ALL) ALL下添加cephuser ALL=(ALL) NOPASSWD: ALL
- 删除写权限
chmod u-w /etc/sudoers
- 创建组和用户
创建git组:
groupadd git
创建git组中的git用户
adduser git -g git
注:如果adduser git,那么会默认创建git组和git用户,可以查看用户和查看组知道
- 查看用户和查看组
查看用户
cat /etc/passwd
查看组
cat /etc/group
- 禁止用户登录
vi /etc/passwdgit:x:1000:1000::/home/git:/bin/git-shell
注:sudo输入一次密码之后就会保存,在登出之前,就算是输入错误的密码,也还是调用缓存的密码
echo '123456'|sudo -S dmidecode -s system-uuid
echo '12345'|sudo -S dmidecode -s system-uuid