Is /etc/sudoers file only suppose to have read only permissions?

Yes, /etc/sudoers is supposed to have those permissions, being read-only for user and group, nothing else. The reason being that you aren't supposed to edit the sudoers file directly, but by using the visudo wrapper, which provides some sanity checking before writing a new sudoers file.

You can control what editor visudo uses by setting the VISUAL alt. EDITOR environment variable.

$ sudo EDITOR=vi visudo

Linux: Delete / Remove User Account

userdel userName

Howto: Linux Add User To Group

 useradd -G {group-name} username

How can I add a new user as sudoer using the command line?

 sudo adduser <username> sudo
sudo deluser pi to delete just the user account
You don’t have to, but if you want to remove the /home/pi directory as well, use…
sudo deluser -remove-home pi
 
Group membership is only evaluated upon login, so if the user is already logged in they'll have to log out and in before they can use their new permissions.
This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):
# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL

 

How do I change pi's password?

At the very least, you should change the password for the pi account, as anybody with a RPi will be able to log onto yours. To do this, run passwd from the command line and follow the prompts.

How do I change pi's username?

If, like me, you want to use your own name, you want to use usermod like this:
usermod -l newname -d newname -m oldname

No comments:

Post a Comment