Skip to content

Instantly share code, notes, and snippets.

@fbakhda
fbakhda / windows-cmd-color.bat
Created November 21, 2024 09:22
Sample Windows CMD Colours
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
@fbakhda
fbakhda / basic-ubuntu-setup.sh
Created November 21, 2024 09:19
Setting up Basic Ubuntu System (within Intel)
#!/bin/bash
SUDO=''
if (( $EUID != 0 )); then
echo 'I will try without root access to perform'
echo 'but i cant guarantee it works'
echo 'Else use root account'
echo 'Continue [Enter] , Cancel [Ctrl+C]'
read
SUDO='sudo'
@fbakhda
fbakhda / mysql-db-restore.sh
Created November 21, 2024 08:31
MySQL DB Restore script with Param 1: Database Name Param 2: Database SQL Filepath
#!/bin/bash
MYSQL_USER="root"
MYSQL_PASSWORD="" # Change this to your db password
function restore() {
(
echo "SET AUTOCOMMIT=0;"
echo "SET UNIQUE_CHECKS=0;"
echo "SET FOREIGN_KEY_CHECKS=0;"
@fbakhda
fbakhda / delete-old-kernels.sh
Created November 21, 2024 08:23
Deleting old Kernels from Ubuntu system
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r) | xargs sudo apt-get -y purge
@fbakhda
fbakhda / gh-commands-samples.txt
Created November 21, 2024 06:48
Github gh Command Samples
# Authentication
gh auth login
gh auth logout
# Repositories
gh repo clone owner/repo
gh repo create my-new-repo --public
gh repo fork owner/repo
gh repo view owner/repo --web
@fbakhda
fbakhda / cpu_utilization.sh
Created November 21, 2024 06:26
Snapshot 5 datapoints of CPU Utilization percentage and print the 5th data point for CPU Utilization percentage
#!/bin/sh
# by Paul Colby (http://colby.id.au), no rights reserved ;)
# modified by Bakhda, Firesh
PREV_TOTAL=0
PREV_IDLE=0
for INDEX in 1 2 3 4 5; do
# Get the total CPU statistics, discarding the 'cpu ' prefix.
CPU=$(sed -n 's/^cpu\s//p' /proc/stat)
@fbakhda
fbakhda / aliases.sh
Last active November 21, 2024 09:53
Simplify doing ssh via alias "sshlist" to list all possible SSH Clients from your .ssh/config
alias ll='ls -la'
alias sshlist='awk '\''BEGIN { printf("%-30s %-30s %-10s %-s\n", "Host", "HostName", "Port", "User") } /^Host / {host=$2} /Hostname / {hostname=$2} /Port / {prt=$2} /User / {usr=$2; printf "%-30s %-30s %-10s %s\n", host, hostname, (prt ? prt : "NA"), (usr ? usr : "NA"
)}'\'' ~/.ssh/config'