0

I fix that /etc/sudoers near line 23 error by using pkexec visudo command. But I don't know the reason. Can any one tell me the reason? And how to prevent these type of error in future?

My File Like this:

#
# 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
Defaults !lecture, !tty_tickets, !fqdn 
Defaults !lecture, !tty_tickets, !fqdn 
Defaults !lecture, !tty_tickets, !fqdn 
Defaults !lecture, !tty_tickets, !fqdn 
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^

I can Fix this problem by deleting Last Line. But Don't know the reason.

4
  • 4
    Show us line 23 (22, 23, 24 might be better) otherwise this is pretty impossible to answer.
    – Rinzwind
    Feb 20, 2015 at 15:19
  • # 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 Defaults !lecture, !tty_tickets, !fqdn Defaults !lecture, !tty_tickets, !fqdn Defaults !lecture, !tty_tickets, !fqdn Defaults !lecture, !tty_tickets, !fqdn ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
    – Nallasivam
    Feb 21, 2015 at 5:19
  • You should add it to you question and format it please (and use "more" not "cat" please).
    – Rinzwind
    Feb 21, 2015 at 7:33
  • Did you run a script that changes sudoers? If you did, whoever wrote it is an idiot.
    – muru
    Feb 21, 2015 at 10:11

1 Answer 1

2

Always use visudo to edit sudoers!

To fix this, use visudo to remove

  • the last line,

    ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^`
    
  • and the duplicate lines preceding it.

    Defaults !lecture, !tty_tickets, !fqdn
    Defaults !lecture, !tty_tickets, !fqdn
    Defaults !lecture, !tty_tickets, !fqdn
    

    If it still gives you trouble, comment the only remaining instance of them (put # in front of it). I don't know what the users/groups lecture, tty_tickets, and fqdn are for, but they're not part of a default Ubuntu installation.

You were asking, how to prevent such a thing in the future:

  • Don't edit sudoers without a syntax checker like visudo!

  • Don't run idiotic programs as super-user, that try to make unchecked changes to /etc/sudoers! Additions to sudoers should be made as new files in /etc/sudoers.d/.

2
  • Thanks David, I Disable Password using this command. I thing it will affect for sudoers.d file. sudo sed -i '26d' /etc/sudoers sudo sed -i -e '26i%sudo ALL=NOPASSWD: ALL' /etc/sudoers
    – Nallasivam
    Feb 26, 2015 at 10:12
  • Did you read the very first line of my answer? Don't use sed, use visudo to edit sudoers! If you don't like the vi editor, set the VISUAL or EDITOR environment variable to your favourite editor (see man visudo for more info on this). If you want to allow password-less sudo execution, refer to Execute sudo without Password?. Feb 26, 2015 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.