Deep Dive Articles

The Best Way to Learn a New Programming Language from Scratch - How I Approach and Learn Any Programming Language Efficiently

Preface: The following article is based on my experiences and opinions on learning programming languages. I have been learning about computers in-depth and find learning languages with specific purposes useful. For example, Python was for beginning, C is for memory management and Rust is for learning to write memory-safe code in my case. This time, I started learning Golang which is known for its simple syntax and powerful performance, and widely known for its awesome concurrency.

Why More is Not Always Good in Terms of Software - Words on Cross Platform Utilities, Bash-ism, and POSIX Compliance.

Preface: This article is about my views on software compliance and cross-platform support, and reflects my opinions and experience with the subject. Your experience and opinions may vary, which I respect. What I am Specifically Talking About? I am going to talk about the issues caused by non-compliant software and why more features are not always good, especially in the case of the upgrade of tools on a single platform.

Why I Shifted From Arch Linux to Debian Linux?

Preface: The following article is based on my personal experience with Arch Linux and Debian Linux. While I appreciate both distributions for their unique strengths and different use cases, the information provided reflects my own opinions and experiences. Your experiences may vary. What was I going for Initially? Bit of my Story as a Beginner Linux User When I started using Linux, I was going through security stuff and learning computer security when I was in my High School.

Tmux is the Ultimate Choice for Power Users - An Awesome Terminal Multiplexer for Managing Persistent Sessions

What is Tmux? Tmux is a Terminal Multiplexer Application for Linux and MacOS for managing terminal sessions and Windows. It is to be mentioned that Tmux is not a terminal emulator, instead, it’s a terminal application, a binary that allows you to stay productive over your terminal. It doesn’t matter which terminal emulator you are using (although I recommend the Suckless Terminal). The functionality of managing Windows and the session doesn’t happen on the desktop GUI side but on the terminal session, you are working with.

The Concept of RSS Feed - A Reliable Way for Publishers and Subscribers Model

Preface: I have been looking for simple solutions in nearly everything related to computing. A lot of software designed these days is not designed per your requirements but as per companies’ profit. Hence, most of these solutions end up sucking your time and energy and need to be replaced by more optimised solutions that would boost your productivity in the right way. RSS Feed is something that I found after searching for solutions related to subscribing to websites or creators without sucking much resources and design that is reliable to the user itself.

Breaking RSA Encryption on Hardware Devices with Side Channel Power Analysis — Leaking the Private Key by Exploiting Square-Multiply Algorithm

Preface: This article is about leaking the private key from hardware devices that implement RSA encryption which is part of hardware hacking. The author is not responsible for any damage caused by the given information. It is recommended to be careful while performing these attacks as they can damage the hardware or even destroy it. All the information provided here is for educational purposes. There are no such prerequisites for understanding the theory, although knowledge about modular arithmetic, basics of encryption mathematics, basic electronics, etc.

Serious Reconnaissance with Unmanned Aerial Vehicles — Mapping Out Devices in an Area with Drones

Introduction: The following content is for educational purposes and for hackers living in basements knowing enough ethics. The author is not responsible for any damage caused by the knowledge provided here and does not support anything like that. It’s essential to check out the rules in the area of reconnaissance about the tactics provided here and the use of materials (unless and until there is any apocalypse and a solid recon is required).

The Fundamentals of Hardware Hacking — Breaking and Reverse Engineering Smart IoT Devices

Disclaimer — This is an introductory article about Hardware Hacking and Security of IoT Devices. None of the mentioned information or techniques are intended for any illegal purposes and the author is not responsible for any damage. It’s advisable to experiment on devices that you own or have explicit permission to do so. Rest of all, hardware hacking is fun! The Beauty of Electronic Devices In the ever-growing world of smart devices and the connectivity of things to the internet, life has become more convenient than ever.

Setting Up a Remote Git Server — A Simple and Concise Step-by-Step Guide to Host a Private Git Server

Preface: This is a concise and simple guide to hosting a remote git server. I have been researching this topic for a while and came up with the idea of writing an article with a step-by-step guide for hosting a private git server. Covering all the aspects of git is not possible in a single article, so it’s assumed that the reader has prior knowledge of git and version control.

