Sunday, November 9, 2025

How to Install Google Cloud SDK & Login to GCP (All Methods) ?

✅ How to Install Google Cloud SDK & Login to GCP (All Methods)


🌟 Step 1 — Install Google Cloud SDK

Windows

Download installer:

https://cloud.google.com/sdk/docs/install

macOS

curl https://sdk.cloud.google.com | bash
exec -l $SHELL

Linux

curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-sdk-367.0.0-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
exec -l $SHELL

⚙️ Step 2 — Initialize Cloud SDK

gcloud init

🔐 GCP Login Methods

✅ Method 1 — Login Using Browser

gcloud auth login

✅ Method 2 — Login Without Browser (SSH Server)

gcloud auth login --no-launch-browser

You will get a URL → open it → paste code.

✅ Method 3 — Set Default Project

gcloud config set project PROJECT_ID

✅ Method 4 — Verify Login

gcloud config list

🎯 Method 5 — Application Default Credentials (ADC)

Used by SDKs / Terraform / APIs

gcloud auth application-default login

🔐 Method 6 — Service Account Login (Automation / CI-CD)

gcloud auth activate-service-account --key-file=key.json
gcloud config set project PROJECT_ID

🛑 Method 7 — Workload Identity Federation (Keyless Login)

gcloud auth login --cred-file=workload-identity-credential.json

🧠 Method 8 — Cloud Shell Login (No Install)

Go to:

https://console.cloud.google.com

Click Activate Cloud Shell ✅

🧩 Method 9 — Terraform + GCP Authentication

gcloud auth application-default login

🔐 Method 10 — Docker / Artifact Registry Login

gcloud auth configure-docker

💻 Method 11 — Login to GCP Git Repos

gcloud source repos clone REPO_NAME --project=PROJECT_ID

📌 Useful Commands

ActionCommand
List projectsgcloud projects list
Show active authgcloud auth list
Remove logingcloud auth revoke
Update SDKgcloud components update

✨ Mastering Bash Special Characters — The Real Power of Linux Terminal 🔥

🔥 Master Bash Special Characters — Power of Linux Terminal

If you work in Linux, DevOps, Cloud, Cyber Security, or Automation, Bash special characters are your superpower.

These symbols control execution, variables, redirection, scripting logic, and automation. Here is the complete cheat-sheet 👇


✅ Basic Bash Symbols

SymbolMeaningExample
$Variable / Command outputecho $HOME
#Comment# comment
*Wildcard (match all)*.txt
?Match one characterfile?.log
\Escape characterecho \"hello\"
~Home directorycd ~

✅ Command Execution Operators

SymbolMeaningExample
;Run sequentiallycmd1; cmd2
&&Run if previous successbuild && deploy
||Run if previous failscd logs || mkdir logs
&Run in backgroundsleep 5 &

✅ Pipes & Redirection

SymbolMeaningExample
|Pipe outputls | grep txt
>Output to file (overwrite)echo hi > file.txt
>>Append to fileecho hi >> file.txt
<Redirect inputsort < data.txt

✅ Advanced Redirection

SymbolMeaningExample
<<Heredoccat << EOF
<<<Here-stringcat <<< "Hello"

✅ Test & Grouping

SymbolMeaningExample
[ ]Test[ -f file.txt ]
[[ ]]Advanced test[[ $a == $b ]]
( )Subshell(cd /tmp && ls)
{ }Command block{ echo A; echo B; }

✅ Brace Expansion

PatternMeaningExample
{1..5}Number rangeecho {1..5}
{a,b}Listmv f.{txt,backup}

✅ Special Shell Variables

VariableMeaning
$?Last command status
$$Process ID
$!Last background PID
$@All arguments
$#Argument count

🎯 Example Script


#!/bin/bash
if [[ -f "$1" ]]; then
  grep "error" "$1" >> logs.txt && echo "Logged ✅"
else
  echo "File not found ❌" && exit 1
fi

#linux #bash #devops #shellscripting #cloud #sysadmin #automation

Sunday, October 1, 2023

Resize EBS volume without rebooting in AWS ?

 This article guides you to resize the EBS volume without rebooting


1. Modify volume in AWS EC2 UI

After login to AWS console, navigate to EC2 -> Elastic Block Store -> Volumes. Click on the volume that you wist to resize, then select Actions -> Modify Volume. It will open a popup.


i) Enter the new size in the size field. Lets says we are resizing from 8 GB to 150 GB.

ii) Click Modify button

