file-test

Bash -u — set-user-ID mode bit

Checks the set-user-ID mode bit on a file. It does not establish that execution would change identity; filesystem and OS policies matter. The example uses a non-executable empty file owned by the learner and never executes it. Run the example independently in a fresh private directory. Expected output (one item per line): set=0; cleared=1.

Formal Syntax & Structure

bash syntaxbash
[[ -u path ]]

Parameters & Attributes

NameTypeDescription
pathpathFile or directory pathname to inspect.

Return Value

exit status

0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.

Working Example

Example Snippetbash
touch samplechmod 4600 sample[[ -u sample ]]; printf 'set=%s\n' "$?"chmod 0600 sample[[ -u sample ]]; printf 'cleared=%s\n' "$?"
Bash Reference