trap
trap is a Linux command in the Process Management category, rated intermediate difficulty. Sets up signal handlers in shell scripts for cleanup. The syntax is trap command signal. It returns signal handler installed. A close relative is ps, which reports a snapshot of current processes. A close relative is top, which real-time interactive process viewer. Updates every few seconds. A close relative is kill, which sends a signal to a process. Default signal is SIGTERM (terminate). More about this category: Linux process management commands — ps, top, kill, killall, pgrep, and more. Manage running processes and system resources. Related Process Management commands: ps, top, kill, killall, pgrep, pkill, nice, renice. This page is part of the free Linux Reference documentation covering 304+ commands, each with syntax, options, practical examples, and a difficulty rating. Find trap and the other essentials on the Linux cheat sheet, or return to the Linux Reference homepage.