Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

/tmp

Direct answer

/tmp holds temporary files for all users. It is world-writable with the sticky bit, and is often a tmpfs cleared at boot (or cleaned by systemd-tmpfiles after some days).

When to use this

Use it for temporary files, or when programs fail because /tmp is full or mounted noexec.

First 30 seconds

1. ls -ld /tmp and findmnt /tmp — present and mounted where expected?

2. df -h /tmp — space left? df -i /tmp — inodes left?

3. Find large or unexpected content: du -xh --max-depth=1 /tmp | sort -h | tail.

4. Permissions and owner as the FHS and services expect?

5. Fix space, permissions or mount, then retest the service.

Operational verification

/tmp mounted (or virtual) → correct owner and permissions → enough space → services read and write as intended

Evidence · next step

For Filesystem → /tmp, continue with the first unproven Topic check: Record /tmp mount/source/type, permissions/sticky bit, capacity and inode availability. If that boundary is healthy, advance to the adjacent check: Identify cleanup policy and application lifetime requirements. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commanddf -h /tmp
Scope / prerequisiteUse it for temporary files, or when programs fail because /tmp is full or mounted noexec.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

process temp-path selection → /tmp mount/capacity → secure name creation → ownership/mode/sticky semantics → lifecycle/cleanup → application result

Healthy evidence: mount semantics, sticky bit, capacity and cleanup policy match the application’s expectations and temporary objects are securely created and consumed.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Record /tmp mount/source/type, permissions/sticky bit, capacity and inode availability.

  • Identify cleanup policy and application lifetime requirements.
  • Verify application creates temporary files securely with correct ownership/mode.
  • Reproduce the original operation while checking capacity, cleanup and namespace-collision evidence.

Verification chain. process temp-path selection → /tmp mount/capacity → secure name creation → ownership/mode/sticky semantics → lifecycle/cleanup → application result

Step 3 Commands Verify boundary
df -h /tmp
findmnt /tmp
ls -ld /tmp   # drwxrwxrwt
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: temporary data is treated as persistent, tmpfs memory pressure is ignored, sticky bit is removed, or predictable shared filenames create race exposure.

/tmp path availability shows temporary namespace access only, but it does not show durability, confidentiality, capacity headroom or safe file-creation behavior.

Step 5 Common mistakes Narrow the fault
  • Scripts using predictable temp file names (use mktemp).
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Do not keep important data there. Sticky bit (drwxrwxrwt) stops users deleting each other's files. A noexec /tmp breaks installers that run scripts from it — use another directory.

Key checks
  • ls -ld <path> — owner, permissions and type
  • stat <path> — inode, links, size and timestamps
  • df -h <path> — filesystem and free space
  • findmnt <path> — which mount the path is on
ReferenceWhat it is1 section · depth on demand

Core model

Verify the actual /tmp mount type, mode/sticky-bit, capacity/inodes and cleanup policy, then inspect the creating process identity and secure temporary-file behavior. Separate temporary pathname availability from durability and from safe handling of untrusted shared namespace names.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

/tmp path availability shows temporary namespace access only, but it does not show durability, confidentiality, capacity headroom or safe file-creation behavior.

In depth

/tmp and /var/tmp: temporary files and cleanup

The hier(7) manual page describes /tmp as holding temporary files that may be deleted without notice. /var/tmp is similar, but its files are kept longer, across reboots. On many systems /tmp is a tmpfs in RAM.

Cleanup is configured by tmpfiles.d(5). It defines cleanup by age for volatile locations such as /run, /tmp and /var/tmp. The age is a time span such as 10d, and by default the access, modification and change times are all considered. Paths can be excluded from cleaning with x lines.

/tmp compared with /var/tmp

/tmp/var/tmp
Survives rebootOften not (tmpfs, or cleaned at boot)Yes
Typical cleanup age10 days (where on disk)30 days
StorageRAM (tmpfs) or diskDisk
Use forShort-lived files, socketsLarger or longer-lived temporary files

Security points

PointDetail
Sticky bit (mode 1777)Users can't delete each other's files
Predictable namesUse mktemp, never fixed names like /tmp/app.log
Mount optionsnosuid,nodev (and sometimes noexec)
Per-service private /tmpPrivateTmp=yes in systemd units

PrivateTmp

With PrivateTmp=yes, a service gets its own empty /tmp and /var/tmp, invisible to other processes. That's good for security. But a file the service writes to /tmp won't be visible to an administrator looking in the normal /tmp.

host$ findmnt /tmp
TARGET SOURCE FSTYPE OPTIONS
/tmp   tmpfs  tmpfs  rw,nosuid,nodev,size=8155988k,nr_inodes=1048576
host$ cat /usr/lib/tmpfiles.d/tmp.conf | grep -v '^#'
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d
host$ echo 'x /tmp/build-cache' | sudo tee /etc/tmpfiles.d/keep-build-cache.conf
host$ tmp=$(mktemp) && echo "working in $tmp"
working in /tmp/tmp.Zq81kXc2Lw
host$ systemctl show nginx -p PrivateTmp
PrivateTmp=yes
host$ sudo ls /tmp | grep systemd-private | head -2

