Git Basics

May 11, 2024

Today, we're learning about Git, a system that lets you track changes to your code over time.

This guide will equip you with the essential Git skills to start using version control locally straight away. Here's what we'll cover: 

  • What is Git and why is it awesome? 
  • Installing Git on your machine 
  • Basic Git commands to navigate version control 
  • Putting it all together with a practical example 
  • Untrack and/or remove files 

Git: Your Code's Best Friend 

With Git you can: 

  • Travel back in time: If you accidentally deleted some code, with Git you can revert to previous versions seamlessly. 

  • Work Together Smoothly: While working on a project with a team, Git lets you see each other's changes and merge them effortlessly. 

  • Track your progress: Git keeps a detailed history of all your code changes, making it easy to keep track of your project. 

Getting Started: Git on Your Machine 

Git usually comes installed by default on most Mac and Linux machines. To check if this is true to you open your terminal application and type: 

git --version 

  • From Red Hat Linux, Git installed by default: 


  • From Windows 11, Git not installed: 


If you get no version number back, the first step is to install Git on your computer. Head over to the official Git website ( and download the installer for your operating system. The installation process is straightforward, just follow the on-screen instructions. 

Git Commands 101 

Now that Git is set up, let's learn some basic commands to get you started: 

  • git init: This command initializes a new Git repository in your current directory. It basically marks a folder as a project for Git to track. 

  • git add <filename>: This command adds a specific file to the staging area, which is like a temporary holding zone before you commit changes. It adds the file to be tracked by Git. You can also use – a period after ‘add 

  • git add .  which will add all files in the current directory to be tracked. 

  • git commit -m "<message>": This command captures the changes you've added to the staging area and creates a permanent snapshot of your project, along with a descriptive message. It’s like saving your code changes. 

  • git status: Use this command to see the status of your project. It will show you which files are modified, staged (ready to commit), or committed. 

  • git log: This command displays the history of your commits, like a time machine for your code! 

  • git ignore <filename>: This command will tell Git to not track that file. Usually files with credentials, passwords etc. 

Putting it into Practice: The Course Catalogue Example  

Let's use a practical example to understand better these concepts. Imagine you're building a course catalogue application. Here's how Git can help: 

  1. Initialize the Git repository: Open your terminal and navigate to your project directory. Then, type git init to create a new Git repository. 

  1. Create some files: Let's say you create three files: index.html, styles.css, and app.js. These files contain the code for your application. 

  1. Stage your changes: Once you've written some code, use git add index.html styles.css app.js to add all three files to the staging area. 

  1. Commit your changes: Finally, run git commit -m "Initial commit - Course Catalogue App" to create your first commit with a descriptive message. 


Removing Files 

Let's say you decide you don't need the "index.html" file anymore. Here's how to remove it from Git's tracking: 

  • Removing from Tracking (Keeping the File): 

Use git rm --cached index.html. This removes "index.html" from Git's tracking, but the file itself remains in your directory. 

  • Complete Removal: 

Use git rm -f code. This removes "index.html" from Git's tracking and also deletes it from your directory. Be careful! This option is permanent. 


Bonus Tip: Collaboration Magic 

Git is really helpful when collaborating with others. By hosting your Git repository on a platform like GitHub, you and your team can share code, track changes, and merge updates effortlessly. But that's a story for another day! 


Discovering Docker & Kubernetes - Work in Progress (WIP)

July 21, 2023

·       About Docker

·       Namespaces

·       Control Groups

·       Container Image

·       Container Runtimes

·       Container Orchestration

·       Kubernetes Cluster

·       Kubernetes Main Resources (Pods, Services, Replication Controllers, Persistent Volume, Persistent Volume Claims)

·       Docker Commands

·       Docker Client Verbs

·       Managing Containers

Docker uses a client-server architecture, described below:    

                                 Client                      ...

Continue reading...

Ping from a script

July 3, 2023

Method: We can write our own script using the ping command to query list of IP addresses and check whether they are alive or not as follows:




# Change base address 192.168.0 according to your network.


for ip in 192.168.0.{1..255} ;

       #Amount of packets transmitted "-c 2"
       #/dev/null is a virtual file. This will discard anything written to it.

ping $ip -c 2 &> /dev/null ;

if [ $? -eq 0 ];


echo $ip is alive




Continue reading...

Git main commands

July 3, 2023

Git status

Git add .      (this adds everything or choose specific file to be added)

Git commit -m "my message"

Git push

Enter passphrase for key '/c/Users/rxxxxxxx/.ssh/id_rsa':

Continue reading...

For Machines Without Telnet Installed

July 3, 2023

cat < /dev/tcp/IP/PORT

cat < /dev/tcp/


curl -v telnet://ip:port'

curl -v telnet://

curl -v telnet://

Continue reading...

Helper Script

July 3, 2023



echo "----------------------------"

echo "Sourcing Functions:"

echo "----------------------------"

echo " - nodes_up: Checks what hosts are up or down using nmap"

echo " - slbs_status: Check if NGINX Process and Status in AZ1 & AZ2"

echo " - slbs: Check if NGINX nodes are up / down using nmap in AZ1 & AZ2"

echo " - service_db_netwk: Checks connectivity between the Service in AZ1 and MySQL in AZ2 and vice-versa"

echo " - tail_service_log: Tail 100 lines of the service.lo...

Continue reading...

IF statements arguments / flags / options / operation

July 3, 2023

Test operators

-e file exists

-f file exists and is not a directory

-s file is not empty

-d directory exists

-x file is executable (for the user running the test)

-r file is readable (for the user running the test)

-w file has write permission (for user running the test)

-h / -L file is a symbolic link

! "not"


Compound Comparison

-a logical 'and' similar to &&

-o logical 'or' similar to ||


Integer Comparison

-eq is equal to

-ne is not equal to

-gt or > is greater t...

Continue reading...

Learning awk

July 3, 2023

Print column 1 & 2

ps | awk '{print $1,$2}'

To separate the columns titles you can use "\t" between the numbers:

ps | awk '{print $1"\t"$2}'

By default the field separator for awk is a space, if it's not the case tell awk which one it is by using F for field separator. In the example of /etc/passwd file the separator is semi-colon

awk -F ":" '{print $1}' /etc/passwd

You can also grep:

awk -F ":" '{print $1}' /etc/passwd | grep myservice


To search for every last field in the line, but r...

Continue reading...

Learning sed

July 3, 2023

sed > Stream editor allow filter and transform texts, find pattern and replace with whatever is that you want to replace with, it's like search and replace.

You can use other separators instead of slashes (/). Example pipe | or hash #

1 - sed substitution -- s for substitution. replaces only the first occurrence in each line of the file and save to a new file

sed 's/word/newword/' < oldfile > newfile


2 - replaces every occurrence of 'word'. g for global

sed 's/word/newword/g' < oldfi...

Continue reading...

A Quick Explanation About the Output from the Free Command in Linux

August 22, 2020
First I would like to quickly explain about Buffer and Cache, so things can make sense up ahead :)
Difference between Buffer and Cache:

Buffer is a temporary location for storing data for a particular application and this data is not used by any other application.

Cache is a memory location to store frequently used data for faster access.

Both are temporary store for your data processing. However memory specified as buffer/cache can be made available when an application needs it, so we count it ...

Continue reading...
blog comments powered by Disqus
blog comments powered by Disqus