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

Filesystem architecture

/bin
Essential commands to boot the system or in single-user mode
Essential commands required by all system users

/sbin
Essential binaries related to system administration

On some new distributions /usr/bin and /bin are symbolically linked together, as are /usr/sbin and /sbin.


/proc

Runtime system information. Not real but virtual files which dynamically reflect the kernel structure and configuration information.


/dev
Device nodes, except for network devices.
Note: /dev/null is a This pseudofile also called the "bit bucket" or "black hole". Redirecting the output there will lose it, therefore it is a fake writing. But the error will be displayed on the screen, unless the redirection is including stnderr:
$ commnad >& /dev/null


/var
Variable files which change in dimension while the system is running. For this reason it's often put in a dedicated partition so its variability can't compromise the free space necessary to the main system. It can contain network services directories.


/etc
Configuration files, no binary files.


/boot
Files needed to boot the system. For every alternative kernel installed on the system there are four files:

  • vmlinuz
    The compressed Linux kernel, required for booting.
  • initramfs
    The initial ram filesystem, required for booting, sometimes called initrd, not initramfs.
  • config
    The kernel configuration file, only used for debugging and bookkeeping.
  • System.map
    Kernel symbol table, only used for debugging.
  • GEUB files
    Such as /boot/grub/grub.conf or /boot/grub2/grub2.cfg

Each of these files has a kernel version appended to its name.


/lib
32 bit libraries.

/lib64
64 bit libraries.

Some of them are dynamically loaded libraries  (DL) also known as Shared Libraries or Shared Objects (SO), which are loaded after the startup of a program. They are requested by plugins or modules. Kernel modules are located in /lib/modules/<kernel-version-number>.


/mnt
Ever more replaced by /run.


/opt
Optional software packages


/sys

Virtual pseudo-filesystem for information about the system and the hardware. It can be used to alter system parameters and debug.


/sys
Site-specific data served by the system. It gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only relate to a specific user should go in the /home/ directory.


/usr
Multi-user programs and data.

  • /usr/include - Header files used to compile applications
  • /usr/lib - Libraries for programs in /usr/bin and /usr/sbin
  • /usr/lib64 - 64-bit libraries for 64-bit programs in /usr/bin and /usr/sbin
  • /usr/sbin - Non-essential system binaries, such as system daemons
  • /usr/share - Shared data used by applications, generally architecture-independent
  • /usr/src - Source code, usually for the Linux kernel
  • /usr/local - Data and programs specific to the local machine; subdirectories include bin, sbin, lib, share, include, etc.
  • /usr/bin - This is the primary directory of executable commands on the system

Comments