#A-1 - Linux, Bash and Git basics
Published: 2023-08-24 09:37:02

https://github.com/coconut-cracker

Intro

The first in a series of blogs designed to help me summarise, synthesise and present what I have been studying.
This half-year study plan has four sections, each one focussing on one core component of IT at the root of Cloud tech, and with a good (but not exhaustive) selection of knowledge, skills and practical experiences fundamental to start working in the field. They are as follows:

A – Linux, Bash + Networking
B – Python
C – Cloud computing
D – Devops

For each section I plan on publishing two or three blog posts, each one summarizing a group of new concepts covered, any mini-projects completed, or generally reviewing the overall experience for that sub-topic. The poetic prose and rambling soliloquies will be kept to a minimum as I aim to make these brief, straight-forward and factual (–  wellsprings of literary flamboyance must stay themselves till the end-of-section posts each month, whenceforth they may at last spill their silver-tinged jewels upon the glistening pages of dev.to’s glorious website…)

The cadence of posts is not set in stone but will be about once per week. There’s a schedule, an deadline having been planned for each post, but it will be down to Scout’s Honour and self-discipline to keep me on track, and not some totalitarian time-keeping supremo wielding a nutcracker. If I miss a blog or two, I will not self-flagellate in atonement so long as the whole Study Plan doesn't spin off the rails irrevocably. Anyway, with that all said, time to get down to it!

Curtains Up for Blog Post One.


#A-1  -  Linux, Bash and Git basics



Bash do be something I use everyday at work. I use it for navigating through filesystems of remote linux servers that run all the core infrastructure of my company’s clients (major financial institutions), and discovering the cause of errors when they arise. Once found, I do more bash-work to remedy the problem (such as modifying a file with vim, running scripts, moving files about between directories or connecting to MySQL or Apache to change data on a database), or I pass along the gathered info to client and/or internal technical teams with more know-how. All pretty simplistic stuff in a scheme of things, but a head-start in Bash nonetheless. 

Having said that, there is a vast wealth of fascinating new info that I’ve discovered. I’ve listed some below (an * is used to mark subjects where I feel a little reminder would be needed before I used it – say, less that 100% confidence; ** for things at 80% confidence or less)

Resources used:
    • Linux for Hackers book
    • ChatGPT
    • NetworkChuck’s youtube channel


Existing knowledge:

    • Various bash commands (cd, mkdir, cat, grep, sed, touch…)
    • file permissions
    • viewing processes


Things I’ve learned:

    • New bash commands and operators
        ◦ e.g. Alias’s and stringing commands together with &&
    • viewing network info with ifconfig and iwconfig
    • changing IP addresses, MAC addresses and DNS files*
    • terminating processes*
    • creating and running simple bash scripts
        ◦ Made a very simple ‘even or odd number?’ script using conditions. 
        ◦ Made a simple random-number guessing game using conditions and loops
        ◦ Pushed them to git via terminal commands (see below)
    • Environment and shell variables
    • $PATH and $PS1 variables*
    • piping outputs of commands (e.g. to grep)
    • passing on values of a variable with >
    • Interacting with git (github) through the linux terminal:
        ◦ setting up SSH keys and managing with the SSH agent
        ◦ Creating a github PAT (personal access token) to seamlessly interact with the github API, & storing it as an environmental variable
        ◦ creating a new remote repo, and pushing commits to the master branch from my local repo.
    • Use and purposes of [], {}, ${}, () and (()) **

Areas for further study:

    • For/while loops
    • condition, and more complex commands using operators:
        ◦ awk; sed etc..
    • More practise of bash syntax (brackets, operators etc.)
    • More bash script functionality (like passing and treating arguments, functions)

    • Azure CLI
        ◦ setting up resource groups & VMs, 
        ◦ Making Bash script to automate this process.
        ◦ More complex commands, functions etc.


Final thoughts:
Some of these concepts have already improved my workflow at work. I created aliases for frequently-used sequences of commands, and yesterday I wrote a small bash script that takes a file name as an argument, searches in various possible directories for transaction history details and file identifiers, uses that to extract another client ID from elsewhere, and returns that so it can be passed on to the client. I confess I cheated here; ChatGPT supplied me with the regex and feature to input user arguments, something I’ve not yet touched on.  That’s still on the list of “to do’s”.


Next Steps:
    • Start playing with Azure CLI, using new bash knowledge where applicable, e.g. automation.
    • Hook up Github with my local environment as start playing with pushing commits, branching etc. from the terminal.
    • Learn a little about the LAMP stack.
    • Milestone: Create an automation script for making new resource group, virtual machine and installing apache, mysql and php on the vm to make a LAMP server. Push it to Github.