What is SUID and give a real example?
IntermediateConceptPermissions, Users & sudo
Answer
SUID (4000) on an executable makes it run with the file owner's effective UID, not the caller's. passwd is SUID root so a normal user can update /etc/shadow.
ls -l /usr/bin/passwd # -rwsr-xr-x
chmod u+s binary; chmod 4755 binary
find / -xdev -perm -4000 -type f 2>/dev/null # audit SUID files
Linux ignores SUID on scripts; it only works on binaries. Unexpected SUID binaries are a privilege-escalation red flag.
More on Permissions, Users & sudo
Explain the rwx permission model for files and directories.BeginnerHow does octal notation work in chmod?BeginnerWhat does chown do and who can run it?IntermediateWhat is umask and how is the final permission calculated?IntermediateWhat does SGID do on files versus directories?IntermediateWhat does a capital S or T in `ls -l` output mean?Intermediate