fbpx

5 reasons for you to store your Bash scripts in Git repositories

1 Maintain a history of your script improvements – Force yourself to continuously improve

Git will help you to get a clear overview of how your scripts have evolved. Maybe you need to go back a version or two and fork a script from there. If you have added proper comments in your scripts, than you and others can follow your reasoning easily.

A funny thing happens when you start adding code in Git repositories and update them as you add or change code. You become more prone to improving your code as you know which parts needs some more work. Maybe even a #ToDo note somewhere that signifies a totally new feature – That #ToDo comment will nag you more when you have a Git repository and constantly go there to check it out. Add the reasoning in reason number 2 and you also feel the peer pressure from others to continue building on your useful scripts.

2 Others might take over your scripts for regular usage

Think of the Linux users that you will work with and that will need the same toolchest that you have. Show some team spirit and share your work, of course with proper attribution to you as a script programmer. This gives you a lot of respect

3 Understand the fallacy of “the perfect script” thinking

There are no perfect scripts. No silver bullets to any IT problem of a larger scale. In the Linux world we are also used to many ways to solve simple tasks on the commandline in many ways. This statement can then be used to argue that your solution has no need to be hidden away or not to be covered by version control. With version control you introduce the idea of newer and better versions of your Bash script. It is a nice trick to show yourself and others that yes, improvements and new ideas are welcome.

4 DevOps and Test-Driven Development ask for iteration and cross-border approaches

These two paradigms really show that more collaboration is expected between subject matter experts, whether a Linux user, a Python scripter, or a LAMP Engineer (to give only three examples). We get inspiration from each other’s solutions to tasks on the commandline. These solutions are stored in Bash scripts. By using Git you show that you are open to the idea of sharing your scripts as well as reject the notion of the “write once, all good, don’t argue” type of mentality.

5 Git is used to version control more than you think

These days you will find that Git is used by many more than programmers. From technical writers to scripters and data scientists. The idea of applying version control and having central repositories that can be forked and worked on by many people is simly very appealing. It also deals with the number one silo: The expert that sits on all the knowledge but that is so tremendously useful to others as well.

How To – Get a grip on those network connections with pstree and lsof -i

As you know, you can string Linux commands together to achieve larger and more complicated tasks. Here we will look at locating processes that are connecting over the network. We will see how to locate established and listening endpoints.

We will also print process trees to understand how Apache2 forks processes to do load balancing of network connections.

First, let’s check all open files that are Internet addresses. All network connections will be identified by a network file (such as an Internet socket, which we are interested in here).

NailLinuxExam – Check those open network connections!

Bash: Automate enabling of Apache sites and modules

Want to automate the enabling and disabling of Apache sites and modules? Tired of running those a2enmod, a2dismod, a2ensite, and a2dissite commands? And then the cleanup involved with the same commands and the Apache2 daemon?

Check out this Bash wrapper for the Apache operations commands. It’s free to use and modify.

For the happy Linux and Bash experimenters out there, it’s a useful starting point to get started with Bash functions.