Allow specific username access to mount and umount on linux without sudo

At some point in time I had a couple machines that had cronjobs running as a non-root username that would ensure a mounted directory exists and was working. I don’t remember why I didn’t use root at the time. Since mount and umount require sudo access, the cronjob would always fail.

This will allow a specific username access to mount and umount without the need to use sudo.

First open the file using visudo (you must use visudo).

sudo visudo -f /etc/sudoers.d/myOverrides

 Then add the following line, replacing MYUSERNAME with your system username.

MYUSERNAME ALL=(ALL) NOPASSWD:/bin/mount, NOPASSWD:/bin/umount

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s