Labthrift Labthrift What to buy. What to skip. Why.

Written 1 Sep 2026. This is a how-to, not a product card.

Empty or shrink a practice file

After od (or after writing a practice file), use truncate so you empty or shrink the file without deleting its name. You don't need extra software beyond coreutils.

Finish disk writes flushed pending writes. Peek at file bytes showed what landed. Tonight you change a file's size on purpose: keep the same home path, but empty or shrink the file. truncate sets length. It does not remove the name. Removing the name is delete a file carefully. That is not a wipe with shred. That is not copying disks with dd. You are still only practicing in home on the computer. It does not need htop, Grafana, or a NAS for this one job.

Skip until SSH already works

SSH from the couch should already get you a prompt. If you only need to write practice words, that is print words exactly or put a short line into a file. If you only need to flush writes, that is finish disk writes. If you only need a peek at bytes, that is peek at file bytes. If you only need the throwaway gone, that is delete a file carefully. Skip this whole note if you only need a house share other computers browse. That is a folder the house can open.

What this is

truncate sets a file's length in bytes. -s 0 empties the file and leaves the name. -s N sets the exact size to N bytes (shrink keeps the start of the file; grow can pad with empty space, sometimes called a hole). It does not delete the path. It is not rm -i. Rm removes the name. Truncate changes size.

Practice truncate in home

SSH in. Make sure home is where you sit:

pwd

You want a path that ends in your login name. If not:

cd ~

Park one short practice line (see printf or echo):

printf 'hello\n' > ~/trunc-a.txt

Optional flush (see sync):

sync

Note the size before you change it:

ls -l ~/trunc-a.txt

You want a small non-zero size (hello plus a newline is typically 6 bytes).

Optional peek (see od):

od -c ~/trunc-a.txt

Empty the file, keep the name (tonight's job):

truncate -s 0 ~/trunc-a.txt

Check again:

ls -l ~/trunc-a.txt

You want size 0. The name ~/trunc-a.txt is still there. That is the whole point of tonight.

Optional shrink after rewrite: put the line back, then keep only the first three bytes:

printf 'hello\n' > ~/trunc-a.txt

truncate -s 3 ~/trunc-a.txt

od -c ~/trunc-a.txt

You want something like the letters h e l and then the prompt back. The rest is gone, the name remains.

Optional grow (lightly. Don't make sparse files the lesson):

truncate -s 10 ~/trunc-a.txt

ls -l ~/trunc-a.txt

Size can show 10 even if the middle is empty space on disk. You only need two: empty with -s 0, or shrink with a small N. Skip sparse deep-dives.

Debian and Ubuntu usually already have truncate (coreutils). Don't make apt the lesson. If it is somehow missing:

sudo apt install coreutils

Then stop. That install is not a reason to buy disk tools.

When you are done practicing:

rm -i ~/trunc-a.txt

Ask first. Say yes only if the name matches. That careful delete is delete a file carefully. Skip rm -rf.

Useful extras, still home-safe

Skip truncate on /etc, whole disks, USB device nodes, or anything outside home. Tonight: one tiny home practice file.

Skip truncate as a wipe. Emptying a practice file is not shred and not dd. Those are different (and scarier) jobs.

Skip huge files as tonight's job. Tonight: a tiny home file, not logs, images, or disk images.

Skip piping truncate into rm. Truncate changes size. Rm deletes. Don't mix those jobs.

Skip awk, sed, and install as new pages this cycle. Free space is already see if the computer still has room (that is the df look. Don't invent a separate df how-to).

Skip hexdump and xxd as tonight's job. Peeking stays on od.

Skip screen, tmux, port 22 forwarding, apt as the lesson, htop, Grafana, and a NAS. Keep SSH on the house network: keep the computer on the house network. Don't forward port 22.

What this is not

This is not sync. That is finish disk writes. It is not od. That peeks at bytes: peek at file bytes. It is not strings. That shows printable text without a full dump: see printable text with strings. It is not printf or echo. Those write words: print words exactly, put a short line into a file. It is not rm. That removes the name: delete a file carefully. It is not cat. That prints text as text: read a file without opening the editor. It is not cmp. That compares two files: see whether two files match byte for byte. It is not sha256sum. That fingerprints one file: check a file fingerprint. It is not free disk space. That is see if the computer still has room. It is not opening SSH to the internet so you can shrink files from a coffee shop. That is keep the computer on the house network. Don't forward port 22.

What next

Need a peek first? Peek at file bytes. Need printable text without a full dump? See printable text with strings. Need a flush first? Finish disk writes. Need exact practice words? Print words exactly. Need the throwaway gone (name and all)? Delete a file carefully. Need free space? See if the computer still has room. Keep SSH on the house network: keep the computer on the house network. Don't forward port 22.

Skip

Sources

Debian: truncate(1). Ubuntu: truncate(1). GNU coreutils: truncate. Official pages only. For the peek, see peek at file bytes. For the flush, see finish disk writes. For exact words, see print words exactly. For a careful delete, see delete a file carefully. For the login, see SSH from the couch.

Also on this topic

SSH from the couchType commands on the computer from your laptop, on the house network. Password login first. Don't open this to the internet. Finish disk writesAfter a practice write, finish disk writes with sync so the file is really on disk before you unplug or power off. You don't need extra software for this. Peek at file bytesAfter writing a practice file, peek with od so you see the characters and bytes that are actually on disk. You don't need extra software beyond coreutils. See printable text with stringsAfter od, use strings so you see readable text without dumping every byte. You don't need extra software beyond binutils. Print words exactlyPrint words exactly with printf so a practice file gets the text you meant, without the extra newline echo always adds. You don't need extra software for this. Put a short line into a fileAfter SSH works, put one short line into a file with echo so you don't need to open nano. You don't need a file manager for this. Delete a file carefullyAfter SSH works, delete one file with rm -i. Ask first. Skip rm -rf. You don't need a NAS for this. See if the computer still has roomBefore you buy a bigger drive, check free space with df. Turn off password login once the key worksAfter the laptop key login is boring, tell SSH to stop accepting the password. The key is how you get in. A keyboard on the computer is the backup now. Keep the computer on the house networkSSH and Pi-hole belong on the house network. Skip this if you never opened the router settings. Don't forward port 22.