今天搜索了一下,发现ubuntu下打sudo默认用户是能够得到系统权限,而centos不行,
也就是执行sudo +命令时,报错
lee is not in the sudoers file. This incident will be reported.
网上终于找到答案解决了。
1.输入"su root",得到系统权限
2.更改文件的读写权限。增长写权限
输入命令"chmod u+w /etc/sudoers"。
3.编辑/etc/sudoers文件。
输入命令"vim /etc/sudoers",输找到这一行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),而后保存(就是先摁一下Esc键,而后输入":wq")退出。 撤销文件的写权限。
4.输入命令"chmod u-w /etc/sudoers",撤销写权限。 ubuntu
可是在 sudo su root时还会要求输入当前用户密码,咱们不想输入密码能够更改文件 /etc/sudoers 找到 vim
# %wheel ALL=(ALL) NOPASSWD: ALL centos
复制此行,并去掉# ide
把whell改成你当前的用户便可
spa