Bash Scripting Python Scripting administration tutorials
Guys are there any good tutorials out there which walk you through bash scripting / python 3 for useful system administration stuff like backup scripts.
Microsoft's strategy to conquer the I.T industry
" Embrace, evolve, extinguish "
" Embrace, evolve, extinguish "
Comments
-
ally_uk Member Posts: 1,145 ■■■■□□□□□□I found a pretty kool archive script
#!/bin/bash
#
#
# Daily_Archive - Archive Designated files and directories
#############################################################
#
# Gather The Current Date
#
DATE=$(date +%y%m%d)
#
# Set Archive File Name
#
FILE=archive$DATE.tar.gz
#
# Set Configuration and Destination File
#
CONFIG_FILE=/archive/files_to_backup
DESTINATION=/archive/$FILE
#
##################### Main Script ##########################
#
# Check Backup Config File Exists
#
if [ -f $CONFIG_FILE ] # make sure config file exists
then # if it exists do nothing and continue on!
echo
else
echo
echo "$CONFIG_FILE does not exist."
echo "backup not completed due to missing configuration file"
echo
exit
fi
#
# Build the names of the files to backup
#
FILE_NO=1 # start on line 1 on the config file
#
exec < $CONFIG_FILE #Redirect std Input to name of config file
#
read FILE_NAME # read 1st record
#
while [ $? -eq 0 ] # create list of files to backup
do
if [ -f $FILE_NAME -O -d $FILE_NAME ] #check the file exists
then
# if file exists add its name to list.
FILE_LIST="$FILE_LIST $FILE_NAME"
else
# If files doesn't exist, issue warning
echo
echo $FILE_NAME, does not exist."
echo "Obviously I will not include it in this archiuve."
echo "It is listed on line $FILE_NO of the config file."
echo "Continuing to build archive list."
echo
fi
#
FILE_NO=$($File_NO +1] # Increase Line/File by one.
Read FILE_NAME # read next record
done
#
#######################################################################
#
# Backup the files and compress the archive
#
echo "Starting Archive..."
echo
#
tar -czf $DESTINATION $FILE_LIST 2> /dev/null
#
echo "Archive completed"
echo "Resulting archive file is: $DESTINATION"
echo
#
exitMicrosoft's strategy to conquer the I.T industry
" Embrace, evolve, extinguish " -
Verities Member Posts: 1,162Linux Academy has by far the best course on BASH scripting I've come across:
The System Administrator’s Guide to Bash Scripting
It consists of about 7 hours of practical BASH scripting that can be modified for whatever you want done (i.e. reading files to create a list of users). Work on learning BASH first then move on to Python, which I believe they're currently creating a new course for. -
UnixGuy Mod Posts: 4,570 ModFind a task at work that you do repeatedly. Find a way to automate it. Google and see how other people automated it. Test, lab, learn, code.
You don't need tutorials -
chrisone Member Posts: 2,278 ■■■■■■■■■□You don't need tutorials
Isn't this a tutorial?Google and see how other people automated it.Certs: CISSP, EnCE, OSCP, CRTP, eCTHPv2, eCPPT, eCIR, LFCS, CEH, SPLK-1002, SC-200, SC-300, AZ-900, AZ-500, VHL:Advanced+
2023 Cert Goals: SC-100, eCPTX -
UnixGuy Mod Posts: 4,570 ModIsn't this a tutorial?
Kinda, but I meant he doesn't need a step-by-step how-to guide on how to automate things. Pick one task at a time -
UnixGuy Mod Posts: 4,570 ModPS: OP @ally_uk we answered your question 2 years ago...
http://www.techexams.net/forums/off-topic/106584-bash-scripting-101-a.html -
Verities Member Posts: 1,162PS: OP @ally_uk we answered your question 2 years ago...
http://www.techexams.net/forums/off-topic/106584-bash-scripting-101-a.html
*sigh*....
http://www.techexams.net/forums/lpi-rhce-sair/113314-lets-talk-about-scripting-learning.html
Its like no one uses the search function anymore. The same questions that have already been answered get asked over and over and over and over.... -
Kinet1c Member Posts: 604 ■■■■□□□□□□Linux Academy has by far the best course on BASH scripting I've come across:
The System Administrator’s Guide to Bash Scripting
It consists of about 7 hours of practical BASH scripting that can be modified for whatever you want done (i.e. reading files to create a list of users). Work on learning BASH first then move on to Python, which I believe they're currently creating a new course for.
Working my way through the LA course now, would recommend it to anyone looking to start or enhance their bash scripting.2018 Goals - Learn all the Hashicorp products
Luck is what happens when preparation meets opportunity -
ally_uk Member Posts: 1,145 ■■■■□□□□□□I know dudes 2 years I can barely output echo hello world I have the intention to learn but I want some interesting sysadmin stuff to get me interested otherwise I get bored of doing math, loopsMicrosoft's strategy to conquer the I.T industry
" Embrace, evolve, extinguish " -
Verities Member Posts: 1,162Working my way through the LA course now, would recommend it to anyone looking to start or enhance their bash scripting.
Yep, I went through the entire course and can now create extremely useful scripts (like nested functions that contain ansible commands, running reports on dead UIDs then removing them from systems, etc). You come out of the course with 20+ scripts that you can use in your daily sys admin duties. That course also satisfies the requirements of bash scripting for the RHCE. -
Kinet1c Member Posts: 604 ■■■■□□□□□□Some books which will be of use along the way: https://www.humblebundle.com/books/unix-book-bundle2018 Goals - Learn all the Hashicorp products
Luck is what happens when preparation meets opportunity -
Kai123 Member Posts: 364 ■■■□□□□□□□Some books which will be of use along the way: https://www.humblebundle.com/books/unix-book-bundle
I bought the TCP/IP and DNS/BIND books from Amazon a week ago (second hand but still €25 in total).
How do you personally find studying from e-books? I might get a decent kindle since that bundle is a lot of material to go through. -
Kinet1c Member Posts: 604 ■■■■□□□□□□I'm all about the physical books for studying tbh ... but this was too good a deal to pass up. I've got a kindle so going to try it out but would not use a tablet due to the type of screen.2018 Goals - Learn all the Hashicorp products
Luck is what happens when preparation meets opportunity