Skip to main content

1000

Sticky Bit

Sticky Bit restricts deletion inside a directory: only the file owner (or root) can delete or rename a file, even if the directory is world-writable. It is **directory-focused (file SUID equivalent does nothing today).

Critical for shared writable directories; essential for /tmp. In WordPress, useful only in specific protected shared-cache contexts never general WP content.

Objective

Learn the 1000 sticky bit permission, its behavior, use cases, and safe application on WordPress VPS.

Core Concept

Meaning of first digit

DigitMeaning
1Enable sticky bit

Pattern

1xyz # Sticky + regular permission xyz

Typical example:

1777 # Sticky + 777

Key Behavior (directories)

  • Directory writable by many users
  • Prevents users from deleting each other's files

Syntax Formula

Set sticky bit

chmod 1xxx <directory>

Shortcut:

chmod +t <directory>

Remove sticky bit

chmod -t <directory>

Permission Indicator

ls -ld <directory>

Expected flag:

drwxrwxrwt

t replaces **x for others when sticky bit enabled.

Real Examples & Expected Output

Set sticky on shared dir

mkdir /srv/shared
chmod 1777 /srv/shared
ls -ld /srv/shared

Output:

drwxrwxrwt ... /srv/shared

Remove sticky bit

chmod -t /srv/shared

WordPress-Relevant Usage

ScenarioValidNotes
System /tmp✅ Default, mandatory
Dedicated shared cache/tmp outside public web root✅ With strict group model
wp-content/uploads❌ Never
wp-content/cache❌ Not recommended
Shared SFTP/Web designer workspace✅ If isolated directory tree
Public writable folder by web apps✅ With caution & access rules

WordPress VPS Scenarios

ExampleGuidance
Multi-developer folder /srv/wpshareAllowed with 1770 + ACL + sticky
WP uploadsNever, exposure + overwrite risk
PHP session directorySticky bit required (system default)
Cloud panel shared public folderOnly if OS sets it by default

**Rule: Sticky bit protects files from each other, not from attackers.

Security Considerations

Benefits

BenefitDescription
Protects user files in shared dirsPrevents cross-deletion
Mandatory for /tmpPHP/session security

Risks

RiskRoot cause
Used on wrong directoriesWeb-writable privilege problems
False securityProtects only from deletion, not read/write

Audit

find / -type d -perm -1000 2>/dev/null

Best Practices

RecommendationReason
Use sticky only in shared writable dirsCorrect security model
Never apply inside wp-contentAttack surface increase
For WP cache & uploads use strict owner perms755/750 & correct user
Use ACLs instead of sticky for team collaborationGranular control

ACL Example:

setfacl -m u:dev:rwx /srv/shared

WP-Specific Quick Audit

Scan wp tree:

find /home -type d -perm -1000

If appears under:

  • /wp-content/uploads
  • /wp-content/cache
  • Theme/plugin folders

Remove and correct permissions.

Go-Live Checklist

Item
Sticky only in /tmp & managed shared dirs
No sticky inside public WP path
ACLs or sudo rules for shared access
Verify PHP tmp path sticky set

Troubleshooting Matrix

ProblemCauseFix
Cannot delete others' filesSticky enabledchmod -t dir
Users overwriting each otherWrong perms, no ACLFix ACL + directory perms
Sticky used on wp-contentMisuseRemove sticky + reset perms

Quick Lab

Create sticky-protected collaboration directory

groupadd wpteam
mkdir /srv/wpteam
chgrp wpteam /srv/wpteam
chmod 1770 /srv/wpteam
ls -ld /srv/wpteam

Expected:

drwxrwx--T ... /srv/wpteam

Cheat Sheet

CommandPurpose
chmod 1xxx dirSticky + permissions
chmod +t/-t dirAdd/remove sticky bit
find / -perm -1000Audit sticky dirs
ls -ld dirCheck for t bit

Mini-Quiz

QuestionAnswer
Purpose of sticky bit?Prevent cross-user file deletion
Where mandatory?/tmp, session dirs
Safe for uploads/?No
Indicator in ls -ld?t in other exec bit