8

I find it much easier to edit files directly rather than remember commands like useradd -g, usermod, groupmod, etc. Is there anything wrong with just editing /etc/group directly?

9

Editing the group, passwd, and shadow files directly is safe, but in order to do so you should use the vigr and vipw commands.

When using vigr or vipw, locks are applied to the files in order to prevent concurrent editing which can lead to file corruption.

  • 1
    Can you also come up with a vishadow to edit /etc/shadow that way? – ott-- Jun 12 '13 at 19:43
  • Usually you should NEVER edit the /etc/shadow file directly. – mdpc Jun 12 '13 at 19:59
  • 2
    @ott--: Sometimes editing the /etc/shadow file directly is necessary or desirable. Some variants of vipw support a -s option to do so. Just be careful and make sure you understand what you are doing. Read this or something similar. – user26112 Jun 12 '13 at 20:02
1

Apart from not making mistakes while doing so, you have to be aware that on systems where LDAP is setup useradd etc. can also update the data there.

Essentially if only /etc/group, and only a limited amount of lines in there, are effected you might as well edit the file.

If you have /etc under revision control (mercurial, git) it is easy to roll-back changes.

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.