Skip to content

Linux & shell: Terminal tools (tmux, jq, background jobs)

8 Linux & shell commands: Terminal tools (tmux, jq, background jobs). Click a command to see what each part does.

Index
8 items
Click a command to see what each part does.

Terminal tools (tmux, jq, background jobs)8

  • tmux new -A -s <name>Start or reattach a tmux session

    What each part does

    1. tmux new -s <name>new named session that survives SSH disconnects
    2. -Aattach instead if it already exists

    Tip Detach with Ctrl+B then D; list with tmux ls.

  • <command> | jq '.items[] | {name: .metadata.name, phase: .status.phase}'Pretty-print and filter JSON

    What each part does

    1. | jq '...'JSON processor
    2. .items[]iterate over an array
    3. {name: ..., phase: ...}build a smaller object with just those fields
  • jq -r '.[] | select(.state=="running") | .name' <file>.jsonRaw values from JSON for scripts

    What each part does

    1. -rraw strings, no quotes
    2. select(.state=="running")keep only matching items
    3. .nameprint one field
  • yq '.spec.replicas' <file>.yaml; yq -i '.spec.replicas = 3' <file>.yamlRead or edit YAML

    What each part does

    1. yq '.path'read a value (jq syntax for YAML)
    2. yq -i '...'edit the file in place
  • nohup <command> > <log> 2>&1 &Keep a command running after logout

    What each part does

    1. nohupignore the hangup signal sent when you log out
    2. > <log> 2>&1send output and errors to a log
    3. &run in the background; jobs and fg to manage it
  • timeout 30s <command>Stop a command that runs too long

    What each part does

    1. timeout 30skill the command after 30 seconds; exit code 124 if it timed out
  • cat <list> | xargs -P 8 -I{} <command> {}Run commands in parallel

    What each part does

    1. xargs -P 8up to 8 at a time
    2. -I{}replace {} in the command with each input line
  • until <command>; do echo retrying; sleep 5; doneRetry a command until it succeeds

    What each part does

    1. until <command>loop while the command fails
    2. sleep 5wait between attempts

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…