bash

Sed It Right: Mastering the Stream Editor for Text Magic

Sed It Right: Mastering the Stream Editor for Text Magic

We all feel the pain of regex's weird syntax, but hey, we're not going to let that stop us from achieving greatness! Despite its quirks, regex is a powerhouse when used in combination with sed. Let’s harness its strength! sed becomes a real powerhouse when you start using regex to match patterns more intelligently. For example, suppose you want to replace any sequence of digits with the word "[number]": sed 's/[0-9]+/[number]/g' text.txt Enter fullscreen mode Exit fullscreen mode This will replace any group of digits ([0-9]+) with "[number]" throughout the file. Regex allows you to create powerful and flexible searches,…
Read More
Writing a Telegram and Email Notifications Script for Zabbix

Writing a Telegram and Email Notifications Script for Zabbix

Monitoring your whole infrastructure is very essential specially in IT infrastructures. I recently learn creating and writing scripts for monitoring like this. I will share you how I make telegram and email notifications script. This script sends an telegram and email notification whenever a problem in the infrastructure occurs. What is Zabbix Zabbix is an open source software that monitors numerous parameters of a network and the health and integrity of servers, virtual machines, applications, services, databases, websites, the cloud and more. Zabbix uses a flexible notification mechanism that allows users to configure email-based alerts for virtually any event. This…
Read More
[DAY 90-92] I made a shell script to build me a world cup database

[DAY 90-92] I made a shell script to build me a world cup database

Hi everyone! Welcome back to another blog where I document the things I learn in web development. I do this because it helps retain the information and concepts through active recall. On days 90-92, I finished building a script to automate creating a database, a translator using a shell script, and started building an interactive bash program. The first project is where I created a bash script to make a database about world cup matches in PostgreSQL. This is part 2 out of 5 certification projects in the relational databases course in freecodecamp. I also made a script on the…
Read More
How to Debug Scripts in Bash

How to Debug Scripts in Bash

When I was first starting out with some command line automation and development, I remember spending many hours trying to find the error in my code, and in the end, it could be something very simple, like a comma. You may have faced the same situation as well. Knowing how to use proper debugging technique will help you resolve errors quickly. Unlike other languages, there is no debugging tool for bash where you can set breakpoints, step through code, etc. But you can enable some options in your scripts for debugging, which can help you, as follows: Enable debugging flags…
Read More
‘hi’ shows it’s colors

‘hi’ shows it’s colors

I previously introduced ‘hi’ – the Host Information tool to the world and described it’s base functionality. Later, I described how hi can be used to craft more complex notifications. In this article, I’ll describe some of the latest features implemented as part of the v0.4.5 pre-release.Get ‘hi’ on GitHub: https://github.com/jbobbylopez/hi Logging and State Management One of the biggest features introduced is the use of the logging module to implement a logging facility to log every status change event detected by the ‘hi’ tool. State is captured as a JSON file, which is then compared against the current state of…
Read More
Automating User and Group Management using Bash Script

Automating User and Group Management using Bash Script

[*] Creating users and groups manually particularly in a large environment can be time consuming and tedious. Automating this task with a bash script saves time and errors.This script create_users.sh streamline the process, automates the creation of users and groups, sets up home directories, generates random passwords, and logs all actions. This article explains each step of the script and provides insights into its implementation. Script OverviewThe script reads a input file containing usernames and group names, creates users and groups as specified, sets up home directories with appropriate permissions and ownership, generates random passwords, and logs all actions. Additionally,…
Read More
Linux User Creation Bash Script

Linux User Creation Bash Script

As your company scales and brings in new developers, managing user accounts manually can become cumbersome and error-prone. Automating this process with a Bash script can save time and ensure consistency across the board. In this article, I'll walk you through creating a Bash script called create_users.sh that reads a text file containing usernames and group names, creates the necessary users and groups, sets up home directories, generates random passwords, and logs all actions. Let's dive in! RequirementsInput File: A text file where each line is formatted as user;groups. Usernames and groups are separated by a semicolon ;, and multiple…
Read More
How to Get the Directory Where a Bash Script is Located

How to Get the Directory Where a Bash Script is Located

Hello everyone! When you're working with Bash scripts, it's often useful to know the directory where the script itself resides. This can be essential for referencing relative paths, ensuring the script works correctly regardless of where it is executed from. Let’s dive into how you can achieve this. Method 1: Using dirname and $0 The simplest way to get the directory of the script is to use the dirname command in combination with $0. Here's a step-by-step explanation: $0: This special variable contains the path used to invoke the script. It might be a relative path, an absolute path, or…
Read More
Bash Scripting for Software Engineers – A Beginner’s Guide

Bash Scripting for Software Engineers – A Beginner’s Guide

It's your first day at your new job. You've been handed a computer running Linux, and you were told to locate all the files containing the word "key". It's a simple enough task, right? The catch is, there are thousands of files on that system, and you've never written a shell script before. Shell scripting, the language of the command line, is your ticket to automating repetitive tasks and mastering your Linux environment. With this guide, you'll be able to navigate your way around any Bash terminal with ease, and you might learn a couple of cool tricks along the…
Read More
0x00. Shell, navigation

0x00. Shell, navigation

File System Organization Like Windows, the files on a Linux system are arranged in what is called a hierarchical directory structure. This means that they are organized in a tree-like pattern of directories (called folders in other systems), which may contain files and subdirectories. The first directory in the file system is called the root directory. The root directory contains files and subdirectories, which contain more files and subdirectories and so on and so on. The basic three commands include: pwd (print working directory) cd (change directory) ls (list files and directories). pwd The directory we are standing in is…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.