Finding a service's private /tmp

Each service with PrivateTmp gets a directory like /tmp/systemd-private-<id>-nginx.service-<id>/tmp. That's where its temporary files really are. The directory is removed when the service stops.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

/tmp is part of Filesystem → /tmp. /tmp is a shared location for temporary files whose lifetime and cleanup policy are system-specific; it is often writable by all users with the sticky bit and may be disk-backed or tmpfs, so applications must not assume persistence, secrecy or unlimited capacity.

Topic-specific state model. /tmp is a shared location for temporary files whose lifetime and cleanup policy are system-specific; it is often writable by all users with the sticky bit and may be disk-backed or tmpfs, so applications must not assume persistence, secrecy or unlimited capacity.

Interpretation rule. - /tmp content ≠ durable data and may be removed at boot or by periodic cleanup.

  • World-writable /tmp ≠ users can delete arbitrary files when sticky-bit semantics apply.
  • /tmp ≠ necessarily disk-backed; tmpfs is possible and consumes memory/swap-backed resources.
  • Predictable temporary filename ≠ safe; shared namespaces create race/symlink risks.

Quick reference

/tmp holds temporary files, world-writable with the sticky bit (drwxrwxrwt). On many distributions it is a tmpfs (RAM), cleaned at boot; systemd-tmpfiles also removes old files (10 days in /tmp, 30 in /var/tmp by default).

findmnt /tmp
cat /usr/lib/tmpfiles.d/tmp.conf
systemd-tmpfiles --clean

Use PrivateTmp=yes in systemd units so each service gets its own /tmp, preventing symlink attacks and data leakage between services. Mount with nodev,nosuid,noexec for hardening.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. /tmp path availability shows temporary namespace access only, but it does not show durability, confidentiality, capacity headroom or safe file-creation behavior.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. /tmp owns temporary-directory semantics. Security owns temp-file attack prevention, Storage/capacity owns resource exhaustion and applications own lifecycle expectations.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Filesystem → /tmp. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
linux /tmptemporary files linuxtmp sticky bittmpfs tmp linux
Embedded reference data

Quick lookup tables

/tmp operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for /tmp.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective state/tmp is a shared location for temporary files whose lifetime and cleanup policy are system-specific; it is often writable by all users with the sticky bit and may be disk-backed or tmpfs, so applications must not assume persistence, secrecy or unlimited capacity.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin process/container mount namespace → resolve the exact path from / and record every mount crossing → identify final dentry + filesystem/device + inode + file type → capture ownership/mode/ACL and capacity where relevant → map pseudo/device/runtime objects to the live kernel/process endpoint → verify the original consumer read/write/execute/service result.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainprocess temp-path selection → /tmp mount/capacity → secure name creation → ownership/mode/sticky semantics → lifecycle/cleanup → application resultTrace requested/configured state through effective state to the observed workload result.
Failure boundary/tmp path availability proves temporary namespace access only; it does not prove durability, confidentiality, capacity headroom or safe file-creation behavior.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated namespace, path and object evidence can establish this Linux Filesystem proof path: process temp-path selection → /tmp mount/capacity → secure name creation → ownership/mode/sticky semantics → lifecycle/cleanup → application resultUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured namespace, mount, inode/object, authorization, backing-resource or consumer scope. /tmp path availability proves temporary namespace access only; it does not prove durability, confidentiality, capacity headroom or safe file-creation behavior.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: preserve the same process mount namespace, resolve the path and mount crossings, identify the exact object/inode or live pseudo/device endpoint, inspect effective access/capacity, then repeat the original consumer operation before changing unrelated filesystem state.Continue to the next unresolved boundary while preserving the original test condition.

/tmp · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundary/tmp
Topic pathFilesystem → /tmp
Runtime state/tmp is a shared location for temporary files whose lifetime and cleanup policy are system-specific; it is often writable by all users with the sticky bit and may be disk-backed or tmpfs, so applications must not assume persistence, secrecy or unlimited capacity.
Fast checks- Record /tmp mount/source/type, permissions/sticky bit, capacity and inode availability. - Identify cleanup policy and application lifetime requirements. - Verify application creates temporary files securely with correct ownership/mode. - Reproduce the original operation while checking capacity, cleanup and namespace-collision evidence.
Verification chainprocess temp-path selection → /tmp mount/capacity → secure name creation → ownership/mode/sticky semantics → lifecycle/cleanup → application result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundary/tmp path availability proves temporary namespace access only; it does not prove durability, confidentiality, capacity headroom or safe file-creation behavior. Boundary chain: process credentials/namespace → path/mount lookup → DAC/ACL/LSM → filesystem metadata → block/device/backend → completion/read-back.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?