Close Menu
IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
  • Home
  • News
  • Blog
  • Selfhosting
  • AI
  • Linux
  • Cyber Security
  • Gadgets
  • Gaming

Subscribe to Updates

Get the latest creative news from ioupdate about Tech trends, Gaming and Gadgets.

[contact-form-7 id="dd1f6aa" title="Newsletter"]
What's Hot

Google Requires Crypto App Licenses in 15 Regions as FBI Warns of $9.9M Scam Losses

August 15, 2025

A new way to test how well AI systems classify text | MIT News

August 15, 2025

Pebble’s smartwatch is back: Pebble Time 2 specs revealed

August 15, 2025
Facebook X (Twitter) Instagram
Facebook Mastodon Bluesky Reddit
IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
  • Home
  • News
  • Blog
  • Selfhosting
  • AI
  • Linux
  • Cyber Security
  • Gadgets
  • Gaming
IOupdate | IT News and SelfhostingIOupdate | IT News and Selfhosting
Home»Linux»10 Bash Scripts to Automate Daily Linux SysAdmin Tasks
Linux

10 Bash Scripts to Automate Daily Linux SysAdmin Tasks

MarkBy MarkJune 27, 2025No Comments4 Mins Read
10 Bash Scripts to Automate Daily Linux SysAdmin Tasks


Introduction

In the world of Linux, automation is key to efficient system administration. Bash, the Bourne Again Shell, provides powerful scripting capabilities that enable Linux SysAdmins to streamline their daily tasks. This article explores ten essential Bash scripts that can significantly simplify the workload for System Administrators, making it easier to manage systems effectively. Read on to discover these invaluable scripts and how they can enhance your Linux experience!

FAQ

How to run a Bash script as an Admin?
Use the sudo /path/to/script command to execute the Bash script as an Admin. It’s best practice to limit executable permissions to authorized personnel only.
What is #!/bin/bash in Bash?
The #!/bin/bash line, known as the shebang, instructs the system to utilize the Bash interpreter for script execution. Omitting this may result in the script being treated as a simple shell script.
How do I give permissions to run a Bash script?
Utilize the chmod command to set permissions. For a Linux SysAdmin script, apply sudo chmod u+x /path/to/script to grant executable rights.

10 Bash Scripts to Automate Daily Linux SysAdmin Tasks

As a Linux SysAdmin, daily tasks can become overwhelming. Here’s a curated list of ten essential Bash scripts designed to automate common administrative functions. Follow these prerequisites before diving into the scripts:

Prerequisite 1: Running a Bash Script

To effectively run a Bash script, you’ll need to follow two simple steps:

  1. Make the Script Executable: Run the command sudo chmod u+x /path/to/script to allow execution permissions for the script.
  2. Execute the Script: After granting permissions, execute the script using the command ./script_name.sh.

Prerequisite 2: Package Management Commands for Various Distros

Familiarize yourself with package management commands based on your Linux distribution:

Package ManagerUpdate/UpgradeInstallRemove
pacman (Arch-based)sudo pacman -Syusudo pacman -Ssudo pacman -R
zypper (SUSE-based)sudo zypper updatesudo zypper installsudo zypper remove
dnf (Fedora/RHEL-based)sudo dnf updatesudo dnf installsudo dnf remove
apt (Debian/Ubuntu-based)sudo apt updatesudo apt installsudo apt remove

Script 1: Update and Upgrade System Repositories/Packages

This script updates and upgrades all installed packages:

#! /bin/bash
sudo apt update -y
sudo apt upgrade -y
sudo apt autoremove -y

Script 2: Install a Package on Linux

To install a specified package using the script:

#! /bin/bash
sudo apt update && sudo apt upgrade
sudo apt install $1

Script 3: Remove a Package

This script handles the complete removal of a package:

#! /bin/bash
sudo apt remove $1
sudo apt purge $1
sudo apt autoremove

Script 4: Monitor System Performance

Automate the monitoring of RAM, CPU, and uptime:

#! /bin/bash
echo "RAM Status"
free -h
echo "Uptime"
uptime
echo "CPU/Memory Stats"
vmstat 2

Script 5: Log Monitoring

Filter logs for user access and authentication:

#! /bin/bash
cat /var/log/auth.log | grep $1

Script 6: User Management

Manage user accounts easily:

#! /bin/bash
USER=$1
GROUP=$2
sudo groupadd $GROUP
sudo adduser $USER
sudo usermod -aG $GROUP $USER

Script 7: Disk Management

Check disk space and usage:

#! /bin/bash
df -h
echo "Disk Usage of:" $1
du -sh $1

Script 8: Service Management

Manage services smoothly:

#! /bin/bash
sudo systemctl start $1
sudo systemctl enable $1
sudo systemctl status $1

Script 9: Process Management

Identify and manage zombie processes:

#! /bin/bash
ZOM=`ps aux | grep 'Z' | awk '{print $2}' | grep [0-9]`
DEF=`ps aux | grep 'Z' | awk '{print $2}' | grep [0-9]`
echo "Zombie and Defunct Process IDs are:" $ZOM "and" $DEF

Script 10: Firewall Management

Automate firewall rules:

#! /bin/bash
sudo ufw allow $1
sudo ufw enable
sudo ufw status

Bonus: Automating Scripts Using Cron

Further enhance efficiency by scheduling scripts with cron jobs. This allows scripts to run at specific intervals, freeing time for SysAdmins. Configure with crontab -e to set desired execution timing.

Conclusion

Bash scripting has transformed the way Linux System Administrators manage tasks. Through automation, repetitive actions can be streamlined significantly. By implementing the scripts outlined above, administrators can increase productivity and ensure system integrity.



Read the original article

0 Like this
Automate Bash Daily Linux Scripts SysAdmin tasks
Share. Facebook LinkedIn Email Bluesky Reddit WhatsApp Threads Copy Link Twitter
Previous ArticleAnthropic Scores a Landmark AI Copyright Win—but Will Face Trial Over Piracy Claims
Next Article US Judge sides with AI firm Anthropic over copyright issue

Related Posts

Linux

10+ Best Tools to Make Bootable USB from ISO (2025)

August 15, 2025
Linux

10 sFTP Commands to Move Files Between Linux Systems

August 10, 2025
Linux

AWS Fiasco, AUR Poisoned Again, Ubuntu Manual, Firefox New Tab Customization and More Linux Stuff

August 8, 2025
Add A Comment
Leave A Reply Cancel Reply

Top Posts

AI Developers Look Beyond Chain-of-Thought Prompting

May 9, 202515 Views

6 Reasons Not to Use US Internet Services Under Trump Anymore – An EU Perspective

April 21, 202512 Views

Andy’s Tech

April 19, 20259 Views
Stay In Touch
  • Facebook
  • Mastodon
  • Bluesky
  • Reddit

Subscribe to Updates

Get the latest creative news from ioupdate about Tech trends, Gaming and Gadgets.

About Us

Welcome to IOupdate — your trusted source for the latest in IT news and self-hosting insights. At IOupdate, we are a dedicated team of technology enthusiasts committed to delivering timely and relevant information in the ever-evolving world of information technology. Our passion lies in exploring the realms of self-hosting, open-source solutions, and the broader IT landscape.

Most Popular

AI Developers Look Beyond Chain-of-Thought Prompting

May 9, 202515 Views

6 Reasons Not to Use US Internet Services Under Trump Anymore – An EU Perspective

April 21, 202512 Views

Subscribe to Updates

Facebook Mastodon Bluesky Reddit
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
© 2025 ioupdate. All Right Reserved.

Type above and press Enter to search. Press Esc to cancel.