files
Working with files and directories
-
stat
Tested stat examples: reading size, mode, owner and the three timestamps, printing a single field with -c, and what stat says about a symlink.
-
tar
Tested tar examples: create, list, and extract archives, back up incrementally, stream over ssh, and verify integrity.
-
touch
Tested touch examples: creating a file without truncating an existing one, setting access and modification times separately, and the timestamp nothing can set.
-
wget
Tested wget examples: downloading, resuming, retries, authentication, recursive mirroring, and scripting with exit codes.
-
xargs
Tested xargs examples: batching with -n, placeholders with -I, NUL-separated input from find -print0, parallel runs with -P, and what its exit codes mean.
-
Where things live on a Debian system
Why configuration is in /etc, why /usr belongs to apt, what /var accumulates, and which two directories the package manager will never touch.
-
Bulk rename a batch of files
Rename many files at once with a plain bash loop, safely handling spaces and previewing changes before committing.
-
Copy files between two machines over SSH
Transfer a file or directory tree between two machines with scp or rsync, and resume an interrupted transfer without starting over.
-
Find and replace across many files
Replace a string across a directory tree with grep -rl and sed -i, safely for filenames containing spaces, with a dry run and a backup first.
-
Find files without the permission denied noise
Why 2>/dev/null is the wrong fix for find's permission denied errors, and what -readable -prune does instead, including what happens to the exit status.
-
Find the largest files on disk
Locate what is eating your disk space, from a whole filesystem down to one directory.
-
Save everything a terminal session prints
Keep a copy of what a command printed with tee, or record an entire terminal session with script, including the exit status trap that catches people out.
-
No space left on device
A write failed for want of space. Find which filesystem is full, whether it ran out of blocks or inodes, and why deleting the big file often frees no space.
-
Permission denied
The message names the path and never the reason. Work out which check failed, which account was refused, and when the mode is not the thing doing the refusing.
-
Text file busy
A deploy failed because the program is running. What ETXTBSY protects, why rm then copy works, and the rename that avoids the window between them.
-
Hard links vs symbolic links
A hard link is another name for the same data, a symlink a small file holding a path. What that means when the original goes, when sed edits it, and on disk.
-
Listing what is installed
List installed packages reliably with dpkg-query, tell what you asked for from what came along, and find out when a package arrived from the logs.