当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 9 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : sudoers不知哪里错了
帖子发表于 : 2016-02-28 7:41 

注册: 2015-01-02 15:32
帖子: 241
系统: Debian
送出感谢: 25
接收感谢: 5
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
yangdawei 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



代码:
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 10 <<<
>>> /etc/sudoers: syntax error near line 11 <<<
>>> /etc/sudoers: syntax error near line 12 <<<
>>> /etc/sudoers: syntax error near line 13 <<<
>>> /etc/sudoers: syntax error near line 14 <<<
>>> /etc/sudoers: syntax error near line 16 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
parse error in /etc/sudoers near line 9


页首
 用户资料  
 
2 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 10:02 

注册: 2009-08-04 16:33
帖子: 16891
送出感谢: 21
接收感谢: 1826
引用:
sudoers不知怎么改错了

請把你修改的完整指令 貼上來


页首
 用户资料  
 
3 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 10:17 

注册: 2015-01-02 15:32
帖子: 241
系统: Debian
送出感谢: 25
接收感谢: 5
引用:
請把你修改的完整指令 貼上來


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 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
yangdawei ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL


然后更新:
source sudoers
报错信息:
代码:
bash: Defaults: command not found
bash: Defaults: command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: sudoers: line 19: syntax error near unexpected token `('
'ash: sudoers: line 19: `root   ALL=(ALL:ALL) ALL


检查语法:
visudo -c
代码:
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 9 <<<
>>> /etc/sudoers: syntax error near line 10 <<<
>>> /etc/sudoers: syntax error near line 11 <<<
>>> /etc/sudoers: syntax error near line 12 <<<
>>> /etc/sudoers: syntax error near line 13 <<<
>>> /etc/sudoers: syntax error near line 14 <<<
>>> /etc/sudoers: syntax error near line 15 <<<
>>> /etc/sudoers: syntax error near line 16 <<<
>>> /etc/sudoers: syntax error near line 17 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
>>> /etc/sudoers: syntax error near line 18 <<<
parse error in /etc/sudoers near line 9


页首
 用户资料  
 
4 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 10:21 

注册: 2009-08-04 16:33
帖子: 16891
送出感谢: 21
接收感谢: 1826
引用:
請把你修改的完整指令 貼上來

1. 你使用什麼方法或指令修改 sudoers ?
請貼上來完整指令

2. 你修改 sudoers 期望達到麼目的 ?


页首
 用户资料  
 
5 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 11:31 

注册: 2015-01-02 15:32
帖子: 241
系统: Debian
送出感谢: 25
接收感谢: 5
代码:
    
引用:
請把你修改的完整指令 貼上來

1. 你使用什麼方法或指令修改 sudoers ?
請貼上來完整指令


代码:
su
visudo /etc/sudoers


2.
引用:
你修改 sudoers 期望達到麼目的 ?


开始尝试用visudo打开看看sudoers,但因来知道其操作方式,操作不当,退出后即出现了上述问题。

此后再尝试修改sudoers就使用vi了。


页首
 用户资料  
 
6 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 12:02 
头像

注册: 2011-03-20 13:12
帖子: 4521
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
yangdawei 写道:
source sudoers 报错信息:

sudoers 不是 bash 脚本
引用:
$ help source
source: source filename [arguments] - Execute commands from a file in the current shell.


Ubuntu 出现这种问题是比较难办的。因为默认没有 root 密码,sudoers 损坏就意味着丢失 root 权限。可用 pkexec 提权修复
Debian 问题不大,直接用 su 即可

引用:
sudoers: syntax error near line 9 <<<

这个原因未知,需再研究


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户


页首
 用户资料  
 
7 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 16:35 

注册: 2015-01-02 15:32
帖子: 241
系统: Debian
送出感谢: 25
接收感谢: 5
可能是文件之外的问题,因为工作需要,重做了系统。这个sudoers不搞清楚了轻易不能碰了。


页首
 用户资料  
 
8 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 20:04 

注册: 2009-08-04 16:33
帖子: 16891
送出感谢: 21
接收感谢: 1826
引用:
su
visudo /etc/sudoers

引用:
此后再尝试修改sudoers就使用vi了。

1. 這是錯誤的操作指令
1-1. 正確指令是
sudo visudo
1-1-1. 不必指名 /etc/sudoers
因為它 就專為修改 /etc/sudoers 而設
1-1-1-1. http://manpages.ubuntu.com/manpages/wil ... udo.8.html
visudo — edit the sudoers file

2. 在 Ubuntu 新手 對於 權限 / uid / gid 不熟悉前
不建議 使用 root 登入 也不建議 切換成 root 身份
2-1. 使用非 root 登入 需要 root 權限時 加 sudo / gksudo 在指令前面 參見
https://help.ubuntu.com/community/RootSudo#Usage
2-2. 如果要給登入的帳號 能夠使用 sudo / gksudo 行使 root 的權利
只要把該非 root 使用者帳號 使用 usermod 指令 加入 sudo 群組即可
http://manpages.ubuntu.com/manpages/wil ... mod.8.html
usermod - modify a user account
引用:
因为工作需要,重做了系统

3. 抱歉 太晚回覆你

4. 以後 有需要 再參閱
4-1. https://help.ubuntu.com/community/Sudoers
Sudoers
4-2. https://www.digitalocean.com/community/ ... and-centos
How To Edit the Sudoers File on Ubuntu and CentOS
4-3. 再強調 新手 不熟悉 ubuntu 權限 / uid / gid 前
不建議 使用 root 登入 也不建議 切換成 root 身份
4-4. 也不建議你 任意改變 /etc/sudoers 檔案
4-5. 提供前面文章 僅僅提供你參考 不是鼓勵你現在就動手去改它


页首
 用户资料  
 
9 楼 
 文章标题 : Re: sudoers不知哪里错了
帖子发表于 : 2016-02-28 20:28 

注册: 2015-01-02 15:32
帖子: 241
系统: Debian
送出感谢: 25
接收感谢: 5
非常感谢poloshiao的耐心指导。


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 9 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译