The Nature of Linux Kernel Development — Difference Between Rules of Kernel Level and User-Space Application Level

Preface: This article is intended to explain a clear distinction between the core principles of Linux Kernel Development and User-Application Level Development. The provided information is based on my research on Kernel Development through various sources and I have tried to make it as accurate as possible. Efforts have been made to explain it as simply and concisely as possible. Introduction to the Nature of Linux Kernel Linux Kernel is the abstraction layer between the Operating System and the Hardware in the system.

Linux Process Scheduling — The Reason your Linux System Processes so Efficiently (Kernel Perspective)

Preface: I was going through the book “Linux Kernel Development” by Robert Love, one of the best books I have referred to for low-level stuff and understanding the workings of Linux. I study this book with intensity, simplify the concepts and write it down here so that the readers can get a straightforward description and all they need to know about the topic. Covering the whole Linux Process Scheduling is not possible and is not the goal of this article.

Linux Processes — A Kernel’s Perspective Explained with Clarity and Simplicity

Preface: I have been going through the book “Linux Kernel Development” by Robert Love which I highly recommend for understanding the Linux Kernel in depth. I decided to write this article to explain “Linux Processes” simply and concisely. The topic itself is broad and is not explained into the deepest of it, but essential for Linux Administrators, Developers and even Linux users to appreciate the beauty of the Kernel they make use of every day.

NGINX for Deploying Next.js Application on AWS EC2 with AWS ELB — Control and Stability of Deployments

I was looking for an article like this a few days ago, which I didn’t find at that time, so I did the deployment on my own and came up with this article to prevent other developers from saving those efforts and focusing on development. I am not explaining every single step and have provided links for references. I prefer manual deployment of applications over automated (and even serverless) methods. Although they are convenient and require less effort by the developers, they are bound to the providers and offer less control over the underlying system.

Configuring and Building the Linux Kernel — Absolute Guide to Compiling Your Kernel

Linux Kernel is an Open-Source Software and the user is free to modify and customise it as per the requirements. The modification of the Kernel requires a deep understanding of the working of the Kernel, although patches are available to make the Kernel optimised for specific hardware. Linux Kernel Source Code has various options to configure the drivers, modules, preferences on hardware options, etc. This part can be studied by the user and is pretty much easy to work with.

The Elegance of the Linux Kernel — A Concise History of Unix and the Creation of the Linux Kernel

Introduction and Context I was going through the book “Linux Kernel Development” by Robert Love, an absolute guide to getting started with Linux Kernel Development and a highly recommended book for understanding the core of the Linux Kernel. Linux Kernel has been one of the most important software ever written and is even considered one of the biggest projects ever undertaken by a single person. The idea of the Linux Kernel was initiated by Linus Torvalds, a student from the University of Helsinki and is maintained by him to date (while writing this article).

Linux Shell Scripting — A Suckless and Concise Guide to the Command-line of Linux

Prior Statements: This is a concise guide on the Linux Shell Scripting while consolidating all the facts about the Linux Shell for quick developer’s reference while using Linux. I am referencing the Bash (Bourne-Again Shell) which is the default shell for Linux-based systems. I will also be providing references and external links to dive into depth and not fill the article with too much explanation about a single topic which is not universally required by all the readers.

Suckless Utilities for Arch Linux — The Most Minimal Way Run a Computer

Suckless utilities have been my favourite at this time and kind of essentials for my use of the computer. I have been using Arch Linux for a fair amount of time now and I started using it with XFCE for few weeks. I would appreciate the XFCE desktop environment for it’s smoothness and light-weight nature with works really fine when newly shifting on Arch Linux. But then I learnt the suckless ecosystem and eventually shifted to it as my full-time environment.

Installing Pacman in Arch Linux — When You Blow it Up

Let me suckless and divide the article into two parts: My story how I blew up Pacman Package Manager How to reinstall the Pacman Package Manager If you only care about the second part, skip the first one. The Scenario — Blow it Up I was trying to install the pacman game from the Internet to get it running on my Arch Linux Terminal (I use Suckless Terminal BTW). When I got it installed and played it, it was super awesome.

