shivanshu@<host> ls -l hello.sh 
-rw-r-xr-x 1 shivanshu users 63 Sep  7 17:34 hello.sh

So I am clearly the owner of the file. I am able to change normal permissions like r, w, x using chmod command. However, when I try to do setuid on this file, I get an error

shivanshu@<host> chmod u+s hello.sh
shivanshu@<host> chmod: changing permissions of 'hello.sh': Operation not permitted

Note that I tried it with sudo, as well as with other files like text files instead of .sh files.

Why is this happening? I cannot figure it out based on doing some google search

P.S. - Comment on stack overflow post told me to post here

  • 1
    Is the file on a filesystem that supports the setuid permission, and has it been mounted with the 'nosuid' option? Sep 12 at 4:34
  • I do not know that since its a pre-configured work system, I can see that files like /usr/bin/passwd have the setuid permission, other than that, how can I check if the directory I am working in supports suid or not? Thanks Sep 12 at 4:50
  • 1
    Start by looking at findmnt, such as findmnt -T . -u, to see the filesystem type and all mount options. Keep in mind /usr is not necessarily going to be the same mount or filesystem as your data directory, especially on a pre-configured work system. Sep 12 at 4:55
  • oh ok, i just tried findmnt -T . -u and the return value specify nosuid in the OPTIONS column. So this means I cannot do chmod u+s, g+s etc on any type of file. Thanks a lot for the help Sep 12 at 4:57
  • Advice to newcomers: If an answer solves your problem, please accept it by clicking the large check mark (✓) next to it and optionally also up-vote it (up-voting requires at least 15 reputation points). If you found other answers helpful, please up-vote them. Accepting and up-voting helps future readers. See the relevant help-center article Sep 13 at 0:36

1 Answer 1


As you've found out, the filesystem that your files are on has been deliberately mounted with the 'nosuid' option to disable usage of setuid/setgid, presumably as a security precaution.

In addition to that, Linux only honors the setuid bit on compiled (ELF) executables – not on scripts. Even though you can "chmod u+s" a script, it will have no effect when that script is run.

Finally, Bash deliberately drops all unwanted privileges on startup, so even if setuid did work on scripts in general, it still would not work on scripts that use #!/bin/bash.

You must log in to answer this question.

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