Automate safe system upodates with a single script (for APT + systemd systems)

THE PROBLEM Keeping a Linux system fully updated usually means doing several things by hand: Update APT package lists Upgrade installed packages Remove unused dependencies and cached files Update Flatpak apps (if you use Flatpak) Update firmware via fwupd (if available) Decide whether to reboot or shut down None of that is hard, but it is repetitive and easy to skip steps, especially firmware updates. This script turns that whole workflow into a single, safe command. REQUIREMENTS This script assumes: Package manager Uses APT Example: Debian, Ubuntu, Linux Mint and similar Init system Uses systemd (for systemctl reboot/poweroff) Shell bash (script uses “#!/usr/bin/env bash” and “set -euo pipefail”) You can run it with: bash script.sh Privileges Your user has sudo rights Optional components Flatpak (optional) If not installed, Flatpak steps are skipped fwupd (fwupdmgr, optional) If not installed, firmware steps a...

Signals and the KILL command

COMMAND: KILL

The kill command sends a signal to specified processes or process groups causing them to act according to the signal.

Kill -<value or signal> <pid>

Most common:
Kill -9 <pid>
equal to
Kill -SIGKILL <pid>


CAN I TERMINATE THREADS INSTEAD OF PROCESSES?

NO.

Threads are an integral part of the process and cannot be killed outside it. There is the pthread_kill function but it only applies in the context of the thread itself. Indeed, pthread_kill only causes the signal to be handled in the context of the given thread; the signal actions "termination" or "stopping" affect the process as a whole.


LIST OF SIGNALS

Signal          Value    Action   Comment  ──────────────────────────────────────────────────────────

   SIGHUP        1       Term    Hangup detected on controlling terminal or death of controlling process

   SIGINT        2       Term    Interrupt from keyboard

   SIGQUIT       3       Core    Quit from keyboard

   SIGILL        4       Core    Illegal Instruction

   SIGABRT       6       Core    Abort signal from abort(3)

   SIGFPE        8       Core    Floating point exception

   SIGKILL       9       Term    Kill signal

   SIGSEGV      11       Core    Invalid memory reference

   SIGPIPE      13       Term    Broken pipe: write to pipe with no readers

   SIGALRM      14       Term    Timer signal from alarm(2)

   SIGTERM      15       Term    Termination signal

   SIGUSR1   30,10,16    Term    User-defined signal 1

   SIGUSR2   31,12,17    Term    User-defined signal 2

   SIGCHLD   20,17,18    Ign     Child stopped or terminated

   SIGCONT   19,18,25    Cont    Continue if stopped

   SIGSTOP   17,19,23    Stop    Stop process

   SIGTSTP   18,20,24    Stop    Stop typed at terminal

   SIGTTIN   21,21,26    Stop    Terminal input for background process

   SIGTTOU   22,22,27    Stop    Terminal output for background process

Comments