Skip to content

About

My handy linux scripts

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

awk_linux_scripts

Bash Linux Zorin OS License

Handy Linux maintenance scripts to make system administration easier from the terminal. Originally written for Zorin OS and other Debian-based distributions.

Table of Contents

Overview

This collection provides convenient terminal tools for:

  • Quick access to detailed hardware information
  • Automated system updates and cleanup

Compatibility

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 apt package manager

The scripts use apt for package management, so they are not compatible with distributions using dnf (Fedora, RHEL) or pacman (Arch).

Prerequisites

showhardware.sh requires the following packages to be installed:

sudo apt install lshw dmidecode

Scripts

showhardware.sh

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

Note: The script must be run with sudo and will verify privileges before proceeding.

checkforupdates.sh

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 autoclean and apt 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.sh

Warning: Upgrades and removals run without asking for confirmation.

apt update can finish successfully even when a package source fails to download. Check its output for warnings.

Installation

  1. Clone the repository into ~/scripts (or copy the files there):

    git clone https://github.com/andreak3779/awk_linux_scripts.git ~/scripts
  2. Make scripts executable:

    chmod +x ~/scripts/*.sh
  3. 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 .sh extension)

    for f in "$HOME"/scripts/*.sh; do
      sudo ln -s "$f" "/usr/local/bin/$(basename "$f" .sh)"
    done
  4. Verify installation:

    sudo ~/scripts/showhardware.sh   # Options A and B
    sudo showhardware                # Option C

Usage

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

With Option C:

sudo showhardware
checkforupdates

Troubleshooting

Scripts 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":

  • sudo usually 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

Uninstallation

Remove installed scripts:

rm ~/scripts/showhardware.sh ~/scripts/checkforupdates.sh

If you used Option C, also remove the links:

sudo rm /usr/local/bin/showhardware /usr/local/bin/checkforupdates

Remove from PATH (if using ~/.bashrc or ~/.profile):

# Edit ~/.bashrc or ~/.profile and remove the PATH line
vi ~/.bashrc
# Find and delete: export PATH=~/scripts:$PATH

Credits

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

About

My handy linux scripts

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages