Interview Prep/Linux/Storage, disks and filesystems

A team wants a filesystem mounted at `/tmp` that clears on reboot and can't run binaries. How do you set it up?

IntermediateScenarioStorage, disks and filesystems
Answer

Situation read → tmpfs with hardened mount options.

What I'd do →

  1. sudo systemctl enable tmp.mount on distros that ship it, or add to fstab:
tmpfs /tmp tmpfs defaults,size=2G,nodev,nosuid,noexec,mode=1777 0 0
  1. sudo mount -o remount /tmp (or reboot) and verify with findmnt /tmp.
  2. Test installers and tools that unpack to /tmp and run from there; set TMPDIR for them if noexec breaks them.

Why → noexec blocks a common attacker trick of dropping binaries in /tmp; 1777 keeps the sticky bit so users can't delete each other's files.

Interview tip → Mention the sticky bit by name.

All Linux questions Roadmap: Linux

More on Storage, disks and filesystems