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

Basic network troubleshooting steps

1. Be sure that the network is properly configured:
$ /sbin/ifconfig


2. Display the IP address:
$ ip addr show
Does the IP address look valid? Depending on where you are using this from, it is most likely a Class C IP address.


3. If it does not show a device with an IP address, start or restart the network and/or NetworkManager. The way to do that depends on your system:

  • $ sudo systemctl restart NetworkManager
  • $ sudo systemctl restart network
  • $ sudo service NetworkManager restart
  • $ sudo service network restart

4. If your device was up but had no IP address, try to generate a new address:
$ sudo dhclient <Ethernet device name>
The Ethernet device name is often eth0.


5. If the interface is up and running with an assigned IP address and reaching a website is not still possible, make sure you that there is a valid hostname assigned to the machine:
$ hostname


6. Ping the website:
$ sudo ping -c 3 WEBSITE
Two of the most common suspicious outputs are:

  1. ping: unknown host <WEBSITE>
  2. PING <WEBSITE> (127.0.53.53) 56(84) bytes of data.
    64 bytes from 127.0.53.53: icmp_seq=1 ttl=64 time=0.016 ms

In the case 2 probably something is wrong with the DNS set-up, as 127.0.x.x address is a loop that returns back to the host machine you are on.


7. It can be that the Resolver Server (also called DNS Server) the machine is referring to has some issue. It is possible to change the Resolver Server with a more reliable one by overriding it with the address of the new DNS Server:
$ host x.x.x.x
or
$ dig <domain_that_provides_its_DNS_Server_address>
E.g., 8.8.8.8 is the DNS Server address provided by Google, In this case the command is:
$ host 8.8.8.8
or
$ dig google.com
It is possible to permanently set the new DNS Server address by editing the /etc/resolve.conf file.
There is another file, /etc/hosts, where you can associate names with IP addresses, which is used before the DNS Server is consulted. This is most useful for specifying nodes on your local network.


8. If host or dig commands fail, the reasons can be:

  • The DNS server is down. In this case try pinging it
  • The server can be up and running, but DNS may not be currently available on the machine
  • Your route to the DNS server may not be correct
Trace the route to the DNS Server:
$ sudo traceroute <DNS_Server_address>
Eg for google.com's DNS Server address:
$ sudo traceroute 8.8.8.8
Alternatively, there is a dynamic solution updated in real time like the command top:
$ sudo mtr --report-cycles 3 <DNS_Server_address>


9. If the traceroute command displays only the first line with no further information, then:
$ ip route show
In a normal situation this displays the local network interface and IP address of your router, DSL, or Cable Modem, and it specifies that information.


10. If the previous step shows a blank output or points to the local machine itself, that's most likely the end problem.
Add a proper default route:
$ route add -net ROUTE_ADDRESS
Then, run some of the tests mentioned in the previous steps to test the new route.

Comments