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...

Printing

CUPS - Common UNIX Printing System





CUPS Process

After a print command execution:
  1. The scheduler validates the command and processes the print job:
    • Creates job files according to the settings specified in the configuration files.
    • Records activities in the log files.
  2. Job files are processed with the help of the filter, printer driver, and backend, and then sent to the printer.

Scheduler

Scheduler manages:
  • Print jobs
  • Handles administrative commands
  • Allows users to query the printer status
  • Manages the flow of data through all CUPS components

Mainly 2 files under /etc/cups/ directory:
  • cupsd.conf
    System settings, no printer details. Mainly network security.
  • printers.conf
    Printer settings.

Job Files

The instances to print are in the form of print requests stored in files under /var/spool/cups/.
Those files are put into a Print Queue and removed after printing. They are of 2 types:
  • Data files, starting with the letter d.
  • Control files, starting with the letter c.

Log files

Store in /var/log/cups

Filters, Printer Drivers, and Backends

  1. Job files are converted in printable format by filters.
  2. Printer drivers are contained in /etc/cups/ppd/ directory.
  3. The print data is then sent to the printer through another filter, and via a backend that helps to locate devices connected to the system.

Managing CUPS

To use CUPS, CUPS daemon need to be activated and properly managed:
  1. $ systemctl status cups
  2. $ sudo systemctl [enable|disable] cups
  3. $ sudo systemctl [start|stop|restart] cups
A webserver is already provided by CUPS at the address http://localhost:631.

Commands for printing

$ lp <filename>
To print the file to default printer

$ lp -d printer <filename>
To print to a specific printer (useful if multiple printers are available)

$ program | lp
or
$ echo string | lp
To print the output of a program

$ lp -n number <filename>
To print multiple copies

$ lpoptions -d printer
To set the default printer

$ lpq -a
To show the queue status

$ lpadmin
To configure printer queues

Print management commands

$ lpstat -p -d
To get a list of available printers, along with their status

$ lpstat -a
To check the status of all connected printers, including job numbers

$ cancel job-id
or
$ lprm job-id
To cancel a print job

$ lpmove job-id newprinter
To move a print job to new printer


Utilities

PS/PDF conversion:
  • pdf2ps / ps2pdf
  • enscript
  • pstopdf / pdftops
  • convert
  • gm convert

PDF visualisation:
  • evince
  • okular

PDF manipulation:
  • qpdf
  • pdftk
  • ghostscript

Extra:
  • pdfinfo
    Extracts information

  • flpsed
    Adds data such as comments

  • pdfmod
    GUI for the operations

Comments