Options

Bash Scripting Python Scripting administration tutorials

ally_ukally_uk Member Posts: 1,145 ■■■■□□□□□□
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 "

Comments

  • Options
    ally_ukally_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
    #
    exit
    Microsoft's strategy to conquer the I.T industry

    " Embrace, evolve, extinguish "
  • Options
    VeritiesVerities Member Posts: 1,162
    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.
  • Options
    UnixGuyUnixGuy Mod Posts: 4,565 Mod
    Find 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
    Certs: GSTRT, GPEN, GCFA, CISM, CRISC, RHCE

    Learn GRC! GRC Mastery : https://grcmastery.com 

  • Options
    chrisonechrisone Member Posts: 2,278 ■■■■■■■■■□
    UnixGuy wrote: »
    You don't need tutorials

    Isn't this a tutorial?
    UnixGuy wrote: »
    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
  • Options
    UnixGuyUnixGuy Mod Posts: 4,565 Mod
    chrisone wrote: »
    Isn'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
    Certs: GSTRT, GPEN, GCFA, CISM, CRISC, RHCE

    Learn GRC! GRC Mastery : https://grcmastery.com 

  • Options
    UnixGuyUnixGuy Mod Posts: 4,565 Mod
    Certs: GSTRT, GPEN, GCFA, CISM, CRISC, RHCE

    Learn GRC! GRC Mastery : https://grcmastery.com 

  • Options
    VeritiesVerities Member Posts: 1,162
    UnixGuy wrote: »

    *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....
  • Options
    Kinet1cKinet1c Member Posts: 604 ■■■■□□□□□□
    Verities wrote: »
    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
  • Options
    ally_ukally_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, loops
    Microsoft's strategy to conquer the I.T industry

    " Embrace, evolve, extinguish "
  • Options
    VeritiesVerities Member Posts: 1,162
    Kinet1c wrote: »
    Working 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.
  • Options
    Kinet1cKinet1c Member Posts: 604 ■■■■□□□□□□
    Some books which will be of use along the way: https://www.humblebundle.com/books/unix-book-bundle
    2018 Goals - Learn all the Hashicorp products

    Luck is what happens when preparation meets opportunity
  • Options
    Kai123Kai123 Member Posts: 364 ■■■□□□□□□□
    Kinet1c wrote: »
    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.
  • Options
    Kinet1cKinet1c 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
Sign In or Register to comment.