In Linux, how can I identify if a binary file is set-user-ID?
Can I use
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
executing ls -l you will get something like:
-rwSr--r-- 1 user user 8111573 Sep 26 2012 net-snmp.tar
where the S (can be also s) indicate this file have SUID set
S is set when you do not have execution flag set
s is set when you have execution flag set
Either manually look at the file with
ls -l filename, or from a script you can use
[ -u filename ] && echo SUID-bit is set
-u file True if file exists and its set-user-id bit is set.
The file mode bits listed are similar to symbolic mode specifications (*note Symbolic Modes::). But ‘ls’ combines multiple bits into the third character of each set of permissions as follows: ‘s’ If the set-user-ID or set-group-ID bit and the corresponding executable bit are both set. ‘S’ If the set-user-ID or set-group-ID bit is set but the corresponding executable bit is not set.