创建Ubuntu用户以及让新用户增加sudo权限
2013-12-26 12:47
337 查看
用户管理
增加用户
sudo adduser 用户名
删除用户
sudo deluser 用户名
修改当前用户的密码
passwd
修改用户密码
sudo passwd 用户名
修改用户资料
sudo chfn userid
如何禁用/启用某个帐户
sudo usermod -L 用户名 #锁定用户 sudo usermod -U 用户名 #解锁 或 sudo passwd -l 用户名 #锁定用户 sudo passwd -u 用户名 #解锁
增加用户到admin组,让其有sudo权限
sudo usermod -G admin -a 用户名
如何切换到其他帐号(需要该用户的密码)
su 用户名
如何切换到root帐号
sudo -s sudo -i sudo su
一、创建新用户(完整)
sunny@sunny-Lenovo:~$ sudo adduser haha //创建新用户haha [sudo] password for sunny: Adding user `haha' ... Adding new group `haha' (1004) ... Adding new user `haha' (1002) with group `haha' .. Creating home directory `/home/haha' ... Copying files from `/etc/skel' ... Enter new UNIX password: //输入新用户的密码 Retype new UNIX password: passwd: password updated successfully Changing the user information for haha Enter the new value, or press ENTER for the default Full Name []: cysys1 //输入新用户的全称 Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y
到了这一步,新用户已经添加成功了,此时我们可以打 ls /home查看一下,如果显示 username ,侧代表用户创建成功。
二、删除用户:
sodu userdel haha //删除haha用户
三、赋予新用户sudo权限
1、sudo vim /etc/sudoers 或者 sudo visudo
2、在最后一行加上: 用户名 ALL=(ALL:ALL) ALL
例如 : haha ALL=(ALL:ALL) ALL
# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d haha ALL=(ALL:ALL) ALL .
相关文章推荐
- C++中静态链接库与动态链接库的介绍与使用
- 转换:yyyyMMdd这样格式的字符串如何转datetime
- VS2008 Windows2003 无法在Web服务器上启动调试,与 Web 服务器通信时出现身份验证错误
- cocos2d-x 过度动画
- Starling TextField
- Openssl command到API转换--password和key、iv转化以及openssl进行gdb调试
- 克鲁斯卡尔算法
- Openssl command到API转换--password和key、iv转化以及openssl进行gdb调试
- web程序设计之javascript基础(2)
- AUPE学习第二章------UNIX标准化及实现1
- 2012年网贷平台全国排名
- 黑苹果的碎玉零玑
- LeetCode | Minimum Window Substring
- 鸟哥私房菜之认识 bash shell - 2
- 《实用OpenCV》<三> OpenCV内置Demo (2)
- 新进网贷的小散 感受
- jsp脚本提取struts2中action的属性值
- 红岭_资本翻番的魔术 转 想做网贷的请一定要读
- Javascript/Node.js 中的 this
- 工作便条ZHAOCM