CentOS7 minimal 创建用户user及sudo

2018-03-26  本文已影响0人  余带盐
  1. 账号
    adduser account

    useradd -d /home/account -m account
  2. 密码
    passwd account
  3. 切换用户
    su account
  4. 进入用户目录
    cd /home/accountcd $HOME
  5. 切换回root
    su
  6. 给任何非root用户(如coreteks)用户添加sudo
    root用户:visudo
coretek ALL=(ALL)       ALL

切换回coretek

  1. account用户执行root权限
    sudo + 命令
  1. 添加sudoers文件的写权限
    chmod u+w /etc/sudoers
  2. 配置sudo无需密码
    vi /etc/sudoers
    root ALL=(ALL) ALL下添加
cephuser ALL=(ALL)  NOPASSWD: ALL
  1. 删除写权限
    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/passwd

git: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

上一篇 下一篇

猜你喜欢

热点阅读