Audit and correct dangerous permission changes on shared paths, then apply special bits correctly where they belong. Validate your fixes using long listings and numeric modes so the system behaves safely under real multi-user conditions.
A junior admin “fixed” access problems by loosening permissions in the wrong places. You’re brought in to investigate the damage, restore safe defaults, and apply special bits with intention. The priority is preventing cross-user deletion in shared directories and understanding when setuid and setgid are appropriate.
Permission issues are rarely isolated. A sloppy chmod can silently create a security incident. Your job is to restore correct behavior and prove it with evidence.
/tmp and
identify what is missing.
/tmp using numeric
mode.
x) to traverse and read
(r) to list names.
1777, 2770).
/tmp permissions.
ls -ld /tmp
This shows directory permissions, ownership, and whether the
sticky bit is enabled. In a multi-user system,
/tmp must be world-writable, but it must also
prevent users from deleting each other’s files.
# Bad state example (missing sticky bit):
drwxrwxrwx 2 root root 4096 Jul 18 12:00 /tmp
# Good state includes "t" at the end:
drwxrwxrwt ... /tmp
/tmp.
chmod 1777 /tmp
1777 means: sticky bit (1) plus
world-writable directory permissions (777). This
is the standard safe default for /tmp.
ls -ld /tmp
# Expect: drwxrwxrwt ... /tmp
setuid
setuid changes the effective user ID during execution, allowing a program to run with the file owner’s privileges. This is powerful and risky, so it must be used intentionally and sparingly.
chmod u+s /usr/local/bin/myscript
# OR
chmod 4755 /usr/local/bin/myscript
Symbolic mode is explicit and readable. Numeric mode is fast
and unambiguous. After applying setuid, validate with a long
listing and confirm an s appears in the owner
execute position.
ls -l /usr/local/bin/myscript
# Expect owner execute bit to show "s" (setuid).
2770
2 sets setgid on a directory so newly created
files inherit the directory’s group ownership.
770 means owner and group have full permissions,
and others have none.
chmod 2770 /srv/shared
ls -ld /srv/shared
# Expect: drwxrws--- ... /srv/shared
You likely changed the wrong path or you are looking at a
different mount namespace (containers). Re-run
ls -ld /tmp and confirm the trailing character
is t.
T means the sticky bit is set but the directory
does not have execute (x) for others. On
/tmp, you want drwxrwxrwt, not
drwxrwxrwT.
On many systems, setuid scripts are ignored for safety. This bit is intended for binaries that are audited and designed to run with elevated effective privileges.
If you applied chmod -R or setuid to more than a
single intended file, stop and roll back. Special bits
should be rare and tightly scoped.
This lab is mostly validation plus targeted permission fixes. Your cleanup is confirming the expected mode and special bits are present only where intended.
ls -ld /tmp
ls -l /usr/local/bin/myscript
ls -ld /srv/shared
/tmp shows drwxrwxrwt, your setuid
target shows an s in the owner execute position,
and the setgid directory shows drwxrws--- with
no permissions for others.
ls -ld <dir>
: Shows directory permissions and special bits in long format.
-l
: Uses long listing format (modes, owner, group, timestamps).
-d
: Lists the directory itself, not its contents.
chmod <mode> <path>
: Changes permissions using numeric or symbolic mode.
chmod 1777 /tmp
: Sets sticky bit and world-writable permissions for /tmp.
1
: Sticky bit.
777
: rwx for owner, group, and others.
chmod +t <dir>
: Enables sticky bit on a directory.
+t
: Sticky bit (directory deletion protection).
chmod u+s <file>
: Enables setuid on an executable.
u+s
: setuid (execute with owner’s effective UID).
chmod g+s <dir>
: Enables setgid on a directory.
g+s
: setgid (new files inherit directory group).
2770
: Numeric mode for a setgid directory with full owner and group access.
2
: setgid.
770
: rwx for owner and group, none for others.