iii) Click Yes button in the confirm popup.

Now the volume has been resized, but it won't reflect in the system. We need to do some more steps to make it work.


2. Resize the partition


Lets ssh into the machine.


i) List block devices attached to the machine.

lsblk

NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

loop0     7:0    0   91M  1 loop /snap/core/6350

loop1     7:1    0   18M  1 loop /snap/amazon-ssm-agent/930

loop2     7:2    0 89.4M  1 loop /snap/core/6818

loop3     7:3    0 17.9M  1 loop /snap/amazon-ssm-agent/1068

xvda    202:0    0  150G  0 disk

└─xvda1 202:1    0    8G  0 part /

You can see that xvda1 is still 8 GB. Lets increase the partition to disk size.


ii) Install cloud-guest-utils


apt install cloud-guest-utils


iii) Grow the partition


growpart /dev/xvda 1


iv) Let's check the partition size (you can see /dev/xvda1 is now 150 GB):

lsblk

NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

loop0     7:0    0   91M  1 loop /snap/core/6350

loop1     7:1    0   18M  1 loop /snap/amazon-ssm-agent/930

loop2     7:2    0 89.4M  1 loop /snap/core/6818

loop3     7:3    0 17.9M  1 loop /snap/amazon-ssm-agent/1068

xvda    202:0    0  150G  0 disk

└─xvda1 202:1    0  150G  0 part /


3. Resize the file system

i) Check the file system size. (Still it shows only 8 GB)

df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/xvda1      7.8G  4.9G  2.6G  62% /

ii) Resize the filesystem

resize2fs /dev/xvda1

iii) Check after resizing

df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/xvda1      146G  4.9G  141G   3% /

So we have increased the EBS volume without rebooting and zero downtime.


Monday, February 7, 2022

How to Install ranger in Ubuntu 18.04?

How to Install ranger in Ubuntu 18.04?



ranger - visual file manager


Ranger is a free and open-source command-line file manager for Linux. It comes with a minimalistic text-based user interface and VI key bindings support. The main design goal of this file manager is switch directories and browse files in a quick and easy way. Some of the main features are preview the selected file or directory and automatically determining file types and running them with correct programs. It supports VIM like hotkeys, UTF-8, multi-column display, mouse support, builds in Tabs, and bookmarks support.



Features of Ranger

  • Multi-column display

  • Common file operations (create/chmod/copy/delete)

  • Preview of the selected file/directory

  • VIM-like console and hotkeys

  • A quick way to switch directories and browse the file system

  • Tabs, Bookmarks, Mouse support

  • Video thumbnails previews



Install Ranger File Manager on Ubuntu


sudo apt-get update


sudo apt install ranger -y


Type command 

ranger




To change directories, you can use the arrow keys: Press Right to go into the currently selected directory, or Left to go into the parent directory. Similarly to select items in the middle panel, use the Up and Down arrow keys. There are number of commands you can use to perform different operations on the files but here are some of the most common commands.


For navigation


  • <Ctrl>-f = Page down

  • <Ctrl>-b = Page up

  • gg = Go to the top of the list

  • G = Go to the bottom of the list

  • H = Go back through navigation history

  • h = Move to parent directory

  • J = Page down 1/2 page

  • J = Move down

  • K = Page up 1/2 page

  • k = Move up

  • L = Go forward through navigation history

  • Q = Quit

Working with files


  • i … Display the file

  • E|I … Edit the file

  • r … Open file with the chosen program

  • cw … Rename file

  • / … Search for files (n|p jump to next/previous match)

  • dd .. Mark file for cut

  • ud … Uncut

  • p … Paste file

  • yy .. Copy/yank file

  • zh … Show hidden files

  • <space> = Select current file

  • :delete = Delete selected file

  • :mkdir … Create a directory

  •  :touch … Create a file

  •  :rename … Rename file



For More options use

man  ranger

 

Thursday, December 23, 2021

RabbitMQ How to Purge All Queues ?

 There are some situations where you may need to clear or purge all messages from a queue. 


Using Command Line:


You can purge or clear a queue with the following command:


syntax:


$ rabbitmqctl purge_queue queue_name


Purge Queue from the Web UI


Click on the Queues tab.

Click on the name of the queue that you want.

Expand the “Purge” section.

Click the “Purge Messages” button.

Click “OK”.



Purging all queues 


$ rabbitmqadmin -f tsv -q list queues name > list1.txt


$ for i in `cat list1.txt`; do rabbitmqctl purge_queue "$i" ; done