Handy Linux maintenance scripts to make system administration easier from the terminal. Originally written for Zorin OS and other Debian-based distributions.
This collection provides convenient terminal tools for:
- Quick access to detailed hardware information
- Automated system updates and cleanup
These scripts are designed for Ubuntu-based Linux distributions, including:
- Ubuntu (20.04 LTS and later)
- Zorin OS
- Linux Mint
- Elementary OS
- Pop!_OS
- Any other Debian/Ubuntu-based distribution using
aptpackage manager
The scripts use apt for package management, so they are not compatible with distributions using dnf (Fedora, RHEL) or pacman (Arch).
showhardware.sh requires the following packages to be installed:
sudo apt install lshw dmidecodeDisplays comprehensive hardware and system information in one command.
Displays:
- System information (kernel version, OS, architecture)
- Hardware bus information
- BIOS and system enclosure details
- CPU information (cores, cache, frequency)
- Memory usage and availability
- Disk usage of the root filesystem
- Network interface information
Features:
- Error handling: stops on first error
- Privilege verification: ensures it's run with sudo
- Clean formatted output with visual section separators
Usage:
sudo ~/scripts/showhardware.shNote: The script must be run with
sudoand will verify privileges before proceeding.
Automated system update and maintenance script. Performs package updates, cleanup, and refreshes Snap/Flatpak packages if installed.
Performs:
- Package list updates (
apt update) - System upgrades (
apt upgrade) - Package cache and unused dependency cleanup (
apt autocleanandapt autoremove) - Snap package refresh (if installed)
- Flatpak package upgrade (if installed)
Features:
- Error handling: stops on first error
- Runs each update command with
sudo, so you may be asked for your password - Status message before each step
- Skips Snap or Flatpak if it is not installed
Usage:
checkforupdates.shWarning: Upgrades and removals run without asking for confirmation.
apt updatecan finish successfully even when a package source fails to download. Check its output for warnings.
-
Clone the repository into
~/scripts(or copy the files there):git clone https://github.com/andreak3779/awk_linux_scripts.git ~/scripts -
Make scripts executable:
chmod +x ~/scripts/*.sh
-
Add directory to PATH (choose one method):
Option A: Bash (for ~/.bashrc)
echo 'export PATH=~/scripts:$PATH' >> ~/.bashrc source ~/.bashrc
Option B: Login shells (for ~/.profile)
echo 'export PATH=~/scripts:$PATH' >> ~/.profile source ~/.profile
Option C: System-wide (requires sudo; the commands drop the
.shextension)for f in "$HOME"/scripts/*.sh; do sudo ln -s "$f" "/usr/local/bin/$(basename "$f" .sh)" done
-
Verify installation:
sudo ~/scripts/showhardware.sh # Options A and B sudo showhardware # Option C
With Option A or B:
# Show hardware information (sudo needs the full path)
sudo "$(command -v showhardware.sh)"
# Update the system (the script calls sudo itself)
checkforupdates.shWith Option C:
sudo showhardware
checkforupdatesScripts not found after installation:
- Verify PATH was updated:
echo $PATH | grep scripts - Restart terminal for changes to take effect
- Try opening a new terminal window
"Permission denied" errors:
- Ensure scripts are executable:
chmod +x ~/scripts/*.sh - For system-wide installation, you need sudo
"sudo: showhardware.sh: command not found":
sudousually does not search~/scripts, even when it is on your PATH- Use the full path:
sudo ~/scripts/showhardware.sh - Or install system-wide (Option C) and run
sudo showhardware
lshw or dmidecode commands not found:
- Install required packages:
sudo apt install lshw dmidecode
checkforupdates.sh exits early:
- The script stops at the first command that fails and skips the remaining steps
- Check the output for which command failed
- Review system logs if needed:
journalctl -xe
Remove installed scripts:
rm ~/scripts/showhardware.sh ~/scripts/checkforupdates.shIf you used Option C, also remove the links:
sudo rm /usr/local/bin/showhardware /usr/local/bin/checkforupdatesRemove from PATH (if using ~/.bashrc or ~/.profile):
# Edit ~/.bashrc or ~/.profile and remove the PATH line
vi ~/.bashrc
# Find and delete: export PATH=~/scripts:$PATHThese scripts were enhanced with assistance from GitHub Copilot (GPT-4) in VS Code, an AI-powered code assistant. Improvements include error handling and a privilege check in showhardware.sh, better formatting, and additional functionality.