Advertisements

Add yourself to the sudoers list on FreeNAS 8

FreeNAS 8 does not, by default, allow anyone to use the su command. One practice is to allow members of the wheel group access to su any command. This can be accomplished easily by editing the /usr/local/etc/sudoers file and adding the following line:

%wheel ALL=(ALL) ALL

However, this will be lost on reboot. You can write an sh script to update this file with the following two lines:

echo >> /usr/local/etc/sudoers
echo "%wheel ALL=(ALL) ALL" >> /usr/local/etc/sudoers

You can run this sh script from the web shell and it will update the sudoers file.

It can be cumbersome (and problematic) to lose this on every reboot. So here’s how you can edit the base sudoers file so it’s ready when the system reboots:

First, remount the root filesystem read-write:

mount -wu /

Note that if you’re running FreeNAS from a USB stick, filesystem commits can take several moments to commit while the system is mounted read-write. That’s normal, though annoying.

Next, edit the /conf/base/etc/local/sudoers file (you can use the two statements above) to add:

%wheel ALL=(ALL) ALL

lastly, remount the root filesystem read-only again:

mount -ru /

That’s it. However, if you upgrade FreeNAS in the future, this change will be lost. Re-edit the file again.

If you have questions or suggestion, please feel free to leave them in the comments below. Thank you!

Advertisements