Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On an Ubuntu Linux I have a directory with the setuid bit set (drwsr-xr-x) which I want to unset.

Neither chmod 755 nor chmod 0755 nor chmod 00755 (I though maybe the first 0 is interpreted as just "this is octal") cleared the setuid bit. However, chmod u-s did.

What is the correct numeric mode to clear the setuid bit?

share|improve this question

migrated from serverfault.com Jan 13 '13 at 7:39

This question came from our site for professional system and network administrators.

add comment

1 Answer

up vote 4 down vote accepted

Interestingly. this seems to be impossible using GNU chmod, and that's a feature. From the info entry on chmod on my system; note how, whilst the entry on setting the bits makes reference to symbolic and numeric modes, the entry on clearing them refers only to symbolic (ug-s) mode:

27.4 Directories and the Set-User-ID and Set-Group-ID Bits

These convenience mechanisms rely on the set-user-ID and set-group-ID bits of directories. If commands like chmod' and mkdir' routinely cleared these bits on directories, the mechanisms would be less convenient and it would be harder to share files. Therefore, a command like `chmod' does not affect the set-user-ID or set-group-ID bits of a directory unless the user specifically mentions them in a symbolic mode, or sets them in a numeric mode.

[...]

If you want to try to set these bits, you must mention them explicitly in the symbolic or numeric modes, e.g.:

[...]

If you want to try to clear these bits, you must mention them explicitly in a symbolic mode, e.g.:

[...]

This behavior is a GNU extension. Portable scripts should not rely on requests to set or clear these bits on directories, as POSIX allows implementations to ignore these requests.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.