Lion Cipher Lab

Understand inodes and hard links, then find the deleted file that still fills your disk

Why it matters

A file name on Linux is not the file. It is a label pointing at an inode, the record that really holds the file's size, owner, permissions and the location of its data. Once you see that, three things that baffle beginners stop being mysterious: why deleting a big log at 3 a.m. did not give the disk back, why a symbolic link suddenly says 'No such file or directory', and how an intruder's program can keep running after its file was deleted. This is one of the most common real outages on Linux servers, and the same idea is how an analyst copies a deleted malicious binary out of a live machine.…

What you'll learn

Steps in this lab

  1. What an inode is, in one breath
  2. Open a Linux terminal and make a scratch folder in your Linux home
  3. See your first inode number and link count
  4. Make a hard link and a symbolic link, and compare them
  5. Remove the original name: the hard link keeps the data, the symlink dangles
  6. Honest limits of hard links, and the other way a disk can be 'full'
  7. BEFORE: build the incident, a program writing a big log
  8. The wrong fix: rm the live log, and watch du and df disagree
  9. Find the culprit with lsof +L1, or with /proc if lsof is missing
  10. AFTER: free the space correctly, then stop the process
  11. Why logrotate has copytruncate and postrotate
  12. The security angle: a running program whose file was deleted
  13. Honest negative: /mnt/c is not a Linux filesystem, so do not trust what it tells you
  14. The judgment: what a pro does differently
  15. Clean up, and what you just proved

Open the full interactive lab →