Some Bash Scripts to Manage Remote Server

Script to Update and Upgrade

#! /bin/bash

chmod 700 /usr/bin/apt-get
chmod 700 /usr/bin/aptitude
chmod 700 /usr/bin/dpkg
swapoff -a
chown username:username /home/username/*
chmod 700 /home/username/*
apt-get update && apt-get upgrade --show-upgraded -y

Script to End session and Harden some critical files

#! /bin/bash

swapon -a
chmod 000 /usr/bin/apt-get
chmod 000 /usr/bin/aptitude
chmod 000 /usr/bin/dpkg
find /home/username/ -size  0 -exec rm '{}' \;
/home/username/mysql-defrag.sh
netstat -plunt

You may also like...