Study guide
5.4 Special Directories and Files
LPI Linux Essentials Certificate 010-160
Track your progress as you read
Finished sections get a check mark.
1 Introduction & Exam Overview
1.1 Current Exam Facts 1.2 Study Strategy & Blueprint Weights
2 Topic 1: The Linux Community and a Career in Open Source
1.1 Linux Evolution and Popular Operating Systems 1.2 Major Open Source Applications 1.3 Open Source Software and Licensing 1.4 ICT Skills and Working in Linux
3 Topic 2 Part A: Command Line Basics & Getting Help
2.1a Bash Shell, Command Syntax & Variables 2.1b Quoting, History & Safe Command Syntax 2.2 Using the Command Line to Get Help
4 Topic 2 Part B: Directories, Listing & File Operations
2.3 Using Directories and Listing Files 2.4 Creating, Moving and Deleting Files
5 Topic 3 Part A: Archiving & Searching Data
3.1 Archiving and Compression on the Command Line 3.2a Pipes, Redirection, and Basic Regular Expressions 3.2b grep and Text Extraction Tools
6 Topic 3 Part B: Turning Commands into Scripts
3.3a Script Basics: Shebang, Variables, and Arguments 3.3b Loops, Exit Status, and Simple Conditionals 3.3c Editors, chmod +x, and Running Scripts
7 Topic 4 Part A: Choosing an OS, Hardware & FHS Basics
4.1 Choosing an Operating System 4.2 Understanding Computer Hardware 4.3a Where Programs and Configuration Live (FHS Basics)
8 Topic 4 Part B: Processes, Logs & Networking
4.3b Processes, Memory & Logs 4.4 Your Computer on the Network
9 Topic 5: Security and File Permissions
5.1 Basic Security and Identifying User Types 5.2 Creating Users and Groups 5.3 Managing File Permissions and Ownership 5.4 Special Directories and Files
5.4 Special Directories and Files
Key Takeaways Explain This Topic AI
/tmp and /var/tmp hold temporary files; both commonly use the sticky bit so users cannot delete each other’s files
The sticky bit on a directory (often shown as t in the others-execute position) restricts deletion/rename to file owners (and root)
ls -d lists directory entries themselves instead of descending into their contents
ln -s creates a symbolic link—a pointer to another path that can cross filesystems and target directories
- Broken symlinks remain as link files even if the target is missing—verify targets when troubleshooting
- Last updated: July 2026
5.4 Special Directories and Files
Not every directory behaves like a private home folder. Shared temporary areas need extra rules so users cannot erase each other’s work. Shortcuts across the tree use symbolic links . Topic 5.4 focuses on /tmp , /var/tmp , the sticky bit , ls -d , and ln -s .
Temporary directories: /tmp and /var/tmp
- Directory Typical role Persistence note
- /tmp/ General temporary files for programs and users Often cleared on reboot (policy varies)
- /var/tmp/ Temporary files that should survive longer More likely to persist across reboots
Both locations are usually world-writable so any user can create temp files. Without an extra control, directory write permission would let User A delete User B’s file. The sticky bit solves that classic problem.
The sticky bit on directories
When sticky is set, users may still create files if the directory is writable, but they generally may delete or rename only their own files (root still can manage everything). That is why sticky directories fit shared temp space.
In ls -l output, sticky directories often look like:
drwxrwxrwt ... /tmp
The final t in rwxrwxrwt replaces the usual others-execute x . A capital T can appear if sticky is set without others-execute.
- Symbol in others execute slot Meaning (directory)
- t Sticky bit set and others have execute
- T Sticky bit set without others execute
- x Others execute, no sticky sudo chmod +t /var/tmp
- sudo chmod 1777 /shared/dropbox
Octal 1000 adds sticky; 1777 is a common shared-scratch mode (sticky + wide rwx). Essentials wants recognition of sticky-on-directory for /tmp , not a deep setuid lesson.
Worked example: Alice creates /tmp/alice.out ; Bob creates /tmp/bob.out . With sticky set, Bob cannot delete alice.out even though he can write to /tmp . He can still delete bob.out .
Sticky-bit scenarios
- Situation Sticky? Result
- Bob runs rm /tmp/alice.out Yes ( t ) Denied (not owner)
- Same rm after sticky cleared No Bob can delete Alice’s file
- Carol renames Dave’s file in a 1777 dropbox Yes Denied
- Carol deletes her own file there Yes Allowed ls -ld /tmp # look for ...rwxrwt
- touch /tmp/$USER-test
- # other user: rm /tmp/<yours>-test → fails when sticky set
- rm /tmp/$USER-test # owner cleanup OK
Applications pick /var/tmp when a temp file should survive reboot; both directories commonly show sticky in ls -ld . If a classmate can delete your /tmp file, the first troubleshooting glance is whether sticky is still present on the directory.
- Listing directories with ls -d
- By default, ls dirname shows contents . ls -d shows the directory entry itself . ls -ld /tmp
- ls -ld /home/*/project
- Command Typical result
- ls /tmp Names inside /tmp
- ls -d /tmp Just the /tmp path
- ls -ld /tmp Long listing for /tmp —mode bits (including sticky t ) visible
Use ls -ld when you care about directory permissions, not a flood of temporary filenames.
Symbolic links with ln -s
A symbolic link stores a path pointing to another file or directory: ln -s /usr/share/doc/demo/README.md ~/readme-link
ln -s /var/log ~/logs
- Feature Symbolic link ( ln -s )
- Points to A path (absolute or relative)
- Can cross filesystems? Yes
- Can link to directories? Yes
- If target is removed Link remains but is broken
Long listings show type l and often linkname -> target :
lrwxrwxrwx 1 alice alice 12 Jul 23 10:00 docs -> /srv/docs
Link mode bits are commonly rwxrwxrwx ; the target’s permissions still govern access to the real data when you follow the link.
Worked example: ln -s /home/alice/projects/notes/todo.txt ~/Desktop/todo.txt puts a Desktop shortcut on the real notes file. Move the real file without updating the link and the Desktop entry becomes broken.
Relative targets ( ln -s ../shared/assets assets ) travel with a project tree; absolute targets are better when link and target may move separately. ln -s /tmp/missing ~/broken-link still creates type l —fix the target or rm the pointer only. Always confirm with ls -l that you see -> pointing where you intended before you rely on the shortcut.
Hard links vs symlinks (awareness only)
Essentials emphasizes ln -s . Plain ln creates a hard link (same inode, usually same filesystem, not for directories). Shortcuts to directories or cross-filesystem pointers → think symbolic .
Practical checklist for Topic 5.4
Expect /tmp and often /var/tmp to be sticky shared temp spaces.
Recognize t / T in directory modes as sticky indicators.
Use ls -ld to inspect a directory’s own mode.
Create shortcuts with ln -s and verify with ls -l .
Deleting a symlink removes the pointer , not necessarily the target.
Together with accounts (5.1–5.2) and chmod / chown (5.3), special directories and symlinks complete Topic 5. Quick self-check: ls -ld /tmp (expect sticky t ), create a disposable ln -s , then remove only the link name when cleaning up.