ubuntu下删除和新建用户(并有su权限)
http://blog.csdn.net/speedme/article/details/8206144
ubuntu下删除和新建用户(并有su权限)
如何创建ubuntu新用户?
输入:sudo adduser username,系统会提示以下信息:
(中文的ubuntu系统)
正在添加用户“username”...
正在添加新组“username”(1001)...
正在添加新用户“username”(1001)到组“username”...
创建主目录“/home/username”...
正在从“/etc、skel”复制文件...
输入新的 UNIX 口令:(此处大家注意,不是输入你当前用户的密码,而是输入你要创建新用户的密码)
重新输入新的 UNIX 口令:(再输一次即可)
passwd:已成功更新密码
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []: yangyang (输入新用户的名称)
Room Number []:
Work Phone []:
Home Phone []:
Other []:
这个信息是否正确? [Y/n] y
到了这一步,新用户已经添加成功了,此时我们可以打 ls /home查看一下,如果显示 username yang,则代表用户创建成功。
(英文版本的ubuntu系统)
rootroot@rootroot-virtual-machine:~/wyb$
rootroot@rootroot-virtual-machine:~/wyb$ sudo adduser admin(如果在这个终端第一次使用sudo或者sudo过期会提示输入密码!!!!)
Adding user `admin' ...
Adding new group `admin' (1001) ...
Adding new user `admin' (1001) with group `admin' ...
Creating home directory `/home/admin' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for admin
Enter the new value, or press ENTER for the default
Full Name []: (名字可以不用输入,直接回车。以下都可以直接回车!)
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
rootroot@rootroot-virtual-machine:~/wyb$
rootroot@rootroot-virtual-machine:~/wyb$ ls /home
admin lost+found rootroot
rootroot@rootroot-virtual-machine:~/wyb$
rootroot@rootroot-virtual-machine:~/wyb$ ll /home
total 32
drwxr-xr-x 5 root root 4096 11月 2 20:09 ./
drwxr-xr-x 23 root root 4096 11月 2 17:26 ../
drwxr-xr-x 2 admin admin 4096 11月 2 20:09 admin/ (可以看见除了装系统时生成的用户名:rootroot之外,还有这个用户名)
drwx------ 2 root root 16384 11月 2 16:39 lost+found/
drwxr-xr-x 18 rootroot rootroot 4096 11月 2 19:28 rootroot/
rootroot@rootroot-virtual-machine:~/wyb$
如何让新建的用户拥有su权限?
新建立的admin用户是特权用户,可以使用sudo来提升自己的权限。
rootroot@rootroot-virtual-machine:~/wyb$
rootroot@rootroot-virtual-machine:~/wyb$ su admin
Password:
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
admin@rootroot-virtual-machine:/home/rootroot/wyb$
admin@rootroot-virtual-machine:/home/rootroot/wyb$
admin@rootroot-virtual-machine:/home/rootroot/wyb$
admin@rootroot-virtual-machine:/home/rootroot/wyb$ sudo apt-get install samba
[sudo] password for admin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
samba is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
admin@rootroot-virtual-machine:/home/rootroot/wyb$
但是其他的用户(比如:wenyb)只有普通权限,无法使用sudo来提升自己的权限。
rootroot@rootroot-virtual-machine:/etc$ sudo adduser wenyb
Adding user `wenyb' ...
Adding new group `wenyb' (1002) ...
Adding new user `wenyb' (1002) with group `wenyb' ...
Creating home directory `/home/wenyb' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for wenyb
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
rootroot@rootroot-virtual-machine:/etc$
rootroot@rootroot-virtual-machine:/etc$ su wenyb
Password:
wenyb@rootroot-virtual-machine:/etc$
wenyb@rootroot-virtual-machine:/etc$ sudo apt-get install samba
[sudo] password for wenyb:
wenyb is not in the sudoers file. This incident will be reported.
wenyb@rootroot-virtual-machine:/etc$
解决方法:
http://www.cnblogs.com/zox2011/archive/2013/05/28/3103824.html
xxx is not in the sudoers file.This incident will be reported.的解决方法
1、切换到root用户下,怎么切换就不用说了吧,不会的自己百度去。
2、添加sudo文件的写权限,命令是:
chmod u+w /etc/sudoers
3、编辑sudoers文件
vi /etc/sudoers
找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)
ps:这里说下你可以sudoers添加下面四行中任意一条
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL
第一行:允许用户youuser执行sudo命令(需要输入密码)。
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码)。
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码。
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码。
4、撤销sudoers文件写权限,命令:
chmod u-w /etc/sudoers
这样普通用户就可以使用sudo了。
rootroot@rootroot-virtual-machine:~$ sudo cp /etc/sudoers /etc/sudoers.bak1
[sudo] password for rootroot:
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ sudo cp /etc/sudoers .
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ ll sudoers
-r--r----- 1 root root 745 11月 2 20:28 sudoers
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ chmod 777 sudoers
chmod: changing permissions of ‘sudoers’: Operation not permitted
rootroot@rootroot-virtual-machine:~$ sudo chmod 777 sudoers
rootroot@rootroot-virtual-machine:~$ gedit sudoers
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ sudo cp sudoers /etc/
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ ll /etc/sudoers
-r--r----- 1 root root 771 11月 2 20:30 /etc/sudoers
rootroot@rootroot-virtual-machine:~$
rootroot@rootroot-virtual-machine:~$ su wenyb
Password:
wenyb@rootroot-virtual-machine:/home/rootroot$ sudo apt-get install samba
[sudo] password for wenyb:
Sorry, try again.
[sudo] password for wenyb:
Reading package lists... Done
Building dependency tree
Reading state information... Done
samba is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
wenyb@rootroot-virtual-machine:/home/rootroot$
文件sudoers的内容:
#
# 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
wenyb 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
如何删除ubuntu用户?
ubuntu删除用户同样是在终端下操作的,需要注意的是,如果要删除的用户当前已登陆,是删除不掉的,必须注销掉当前用户切换为另一个用户下,才能删除。举个例子,刚才我新建立了一个用户为 yang 的用户,例如我现在用用户 yang 登陆了桌面,此时如果我想删除 yang 这个用户,是删除不掉的。正确的操作方法是,我注销掉 yang,然后使用 root 登陆到桌面,再删除 yang 即可。
删除ubuntu用户的命令比较容易记:sudo userdel username,例如我想删除 yang ,则输入:sudo userdel yang,删除成功后,系统无任何提示。
用户间切换:
可以使用:su username,
需要输入口令。
ubuntu下删除和新建用户(并有su权限)的更多相关文章
- Ubuntu下如何将普通用户提升到root权限
在ubuntu的系统操作中,我们经常会使用到系统权限的,因为权限不足,导致在一些操作当中非常麻烦.要获取权限,最长使用的方法就是使用sudo指令,但是来回使用还是比较麻烦,有没有直接提升我们的用户权限 ...
- [Linux]Ubuntu下如何将普通用户提升到root权限
转至:http://jingyan.baidu.com/album/6181c3e0780131152ef153ff.html?picindex=0&qq-pf-to=pcqq.c2c 在u ...
- ubuntu下修改进入root用户和修改文件权限
(1)进入root用户 su root 密码:设置的root密码 (2)修改文件权限 sudo chmod +777 file (3)执行shell ./shellfile (4)编写shell 第 ...
- Ubuntu下删除卸载程序图标
Ubuntu下删除卸载程序图标 方法一:直接在终端输入命令alacarte.可以任意增.改.隐藏.显示菜单,但无法删除菜单,即使拥有root权限. 方法二:注意几个目录和文件./usr/share/a ...
- Ubuntu下删除mysql数据库
Ubuntu下删除mysql数据库 sudo apt-get autoremove --purge mysql-server-5.7 sudo apt-get remove mysql-server ...
- Ubuntu下如何修改文件或者文件夹的权限
Ubuntu下如何修改文件或者文件夹的权限------chmod的亲身测试 具体原理如下: Linux系统下如何修改文档及文件夹(含子文件夹)权限,我们来看一下. 一 介 ...
- ubuntu在命令行新建用户后无法进入桌面的原因
在命名行模式下 用useradd新建一个用户后 在图形界面输入密码无法登陆 这是因为未对新建的用户进行任何配置 用adduser命令新建用户即可进入桌面 下面说一下useradd 和 adduser的 ...
- linux新建用户并赋管理员权限
输入useradd新建一个用户 [root@java-devenv ~]# useradd yaoqi [root@java-devenv ~]# passwd yaoqi passwd 是修改用户密 ...
- navicat新建用户,并赋予权限
一.新建用户 二.设置主机和密码 主机%的意思是允许用户本地登入和远程登入. 三.选择表或者视图 右键,选择设置权限 四. 选择添加权限. 五. 选择用户以及Select 和 Show View ...
随机推荐
- Outlook2010 没有Exchange Server,怎么自动回复邮件?
步骤 1:创建邮件模板 单击“开始”>“新建邮件”. 在邮件正文中,键入要作为自动答复发送的邮件. 在邮件窗口中,单击“文件”>“另存为”. 在“另存为”对话框中的“保存类型”列表中,单击 ...
- Linux/UNIX之进程环境
进程环境 进程终止 有8种方式使进程终止,当中5中为正常终止,它们是 1) 从main返回 2) 调用exit 3) 调用_exit或_Exit 4) 最后一个 ...
- C#在Linux下获取文件夹信息(所在磁盘总大小,使用空间,已用空间,使用率)
1.第一种使用shell命令实现: private DiskInfo LinuxGetFolderDiskInfo(string path) { DiskInfo disk = new DiskInf ...
- 在 Web 开发中,img 标签用来呈现图片,而且一般来说,浏览器是会对这些图片进行缓存的。
在 Web 开发中,img 标签用来呈现图片,而且一般来说,浏览器是会对这些图片进行缓存的. 比如访问百度,我们可以发现,图片.脚本这种都是从缓存(内存缓存/磁盘缓存)中加载的,而不是再去访问一次百度 ...
- C# 最基本的涉及模式(单例模式) C#种死锁:事务(进程 ID 112)与另一个进程被死锁在 锁 | 通信缓冲区 资源上,并且已被选作死锁牺牲品。请重新运行该事务,解决方案: C#关闭应用程序时如何关闭子线程 C#中 ThreadStart和ParameterizedThreadStart区别
C# 最基本的涉及模式(单例模式) //密封,保证不能继承 public sealed class Xiaohouye { //私有的构造函数,保证外部不能实例化 private ...
- LeetCode_Mysql_Second Highest Salary
176. Second Highest Salary 1. 问题描写叙述: 写一个sql语句从 Employee 表里获取第二高位的工资. 2. 解决思路: 这道题非常easy,就当热身了.首先用ma ...
- 浅析分布式数据库中间件DDM
前言 DDM是什么?这是华为云Paas推出的分布式数据库中间件,DDM(Distributed Database Middleware)是一个实现了Mysql协议栈的服务器,前端用户可以把它看做一个数 ...
- UIColor与十六进制字符串互转
UIColor转十六进制字符串 方法一:经过测试发现部分颜色会转化为#fffff(五个f),转化残缺导致最后颜色无法还原,不推荐使用. // UIColor转#ffffff格式的字符串 + (NSSt ...
- ASP.NET Core开发Docker部署
ASP.NET Core开发Docker部署,.NET Core支持Docker 部署运行.我们将ASP.NET Core 部署在Docker 上运行. 大家可能都见识过Docker ,今天我们就详细 ...
- python-----列表生成式和列表生成器表达
列表表达式: 程序一: 常规写法: L = [] for x in range(1, 11): L.append(x * x) print(L) #[1, 4, 9, 16, 25, 36, 49, ...