It's 10.30pm on a Saturday night and you decide to reinstall the server for kicks. Wouldn't it be great to have all those useful tidbits of information available immediately in your cortex?
Sometimes you just want to easily create a database and add a user...
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON [dbname].* TO '[username]'@'[host]' IDENTIFIED BY '[password]';
Dealing with all those webapps...
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chown -R www-data:www-data .
iptables boiler-plate...
*filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT DROP [0:0] -A OUTPUT -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT -A INPUT -s 192.168.1.0/24 -p tcp --dport 22 -j ACCEPT -A INPUT -p tcp --dport 80 -j ACCEPT :LOGDROP - [0:0] -A LOGDROP -j LOG --log-level 6 -A LOGDROP -j DROP -A INPUT -j LOGDROP COMMIT
Creating a python 3 virtual environment can always be tedious...
python3 -m venv your_dir_here #need python3.4-venv instead try virtualenv cd your_dir_here source bin/activate #this will activate the virtual env & change the prompt pip install --upgrade pip setuptools
Setting up a virtual environment in Pycharm Community Edition...



Remote backups made fun! From the origin machine, backup to a remote machine:
sudo rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / user_name_on_destination@192.168.1.xxx:/media/[your_external_usb_here] >> /home/somewhere_on_origin/server_backup_log.txt
The
"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
part just relaxes the certificate security for this job and forgets to remember the credentials for future runs.
It's also good to exlcude some non-essential directories.
I'll add more as they come to hand.