dtach
Detach and reattach programs from terminal
SYNOPSIS
dtach [-aAcEnpqsSv] [-h name] [-l name] [-n name] [session command ...]
PARAMETERS
-a name
Attach to existing session name.
-A name
Attach to name, creating if it does not exist.
-c name
Create new session name, killing existing if present.
-E
Disable escape key interpretation (use Ctrl-\ to detach).
-h name
Use name as base for socket filename.
-l [name]
List sessions (all if no name).
-n name
Disable remote control for session name.
-p
Print session ID after creation.
-q
Quiet mode, suppress messages.
-s [name]
Show statistics for session(s).
-v
Display version information.
-V
Display extended version info.
DESCRIPTION
dtach is a minimalistic program that allows users to detach from a terminal session and reattach later, preserving the running process. Unlike feature-rich tools like screen or tmux, dtach focuses solely on detachment and reattachment without multiplexing, scrollback, or window management. It runs a command in a new session identified by a Unix socket file, enabling the process to continue in the background even if the controlling terminal closes.
To use it, create a session with dtach -c session_name command, detach using Ctrl-\ (or configured escape), and reattach with dtach -a session_name. Sessions persist until explicitly killed or the process exits. It's ideal for long-running tasks like compilations or remote jobs where connection drops are common.
dtach is extremely lightweight (under 100KB compiled), fast, and has no dependencies beyond standard libc, making it suitable for embedded systems or minimal environments. It supports remote control via sockets but disables it by default for security.
CAVEATS
Local-only via Unix sockets; no multi-window support or scrollback. Default escape (Ctrl-]) may conflict; use -E or reconfigure. Sessions tied to socket dir permissions.
DETACH KEY
Default: Ctrl-] to detach; send Ctrl-\ from client to force.
SOCKET LOCATION
/tmp/dtach-$USER/ by default; customizable with -h.
HISTORY
Developed by Dave Vasilevsky in 2006 as a BSD-licensed, minimal alternative to screen. Maintained sporadically; latest stable release 0.9 (2013). Gained niche use in minimal/embedded Linux setups for its tiny footprint.


