Skip to main content
Kill -9 Club
Sign in

truncate

FilesPackage: coreutilsHandle with care

Sets a file's size, cutting it or extending it with zeros. truncate -s 0 empties a log without deleting it, so without breaking the descriptor a process keeps open on it.

A mistake with this command can destroy data or lock you out

  • There is no undo: the truncated content is lost instantly. On a database file or a disk image it is guaranteed corruption. Keep it for logs.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

truncate -s
Sets the file size. -s 0 empties it without deleting it, which keeps a running service’s open descriptor valid.

Lessons that teach it

No lesson names it among its useful commands; it appears inside other lessons' command lines.