您的位置:首页 > 运维架构 > Linux

Centos5下的用户管理及开通sudo权限

2011-11-18 15:04 344 查看
查看命令

#列出所有用户
getent passwd

#查看在线用户
who

#查看用户登录历史记录
last


增加用户组

groupadd groupname


增加用户

useradd username -m -s /sbin/nologin -d /home/username -g groupname
-s /sbin/nologin 设置不能登陆 -s /bin/false(老方法) 也行
-d 设置用户主目录
-g 用户组
-m 创建用户目录

Options:
-b, --base-dir BASE_DIR       base directory for the home directory of the
new account
-c, --comment COMMENT         GECOS field of the new account
-d, --home-dir HOME_DIR       home directory of the new account
-D, --defaults                print or change default useradd configuration
-e, --expiredate EXPIRE_DATE  expiration date of the new account
-f, --inactive INACTIVE       password inactivity period of the new account
-g, --gid GROUP               name or ID of the primary group of the new
account
-G, --groups GROUPS           list of supplementary groups of the new
account
-h, --help                    display this help message and exit
-k, --skel SKEL_DIR           use this alternative skeleton directory
-K, --key KEY=VALUE           override /etc/login.defs defaults
-l, --no-log-init             do not add the user to the lastlog and
faillog databases
-m, --create-home             create the user's home directory
-M, --no-create-home          do not create the user's home directory
-N, --no-user-group           do not create a group with the same name as
the user
-o, --non-unique              allow to create users with duplicate
(non-unique) UID
-p, --password PASSWORD       encrypted password of the new account
-r, --system                  create a system account
-s, --shell SHELL             login shell of the new account
-u, --uid UID                 user ID of the new account
-U, --user-group              create a group with the same name as the user
-Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping


更改用户登录权限

#打开登录权限
usermod -s /bin/bash username

#禁用用户登录权限
usermod -s /sbin/nologin username

#更换用户组
usermod -G groupname username

关闭用户账号:
passwd username –l

重新释放:
passwd username –u


修改密码 passwd [username]

删除用户 userdel -r [username]

增加sudo权限

visudo -f /etc/sudoers


增加 yourusername ALL=(ALL) ALL

修改普通用户的.bash_profile文件,在PATH变量中增加 /sbin:/usr/sbin:/usr/local/sbin:/usr/kerberos/sbin

更改用户登录权限

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: