When I execute a script that uses the "mount" command, I need to enter my sudo password. However, I can launch a file explorer like nautilus and mount a filesystem from that application, without ever having to enter a password. What is the mechanism that allows some programs to execute commands that normally require root privilege?

My first instinct was that it is suid, but I changed the owner of a script to root and set the suid flag, i.e., "chmod 4777", but still I cannot perform things in the script that require root privilege.


1 Answer 1


Despite the fact that suid shell scripts are always seen as a security risk, you need to specifc the -p shell flag to prevent the shell from restoring the uid to the real uid.

So you should add:

#!/bin/sh -p

to the beginning of your script

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