Boot Process of Computers — A Learner’s Perspective Of Exploring the Depth of Computers

Prior Clarifications: Here, I will be providing a philosophical explanation about the bootloaders and understanding them in a simple and as minimal way as possible. This is not supposed to be a manual for bootloader or provide any advice for experimenting over your live system. It’s my journey to understand computers (one of the most complex creations of mankind) and I will be stating my thoughts. Take it with a pinch of salt.

Networking Fundamentals for Linux Administrators — A Suckless and Concise Explanation

Statistics are clear on the fact that 96.3% (while writing this article) of the servers use Linux as their Operating System which is no doubt what every other Linux user on this Earth expects. I believe that the Linux Administrator has to take the shot about the configuration of Networking in Linux Based Server. Some of the underlying concepts remain the same for any other distros but it is mainly intended for Linux.

Operating Systems and Low-Level Access to the Hardware — Why should you learn it?

Today, I completed the whole read of the book “Linux Kernel in a Nutshell” by Greg Kroah-Hartman and I highly recommend that you go through it if you want to understand how to build your custom configuration of Linux Kernel and all you need to know about all the nuts and bolts. It’s always great to have such handbooks around the desk. This blog is about why it’s so awesome to look into the operating system you are using with your hardware and why have a grasp on the Low-Level aspects of a computer.

Arch Linux Custom Builds — Freedom of the Operating System

While writing this blog, I was reading the book “Linux Kernel in a Nutshell” by Greg Kroab-Hartman and as far as the pages of the book are concerned, it seems to be a two-day read (this is a handbook so reading it once and having around the desk is super useful). By the way, the author has the book left open for download http://www.kroah.com/lkn/ so check that out if you want to follow up.

Bypassing the Linux Login to access the files (with Physical Access), even the root!

Imagine being away from the computer for a couple of minutes and getting to know that the system has been compromised and a backdoor has been installed into the system. “The system was locked?” doesn’t matter, without the bios security implementation (which most probably would not be implemented), all the files can be recovered without any login made to the Login Screen. This goes with the story of me trying to get my Wi-Fi troubleshooting in Arch Linux where I was trying to upgrade the Kernel of my System to get the Wi-Fi working properly (as mentioned in the previous blog.

Linux Shell Scripting — A Suckless and Concise Guide to the Command-line of Linux

Planted January 19, 2024

Prior Statements: This is a concise guide on the Linux Shell Scripting while consolidating all the facts about the Linux Shell for quick developer’s reference while using Linux. I am referencing the Bash (Bourne-Again Shell) which is the default shell for Linux-based systems. I will also be providing references and external links to dive into depth and not fill the article with too much explanation about a single topic which is not universally required by all the readers. Bash Scripting is a vast topic and cannot be covered in a single article. I will be providing the very basics here and providing references to external links to learn more.

Overview of the Shell in Operating Systems

The shell is a program that acts as a buffer between the user and the operating system. It is a command interpreter and acts invisibly. The three main uses for the shell are:

  1. Interactive use of the system
  2. Customizing the Linux session by defining variables and startup files
  3. Programming, by writing and executing shell scripts

“Computers are incredibly fast, accurate, and stupid. Human beings are incredibly slow, inaccurate, and brilliant. Together they are powerful beyond imagination.”- Albert Einstein

Historical Overview of the Linux Shells

Bourne Shell was the standard shell used for writing shell scripts. Bourne Shell is still found in the /bin/sh on the Linux Systems (although they are now symbolic links to the Bash). The Berkeley C shell (csh and later tcsh) offered better features for interactive use, such as command history and job control. For a long time, the standard practice was to use the Bourne-Shell for programming and the C-shell for daily use. David Korn at Bell Labs enhanced the Bourne shell by adding csh-like features and his shell was known as the Korn shell (ksh).

The Free Software Foundation developed a clone of the Bourne Shell and developed the Bourne-Again Shell (Bash). Bash has become a POSIX-complaint version of the shell, incorporating many popular features from other shells like csh, tcsh and ksh. Bash is now the primary shell for Linux.

Another popular shell is the Z Shell (zsh) which is similar to the ksh but with many extensions. zsh differs from the bash in two ways: it is based on ksh and does not attempt to be POSIX-compliant.

To get a grip on the Linux command line, it is essential to understand basic Linux Commands. Canonical (the creator of the Ubuntu Linux Operating System) has provided a guide for absolute beginners to learning the basics of the command line. The Linux command line for beginners. Experience with operating the Linux command line is also essential.

The Prefix and Executing Shell Script

The shebang for shell scripts is #!/bin/bash. This tells the system that the executing file is a bash script and it needs the bash interpreter to work. Before executing a shell script, it’s essential to mark it as executable and provide the necessary permissions by using the command: chmod +x <filename>. To execute the script: ./<filename>.

Read, Store, Print and Wait ….

Declaring a variable: name="maverick"

Reading User Input: read name

Printing content and variables: echo "hello $name" ($ symbol returns the value of the variable)

Delay for some time: sleep <no_of_seconds>

Arrays in Bash Scripts

Arrays can be declared in the following way:

#!/bin/bash

declare -a languages=(
[0]=rust
[1]=golang
[2]=python
[3]=c
)

echo "${languages[@]}"

Running System Commands in the Script

name=$(uname): This will execute the uname command and store it’s output in the name variable. (print the output with echo "$name")

Predefined Variables in Linux Shells

eg. RANDOM

$RANDOM will return any random number between 0–32767

The outputs of the commands given below are just examples:

>> echo $RANDOM
30011

>> echo $PWD 
/root

>> echo $SHELL 
/bin/bash

>> echo $USER 
root

>> echo $HOSTNAME 
localhost

Note: The double quotes in the bash script support a lot of symbols that can be used for various purposes. On the other hand, single quotes are strict and consider everything inside them to be string.

Arithmetic Operations in bash

>> echo $(( 2 + 3 ))       # Addition 
5

>> echo $(( 2 / 3 ))       # Division
0

# Note: Bash does not return the data in float. 2/3 = 0.666666.....

>> echo $(( 10 / 3 ))      # / is for division
3

>> echo $(( 10 & 3 ))      # & is for remainder
1

Example Snippet of a Bash Program

#!/bin/bash

echo "What is your name?"

read name

echo "How old are you?"

read age

echo "Hello $name, you are $age years old."

sleep 2

lucky_number=$((( $RANDOM % 10 ) + $age ))

echo "$name, your lucky number is $lucky_number"

Conditional Statements

read number 

if [[ $number = 10 ]]; then 
  echo "number is 10"
elif [[ $number = 20 ]]; then
  echo "number is 20"
else 
  echo "The number was not guessed: $number"
fi

The following was a quick reference to if and else statements and all you need to know to understand them. They can be used for making decisions and adjusting the control flow of the scripts. They are highly useful in Linux Automation when handling errors and edge cases.

case $number in                 

        1)
                echo "It's 1"
                ;;              # This means go ahead and check next case

        2)
                echo "It's 2"
                ;;
        3)
                echo "It's 3"
                ;;
esac

Case statements can be used to consolidate the if-else statements and create very specific cases for the control flow of the script to continue.

Comprehensive Example for Control Flow and Conditionals in Bash:

#!/bin/bash

# Yes, I am a Hacker and this script is an example hacker manual

echo "This is a tool manual. Enter the tool number to get information about it.
1. metasploit
2. aircrack-ng
3. hydra"

read number

echo "Are you a experienced hacker? (y/n)"

read answer

case $answer in                 


        y)
                echo "This is a very basic manual for you then.... "
                ;;

        n)
                echo "This is useful for you then!"
                ;;

esac

case $number in

        1)
                echo "You have selected the metasploit option"
                ;;

        2)
                echo "You have selected the aircrack-ng option"
                ;;
        3)
                echo "You have selected the hydra option"
                ;;
esac


if [[ $number == "1" ]]; then
 echo "Do you want to know about msfconsole or msfvenom?
 1. msfconsole
 2. msfvenom"

 read number

 if [[ $number == "1" ]]; then
  echo "msfconsole is a interactive environment framework for exploitation of known vulnerabilities as well as exploit development"

 elif [[ $number == "2" ]]; then
  echo "msfvenom is a payload generater"

 fi

elif [[ $number == "2" ]]; then
 echo "Aircrack-ng is Wi-Fi penetration framework"

elif [[ $number == "3" ]]; then
 echo "hydra is a fast login bruteforcer"

fi

echo "Thank you for using this manual"

Loops in Bash Script — While, Until and for loops

While Loop: A while loop continues to loop over a snippet of code until the conditions provided are true. As soon as it gets false, the while loop is escaped and further script is executed.

#!/bin/bash

x=1

echo "Number of clicks to end"
read target

# The condition will be provided to the while loop
while [[ $x -le $target ]]           # -le means less than or equal to
do
 read -p "Click $x: Press enter to continue"

 (( x++ ))                           # Post incremental operator
done

echo "Target completed"
while true          
do
 echo "This goes forever!"
done

Until Loop: Until loops continue to run until some condition is true. The loop initiates when the given condition is false and executes the given snippet of code until the provided conditions are true.

#!/bin/bash

until [[ $password == "correct_password" ]]
do
 echo "Enter the password: "
 read password
done
echo "Access Granted!"

Until loops are kind of opposite to while loops. They run until the provided condition is satisfied.

While loop runs while the given condition is true. Until loop runs until the given condition is true.

For Loop: For loops don’t wait for a certain condition to be true and execute the given snippet of code until the specified range of items are selected and covered.

for cups in 1 2 3 4 5 6 7 8 9 10;
do
 echo "Hey, you've had $cups of coffee today. "

done
for cups in {1..10};        # range is provided for simplicity
do
 echo "Hey, you've had $cups of coffee today. "

done

For loop can be useful for various purposes like traversing over files in the directory or even going through lines in a file, etc.

#!/bin/bash

declare -a languages=(
[0]=rust
[1]=golang
[2]=python
[3]=c
)

# Itterating over arrays with for loop
for i in ${languages[@]}
do
echo -e "$i \n"
done

Some example scripts for reference

#!/bin/bash

# Script to check if the given website is up
for x in google.com bing.com facebook.com;
do
 if ping -q -c 2 -W 1 $x > /dev/null; then
  echo "$x is up"
 else
  echo "$x is down"
 fi
done
#!/bin/bash

# Checking the weather in the cities provided in the cities.txt file
for x in $(cat cities.txt);
do
 weather=$(curl -s http://wttr.in/$x?format=3)
 echo "The weather for $weather"

done
#!/bin/bash

# Script to create a Wi-Fi prompt for suckless dmenu (my own Arch linux script)
interfaces=$(nmcli device | awk '$2=="wifi" {print $1}')

selected_interface=$(echo "$interfaces" | dmenu -p "Select a network interface:" -l 10)

wifi_list=$(nmcli device wifi list ifname "$selected_interface" | awk '{print $2}')

selected_network=$(echo "$wifi_list" | dmenu -p "Select a Wi-Fi network:" -l 10)

password=$(echo "" | dmenu -p "Enter the Wi-Fi password:")

nmcli device wifi connect "$selected_network" password "$password"

echo "Connecting to $selected_network..."
#!/bin/bash 

# Converts an image or a directory of images to .webp format
if [ -d "$1" ]; then 
  for file in "$1"/*; do 
    if file --mime-type "$file" | grep -q "image"; then
      cwebp "$file" -o "${file%.*}.webp"
      echo "[+] Converted $file to ${file%.*}.webp"
    else 
      echo "[-] Skipping file: $file"
    fi
  done
else
  file=$1
  cwebp "$file" -o "${file%.*}.webp"
fi
echo "Conversion Completed"

There are a lot of references to go with for learning and mastering Linux Shell scripts.

Books I recommend:

Wicked Cool Shell Scripts: 101 Scripts for Linux, OS X, and Unix Systems — Dave Taylor, Brandon Perry

  • Linux in a Nutshell — Ellen Siever, Stephen Figgins, Robert Love and Arnold Robbins
  • Linux Shell Scripts have been very useful for my overall computer usage. I have been using Linux as my primary operating system and I am safe to say that my whole computer works on the backbone of these shell scripts. Bash Scripting have a lot of usage in automating tasks and I believe them to be holding the power of automating IT systems in a versatile and simple fashion.