0

I am very new to CentOS and I am trying to edit my sudoers file. First I am told to run the following:

$chmod a+w /etc/sudoers

and right away I hit an error:

bash: a+w: command not found

What did I do wrong already?!

Thanks in advance

1
  • 3
    Even if someone tells you how to succeed in issuing this command, do not. If you succeed, you will probably cause the 'sudo' command to fail until you change the mode back. But conceptually, this command will permit anyone to edit this sensitive security-critical file. Mar 5, 2014 at 5:53

2 Answers 2

2

Take out the $ in chmod, I imagine that someone was just including a symbol to denote the beginning of your input.

If you type

su input the root password

chmod a+w /etc/sudoers

that should work fine.

Note that you will need root access to modify the file.

5
  • How +1? Assuming OP is setting up his sudo file, he won't be able to use sudo. It's not turned on in Centos
    – mcalex
    Mar 5, 2014 at 5:11
  • you're right, you wouldn't have to sudo the command, but assuming that this user is editing the sudoers file he would have to have some root access. (ie the root user login credentials) so he will still need root access. Without root access you're not going to edit this file.
    – Eric
    Mar 5, 2014 at 5:14
  • Yes, root access, but through 'su', not 'sudo'.
    – mcalex
    Mar 5, 2014 at 5:17
  • note that I have edited my answer taking this into account.
    – Eric
    Mar 5, 2014 at 5:18
  • Much improved :-) visudo is still the preferred option, however.
    – mcalex
    Mar 5, 2014 at 6:03
0

hmmmm, two things.

1) Your syntax for chmod is fine (though there is usually a space between the '$' of the prompt and the first character in the command). This is the correct way to change the mode of a file. However, the /etc/sudoers file (like most files in /etc) are system files and need to be treated carefully.

2) There is a procedure for editing the sudoers file. You make changes with the use of 'visudo' This process saves you both from changing the permissions (ie running 'chmod' on the file) potentially opening your system to attack and from accidentally saving errors in the file as it won't allow you to save a 'broken' sudoers.

You should run the visudo command instead of either changing the mode of the suoders file, or editing it as the superuser (root), as both can potentially be very damaging.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .