0

I want to run a command automatically. The problem is that it may only be run after I logged in and that it requires superuser privileges. I've heard of suid before, so I thought I'd use it for this.

I created a script /mountDropbox.sh which only contains the bash shebang and a mount command. Then I ran this command to set the setuid bit:

sudo chmod 4755 /mountDropbox.sh

However, when I try to run it as a normal user, mount complains about not being executed with superuser privileges:

$ /mountDropbox.sh 
mount: only root can do that

Why does this happen? How can I achieve that this file is always executed with superuser privileges?

I use Ubuntu 16.04 with kernel 4.4.0-134-generic. / is an ext4 file system.

$ ll /mountDropbox.sh 
-rwsr-xr-x 1 root root 77 Sep  4 17:35 /mountDropbox.sh*
UTF-8
  • 3,237

0 Answers0