-u FILE (conditional operator)

true if the file exists and its set-user-id bit is set, i.e. the SETUID bit. false if FILE does not exist or does not have the SETUID bit set.

-g is for the set-group-id bit.

Examples

Different ways to test if a file has the SETUID bit set:
1
2
3
4
test -u ~/bin/cmd && echo "SETUID set"
[ -u ~/bin/cmd ] && echo "SETUID set"
# Bash
[[ -u ~/bin/cmd ]] && echo "SETUID set"
Set the SETUID bit:
1
chmod u+s /usr/local/bin/my-cmd
BashSupport Pro 是一个 支持 -u 的 Bash 集成开发工具 – 马上试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款