❌

Normal view

There are new articles available, click to refresh the page.
Yesterday β€” 11 March 2025Main stream

How do I use the ResourceTag, condition keys to create an IAM policy for tag-based restriction

By: Kannan
28 February 2025 at 08:12

The following IAM policies use condition keys to create tag-based restriction.

  • Before you use tags to control access to your AWS resources, you must understand how AWS grants access. AWS is composed of collections of resources. An Amazon EC2 instance is a resource. An Amazon S3 bucket is a resource. You can use the AWS API, the AWS CLI, or the AWS Management Console to perform an operation, such as creating a bucket in Amazon S3. When you do, you send a request for that operation. Your request specifies an action, a resource, a principal entity (user or role), a principal account, and any necessary request information.

  • You can then create an IAM policy that allows or denies access to a resource based on that resource's tag. In that policy, you can use tag condition keys to control access to any of the following:

  • Resource – Control access to AWS service resources based on the tags on those resources. To do this, use the_ aws:ResourceTag/key-name_ condition key to determine whether to allow access to the resource based on the tags that are attached to the resource.

ResourceTag condition key

Use the _aws:ResourceTag/tag-key _condition key to compare the tag key-value pair that's specified in the IAM policy with the key-value pair that's attached to the AWS resource. For more information, see Controlling access to AWS resources.

You can use this condition key with the global aws:ResourceTag version and AWS services, such as ec2:ResourceTag. For more information, see Actions, resources, and condition keys for AWS services.

  • The following IAM policy allows users to start, stop, and terminate instances that are in the test application tag
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:StartInstances",
                "ec2:StopInstances",
                "ec2:TerminateInstances"
            ],
            "Resource": "arn:aws:ec2:*:3817********:instance/*",
            "Condition": {
                "StringEquals": {
                    "ec2:ResourceTag/application": "test"
                }
            }
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:DescribeTags"
                "ec2:Describedescribe-instance-status"
            ],
            "Resource": "*"
        }
    ]
}

Create the policy and attach the policy to user or role.

  • Created 2 instance one is with application tag and other is non tagged.

Image description
You can see the tagged instance are able to perform Start and Stop action using the IAM resources tag condition.
non-tagged instance we are not able to perform the same.

  • check the status of the instance

Image description

  • perform the Termination action

Image description

reference commands

aws ec2 start-instances --instance-ids "instance-id"
aws ec2 stop-instances --instance-ids "instance-id"
aws ec2 describe-instance-status  --instance-ids "instance-id"
aws ec2 terminate-instances --instance-ids "instance-id"

String condition operators

String condition operators let you construct Condition elements that restrict access based on comparing a key to a string value.

  • StringEquals - Exact matching, case sensitive

  • StringNotEquals - Negated matching

  • StringEqualsIgnoreCase - Exact matching, ignoring case

  • StringNotEqualsIgnoreCase - Negated matching, ignoring case

  • StringLike - Case-sensitive matching. The values can include multi-character match wildcards (*) and single-character match wildcards (?) anywhere in the string. You must specify wildcards to achieve partial string matches.
    Note
    If a key contains multiple values, StringLike can be qualified with set operatorsβ€”ForAllValues:StringLike and ForAnyValue:StringLike.

  • StringNotLike - Negated case-sensitive matching. The values can include multi-character match wildcards (*) or single-character match wildcards (?) anywhere in the string.

Script to list the S3 Bucket storage size

By: Kannan
28 February 2025 at 05:41

If we need to fetch the S3 bucket storage size we need to trace via individual bucket under metrics we get the storage size.
on one go use the below script to get the bucket name with storage size.

s3list=`aws s3 ls | awk  '{print $3}'`
for s3dir in $s3list
do
    echo $s3dir
    aws s3 ls "s3://$s3dir"  --recursive --human-readable --summarize | grep "Total Size" 
done
  1. create the .sh file
  2. copy the code on the file
  3. Excecute the script to get the s3 bucket details
Before yesterdayMain stream

Linux Mint Installation Drive – Dual Boot on 10+ Machines!

24 February 2025 at 16:18

Linux Mint Installation Drive – Dual Boot on 10+Β Machines!

Hey everyone! Today, we had an exciting Linux installation session at our college. We expected many to do a full Linux installation, but instead, we set up dual boot on 10+ machines! πŸ’»βœ¨

πŸ’‘ Topics Covered:
πŸ›  Syed Jafer – FOSS, GLUGs, and open-source communities
🌍 Salman – Why FOSS matters & Linux Commands
πŸš€ Dhanasekar – Linux and DevOps
πŸ”§ Guhan – GNU and free software

Challenges We Faced


πŸ” BitLocker Encryption – Had to disable BitLocker on some laptops
πŸ”§ BIOS/UEFI Problems – Secure Boot, boot order changes needed
🐧 GRUB Issues – Windows not showing up, required boot-repair

πŸŽ₯ Watch the installation video and try it yourself! https://www.youtube.com/watch?v=m7sSqlam2Sk


β–Ά Linux Mint Installation Guide https://tkdhanasekar.wordpress.com/2025/02/15/installation-of-linux-mint-22-1-cinnamon-edition/

This is just the beginning!

Why Skeleton Screens Improve Perceived Loading in Apps like LinkedIn

18 February 2025 at 11:55

Introduction

What do Reddit, Discord, Medium, and LinkedIn have in common? They use what’s called a skeleton loading screen for their applications. A skeleton screen is essentially a wireframe of the application. The wireframe is a placeholder until the application finally loads.

skeleton loader image

Rise of skeleton loader.

The term β€œskeleton screen” was introduced in 2013 by product designer Luke Wroblewski in a blog post about reducing perceived wait time. In this lukew.com/ff/entry.asp?1797 post, he explains how gradually revealing page content turns user attention to the content being loaded, and off of the loading time itself.

Skeleton Loader

Skeleton loading screens will improve your application’s user experience andΒ make it feel more performant. The skeleton loading screen essentiallyΒ impersonates the original layout.

This lets the user know what’s happening on the screen. The user interprets this as the application is booting up and the content is loading.

In simplest terms, Skeleton Loader is a static / animated placeholder for the information that is still loading. It mimic the structure and look of the entire view.

Why not just a loading spinner ?

Instead of showing a loading spinner, we could show a skeleton screen that makes the user see that there is progress happening when launching and navigating the application.

They let the user know that some content is loading and, more importantly, provide an indication of what is loading, whether it’s an image, text, card, and so on.

This gives the user the impression that the website is faster because they already know what type of content is loading before it appears. This is referred to asΒ perceived performance.

Skeleton screensΒ don’t really make pages load faster. Instead, they are designed to make it feel like pages are loading faster.

When to use ?

  1. Use on high-traffic pages where resources takes a bit long to load like account dashboard.
  2. When the component containsΒ good amount of information, such as list or card.
  3. Could be replaced byΒ spinΒ in any situation, but can provide a better user experience.
  4. Use when there’s more than 1 element loading at the same time that requires an indicator.
  5. Use when you need to load multiple images at once, a skeleton screen might make a good placeholder. For these pages, consider implementing lazy loading first, which is a similar technique for decreasing perceived load time.

When not to use ?

  1. Not to use for a long-running process, e.g. importing data, manipulation of data etc. (Operations on data intensive applications)
  2. Not to use for fast processes that that takeΒ less than half a second.
  3. Users still associate video buffering with spinners. Avoid skeleton screens any time a video is loading on your page.
  4. For longer processes (uploads, download, file manipulation ) can use progress bar instead of skeleton loading.
  5. As a replacement for poor performance: If you can further optimize your website to actually load content more quickly, always pursue that first.

Let’s design a simple skeleton loading

index.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Skeleton Loading</title>

	<style>
		.card {
			width:  250px;
			height:  150px;
			background-color: #fff;
			padding: 10px;
			border-radius: 5px;
			border:  1px solid gray;
		}

		.card-skeleton {
			background-image: linear-gradient(90deg, #ccc, 0px, rgb(229 229 229 / 90%) 40px, #ccc 80px);
			background-size: 300%;
			background-position: 100% 0;
			border-radius: inherit;
			animation: shimmer 1.5s infinite;
		}

		.title {
			height: 15px;
			margin-bottom: 15px;
		}

		.description {
			height: 100px;
		}

		@keyframes shimmer{
			to {
				background-position: -100% 0;
			}
		}
	</style>

</head>
<body>
	<div class="card">
		<div class="card-skeleton title"></div>
		<div class="card-skeleton description"></div>
	</div>

</body>
</html>

Skeleton Loading .card { width: 250px; height: 150px; background-color: #fff; padding: 10px; border-radius: 5px; border: 1px solid gray; } .card-skeleton { background-image: linear-gradient(90deg, #ccc, 0px, rgb(229 229 229 / 90%) 40px, #ccc 80px); background-size: 300%; background-position: 100% 0; border-radius: inherit; animation: shimmer 1.5s infinite; } .title { height: 15px; margin-bottom: 15px; } .description { height: 100px; } @keyframes shimmer{ to { background-position: -100% 0; } }

Suggestions to keep in mind

  1. The goal is to design for a perception of decreased waiting time.
  2. Contents should replace skeleton exactly by position and size immediately after they are loaded.
  3. Using motion that moves from left to right (wave) gives a better perception of decreased waiting time than fading in and out (pulse).
  4. Using motion that is slow and steady gives a perception of decreased waiting time.

Can UV Transform Python Scripts into Standalone Executables ?

17 February 2025 at 17:48

Managing dependencies for small Python scripts has always been a bit of a hassle.

Traditionally, we either install packages globally (not recommended) or create a virtual environment, activate it, and install dependencies manually.

But what if we could run Python scripts like standalone binaries ?

Introducing PEP 723 – Inline Script Metadata

PEP 723 (https://peps.python.org/pep-0723/) introduces a new way to specify dependencies directly within a script, making it easier to execute standalone scripts without dealing with external dependency files.

This is particularly useful for quick automation scripts or one-off tasks.

Consider a script that interacts with an API requiring a specific package,

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests",
# ]
# ///

import requests
response = requests.get("https://api.example.com/data")
print(response.json())

Here, instead of manually creating a requirements.txt or setting up a virtual environment, the dependencies are defined inline. When using uv, it automatically installs the required packages and runs the script just like a binary.

Running the Script as a Third-Party Tool

With uv, executing the script feels like running a compiled binary,

$ uv run fetch-data.py
Reading inline script metadata from: fetch-data.py
Installed dependencies in milliseconds

ehind the scenes, uv creates an isolated environment, ensuring a clean dependency setup without affecting the global Python environment. This allows Python scripts to function as independent tools without any manual dependency management.

Why This Matters

This approach makes Python an even more attractive choice for quick automation tasks, replacing the need for complex setups. It allows scripts to be shared and executed effortlessly, much like compiled executables in other programming environments.

By leveraging uv, we can streamline our workflow and use Python scripts as powerful, self-contained tools without the usual dependency headaches.

Top Command in Linux: Tips for Effective Usage

17 February 2025 at 17:17

The top command in Linux is a powerful utility that provides realtime information about system performance, including CPU usage, memory usage, running processes, and more.

It is an essential tool for system administrators to monitor system health and manage resources effectively.

1. Basic Usage

Simply running top without any arguments displays an interactive screen showing system statistics and a list of running processes:

$ top

2. Understanding the top Output

The top interface is divided into multiple sections

Header Section

This section provides an overview of the system status, including uptime, load averages, and system resource usage.

  • Uptime and Load Average – Displays how long the system has been running and the average system load over the last 1, 5, and 15 minutes.
  • Task Summary – Shows the number of processes in various states:
    • Running – Processes actively executing on the CPU.
    • Sleeping – Processes waiting for an event or resource.
    • Stopped – Processes that have been paused.
    • Zombie – Processes that have completed execution but still have an entry in the process table. These occur when the parent process has not yet read the exit status of the child process. Zombie processes do not consume system resources but can clutter the process table if not handled properly.
  • CPU Usage – Breaks down CPU utilization into different categories:
    • us (User Space) – CPU time spent on user processes.
    • sy (System Space) – CPU time spent on kernel operations.
    • id (Idle) – Time when the CPU is not being used.
    • wa (I/O Wait) – Time spent waiting for I/O operations to complete.
    • st (Steal Time) – CPU cycles stolen by a hypervisor in a virtualized environment.
  • Memory Usage – Shows the total, used, free, and available RAM.
  • Swap Usage – Displays total, used, and free swap memory, which is used when RAM is full.

Process Table

The table below the header lists active processes with details such as:

  • PID – Process ID, a unique identifier for each process.
  • USER – The owner of the process.
  • PR – Priority of the process, affecting its scheduling.
  • NI – Nice value, which determines how favorable the process scheduling is.
  • VIRT – The total virtual memory used by the process.
  • RES – The actual RAM used by the process.
  • SHR – The shared memory portion.
  • S – Process state:
    • R – Running
    • S – Sleeping
    • Z – Zombie
    • T – Stopped
  • %CPU – The percentage of CPU time used.
  • %MEM – The percentage of RAM used.
  • TIME+ – The total CPU time consumed by the process.
  • COMMAND – The command that started the process.

3. Interactive Commands

While running top, various keyboard shortcuts allow dynamic interaction:

  • q – Quit top.
  • h – Display help.
  • k – Kill a process by entering its PID.
  • r – Renice a process (change priority).
  • z – Toggle color/monochrome mode.
  • M – Sort by memory usage.
  • P – Sort by CPU usage.
  • T – Sort by process runtime.
  • 1 – Toggle CPU usage breakdown for multi-core systems.
  • u – Filter processes by a specific user.
  • s – Change update interval.

4. Command-Line Options

The top command supports various options for customization:

  • -b (Batch mode): Used for scripting to display output in a non-interactive mode.$ top -b -n 1-n specifies the number of iterations before exit.
  • -o FIELD (Sort by a specific field):$ top -o %CPUSorts by CPU usage.
  • -d SECONDS (Refresh interval):$ top -d 3Updates the display every 3 seconds.
  • -u USERNAME (Show processes for a specific user):$ top -u john
  • -p PID (Monitor a specific process):$ top -p 1234

5. Customizing top Display

Persistent Customization

To save custom settings, press W while running top. This saves the configuration to ~/.toprc.

Changing Column Layout

  • Press f to toggle the fields displayed.
  • Press o to change sorting order.
  • Press X to highlight sorted columns.

6. Alternative to top: htop, btop

For a more user-friendly experience, htop is an alternative:

$ sudo apt install htop  # Debian-based
$ sudo yum install htop  # RHEL-based
$ htop

It provides a visually rich interface with color coding and easy navigation.

Installation of Linux Mint 22.1 Cinnamon Edition

15 February 2025 at 18:13

Linux Mint 22.1 Cinnamon Edition iso
download link
https://mirrors.cicku.me/linuxmint/iso/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso
Installation of Linux Mint 22.1 Cinnamon Edition

make the iso file to a usb installer
then in bios settings make usb as first boot order
insert the pendirve automatically it detects the Linux Mint OS
and this screen will appear

select β€œstart linux mint” then hit enter
we got the linux mint home screen

now double click the β€œinstall linux mint” icon
in the welcome screen choose β€œEnglish” and continue

select keyboard layout to English (US) and continue

Next we got the multimedia codecs wizard leave as it is and
hit continue

next we got the installation type wizard
select β€œsomething else ” and continue

in the next wizard click β€œNew Partition Table”

we got the β€œcreate new empty partition table on this device ?” wizard
click continue

then select the free space and click β€œ+”

we got the create partition wizard
give the size for root partition (Maximum size 85%)
use as β€œExt4 journaling file system”
Mount point : /
then click β€œOK”

then again select the free space and click β€œ+” sign

give the size for swap (twice the size of RAM usually)
select Use as: swap area
then click β€œOK”

again select the free space and click β€œ+” sign
give the size for EFI partition 1GB
select Use as: EFI system partition
and click β€œOK”

again select the free space and click β€œ+” sign
give the size 100 MB for
use as : β€œReserved BIOS boot area” then click OK

then click Install continue

the give the time zone as kolkata

then click continue and in the next wizard
give username , computer name , password
either choose login automatically or require password

then click β€œcontinue”
the installation process tookΒ  a while
when the installation complete
it will ask to remove the installation medium and press ENTER

the system reboots and Linux Mint cinnamon home page will be displayed

πŸ™‚

Effortless Git Repo Switching with a Simple Bash Function!

By: krishna
12 February 2025 at 10:36

Why I Created This Function

At first, I used an alias

alias gitdir="cd ~/Git/" (This means gitdir switches to the ~/Git/ directory, but I wanted it to switch directly to a repository.)
So, I wrote a Bash function.

Write Code to .bashrc File

The .bashrc file runs when a new terminal window is opened.
So, we need to write the function inside this file.

Code

gitrepo() {
    # Exact Match
    repoList=$(ls $HOME/Git)
    if [ -n "$(echo "$repoList" | grep -w $1)" ]; then
	cd $HOME/Git/$1
    else
	# Relevant Match
	getRepoName=$(echo "$repoList" | grep -i -m 1 $1)
	
	if [ -n "$getRepoName" ]; then
	    cd "$HOME/Git/$getRepoName"
	else
	    echo "Repository Not Founded"
	    cd $HOME/Git
	fi
	
    fi   
}

Code Explanation

The $repoList variable stores the list of directories inside the Git folder.

Function Logic Has Two Parts:

  • Exact Match
  • Relevant Match

Exact Match

if [ -n "$(echo "$repoList" | grep -w $1)" ]; then
	cd $HOME/Git/$1

If condition: The $repoList variable parses input for grep.

  • grep -w matches only whole words.
  • $1 is the function’s argument in bash.
  • -n checks if a variable is not empty. Example syntax:
    [ a != "" ] is equivalent to [ -n a ]

Relevant Match

getRepoName=$(echo "$repoList" | grep -i -m 1 $1)
	if [ -n "$getRepoName" ]; then
	    cd "$HOME/Git/$getRepoName"

Relevant search: If no Exact Match is found, this logic is executed next.

getRepoName="$repoList" | grep -i -m 1 $1
  • -i ignores case sensitivity.
  • -m 1 returns only the first match.

Example of -m with grep:
ls | grep i3
It returns i3WM and i3status, but -m 1 ensures only i3WM is selected.

No Match

If no match is found, it simply changes the directory to the Git folder.

	else
	    echo "Repository Not Founded"
	    cd $HOME/Git

What I Learned

  • Basics of Bash functions
  • How to use .bashrc and reload changes.

20 Essential Git Command-Line Tricks Every Developer Should Know

5 February 2025 at 16:14

Git is a powerful version control system that every developer should master. Whether you’re a beginner or an experienced developer, knowing a few handy Git command-line tricks can save you time and improve your workflow. Here are 20 essential Git tips and tricks to boost your efficiency.

1. Undo the Last Commit (Without Losing Changes)

git reset --soft HEAD~1

If you made a commit but want to undo it while keeping your changes, this command resets the last commit but retains the modified files in your staging area.

This is useful when you realize you need to make more changes before committing.

If you also want to remove the changes from the staging area but keep them in your working directory, use,

git reset HEAD~1

2. Discard Unstaged Changes

git checkout -- <file>

Use this to discard local changes in a file before staging. Be careful, as this cannot be undone! If you want to discard all unstaged changes in your working directory, use,

git reset --hard HEAD

3. Delete a Local Branch

git branch -d branch-name

Removes a local branch safely if it’s already merged. If it’s not merged and you still want to delete it, use -D

git branch -D branch-name

4. Delete a Remote Branch

git push origin --delete branch-name

Deletes a branch from the remote repository, useful for cleaning up old feature branches. If you mistakenly deleted the branch and want to restore it, you can use

git checkout -b branch-name origin/branch-name

if it still exists remotely.

5. Rename a Local Branch

git branch -m old-name new-name

Useful when you want to rename a branch locally without affecting the remote repository. To update the remote reference after renaming, push the renamed branch and delete the old one,

git push origin -u new-name
git push origin --delete old-name

6. See the Commit History in a Compact Format

git log --oneline --graph --decorate --all

A clean and structured way to view Git history, showing branches and commits in a visual format. If you want to see a detailed history with diffs, use

git log -p

7. Stash Your Changes Temporarily

git stash

If you need to switch branches but don’t want to commit yet, stash your changes and retrieve them later with

git stash pop

To see all stashed changes

git stash list

8. Find the Author of a Line in a File

git blame file-name

Shows who made changes to each line in a file. Helpful for debugging or reviewing historical changes. If you want to ignore whitespace changes

git blame -w file-name

9. View a File from a Previous Commit

git show commit-hash:path/to/file

Useful for checking an older version of a file without switching branches. If you want to restore the file from an old commit

git checkout commit-hash -- path/to/file

10. Reset a File to the Last Committed Version

git checkout HEAD -- file-name

Restores the file to the last committed state, removing any local changes. If you want to reset all files

git reset --hard HEAD

11. Clone a Specific Branch

git clone -b branch-name --single-branch repository-url

Instead of cloning the entire repository, this fetches only the specified branch, saving time and space. If you want all branches but don’t want to check them out initially:

git clone --mirror repository-url

12. Change the Last Commit Message

git commit --amend -m "New message"

Use this to correct a typo in your last commit message before pushing. Be cautiousβ€”if you’ve already pushed, use

git push --force-with-lease

13. See the List of Tracked Files

git ls-files

Displays all files being tracked by Git, which is useful for auditing your repository. To see ignored files

git ls-files --others --ignored --exclude-standard

14. Check the Difference Between Two Branches

git diff branch-1..branch-2

Compares changes between two branches, helping you understand what has been modified. To see only file names that changed

git diff --name-only branch-1..branch-2

15. Add a Remote Repository

git remote add origin repository-url

Links a remote repository to your local project, enabling push and pull operations. To verify remote repositories

git remote -v

16. Remove a Remote Repository

git remote remove origin

Unlinks your repository from a remote source, useful when switching remotes.

17. View the Last Commit Details

git show HEAD

Shows detailed information about the most recent commit, including the changes made. To see only the commit message

git log -1 --pretty=%B

18. Check What’s Staged for Commit

git diff --staged

Displays changes that are staged for commit, helping you review before finalizing a commit.

19. Fetch and Rebase from a Remote Branch

git pull --rebase origin main

Combines fetching and rebasing in one step, keeping your branch up-to-date cleanly. If conflicts arise, resolve them manually and continue with

git rebase --continue

20. View All Git Aliases

git config --global --list | grep alias

If you’ve set up aliases, this command helps you see them all. Aliases can make your Git workflow faster by shortening common commands. For example

git config --global alias.co checkout

allows you to use git co instead of git checkout.

Try these tricks in your daily development to level up your Git skills!

Minimal Typing Practice Application in Python

By: krishna
30 January 2025 at 09:40

Introduction

This is a Python-based single-file application designed for typing practice. It provides a simple interface to improve typing accuracy and speed. Over time, this minimal program has gradually increased my typing skill.

What I Learned from This Project

  • 2D Array Validation
    I first simply used a 1D array to store user input, but I noticed some issues. After implementing a 2D array, I understood why the 2D array was more appropriate for handling user inputs.
  • Tkinter
    I wanted to visually see and update correct, wrong, and incomplete typing inputs, but I didn’t know how to implement it in the terminal. So, I used a simple Tkinter gui window

Run This Program

It depends on the following applications:

  • Python 3
  • python3-tk

Installation Command on Debian-Based Systems

sudo apt install python3 python3-tk

Clone repository and run program

git clone https://github.com/github-CS-krishna/TerminalTyping
cd TerminalTyping
python3 terminalType.py

Links

For more details, refer to the README documentation on GitHub.

This will help you understand how to use it.

source code(github)

Learning Notes #61 – Undo a git pull

18 January 2025 at 16:04

Today, i came across a blog on undo a git pull. In this blog, i have reiterated the blog in other words.

Mistakes happen. You run a git pull and suddenly find your repository in a mess. Maybe conflicts arose, or perhaps the changes merged from the remote branch aren’t what you expected.

Fortunately, Git’s reflog comes to the rescue, allowing you to undo a git pull and restore your repository to its previous state. Here’s how you can do it.

Understanding Reflog


Reflog is a powerful feature in Git that logs every update made to the tips of your branches and references. Even actions like resets or rebases leave traces in the reflog. This makes it an invaluable tool for troubleshooting and recovering from mistakes.

Whenever you perform a git pull, Git updates the branch pointer, and the reflog records this action. By examining the reflog, you can identify the exact state of your branch before the pull and revert to it if needed.

Step By Step Guide to UNDO a git pull

1. Check Your Current State Ensure you’re aware of the current state of your branch. If you have uncommitted changes, stash or commit them to avoid losing any work.


git stash
# or
git add . && git commit -m "Save changes before undoing pull"

2. Inspect the Reflog View the recent history of your branch using the reflog,


git reflog

This command will display a list of recent actions, showing commit hashes and descriptions. For example,


0a1b2c3 (HEAD -> main) HEAD@{0}: pull origin main: Fast-forward
4d5e6f7 HEAD@{1}: commit: Add new feature
8g9h0i1 HEAD@{2}: checkout: moving from feature-branch to main

3. Identify the Pre-Pull Commit Locate the commit hash of your branch’s state before the pull. In the above example, it’s 4d5e6f7, which corresponds to the commit made before the git pull.

4. Reset to the Previous Commit Use the git reset command to move your branch back to its earlier state,


git reset <commit-hash>

By default, it’s mixed so changes wont be removed but will be in staging.

The next time a pull operation goes awry, don’t panicβ€”let the reflog guide you back to safety!

Problem Statements : Git & Github Session – St. Joseph’s GDG Meeting

17 December 2024 at 15:13

List of problem statements enough to get your hands dirty on git. These are the list of commands that you mostly use in your development.

Problem 1

  1. Initialize a Repository.
  2. Setup user details globally.
  3. Setup project specific user details.
  4. Check Configuration – List the configurations.

Problem 2

  1. Add Specific files. Create two files app.js and style.css. User git add to stage only style.css . This allows selective addition of files to the staging area before committing.
  2. Stage all files except one.

Problem 3

  1. Commit with a message
  2. Amend a commit
  3. Commit without staging

Problem 4

  1. Create a Branch
  2. Create a new branch named feature/api to work on a feature independently without affecting the main branch.
  3. Delete a branch.
  4. Force delete a branch.
  5. Rename a branch.
  6. List all branches.

Problem 5

  1. Switch to a branch
  2. Switch to the main branch using git checkout.
  3. Create and switch to a branch
  4. Create a new branch named bugfix/001 and switch to it in a single command with git checkout -b.

Problem 6

  1. Start with a repository containing a file named project.txt
  2. Create two branches (feature-1 and feature-2) from the main branch.
  3. Make changes to project.txt in both branches.
  4. Attempt to merge feature-1 and feature-2 into the main branch.
  5. Resolve any merge conflicts and complete the merge process.

Problem 7

  1. View history in one-line format
  2. Graphical commit history
  3. Filter commits by Author
  4. Show changes in a commit

Problem 8

  1. Fetch updates from remote
  2. Fetch and Merge
  3. Fetch changes from the remote branch origin/main and merge them into your local main
  4. List remote references

Problem 9

  1. Create a stash
  2. Apply a stash
  3. Pop a stash
  4. View stash

Problem 10

  1. You need to undo the last commit but want to keep the changes staged for a new commit. What will you do ?

Problem 11

  1. You realize you staged some files for commit but want to unstage them while keeping the changes in your working directory. Which git command will allow you to unstage the files without losing any change ?

Problem 12

  1. You decide to completely discard all local changes and reset the repository to the state of the last commit. What git command should you run to discard all changes and reset your working directory ?

Kanchi Linux Users Group Monthly Meeting – Dec 08, 2024

8 December 2024 at 02:43

Hi everyone,
KanchiLUG’s Monthly meet is scheduled as online meeting this week on Sunday, Dec 08, 2024 17:00 – 18:00 IST

Meeting link : https://meet.jit.si/KanchiLugMonthlyMeet

Can join with any browser or JitSi android app.
All the Discussions are in Tamil.

Talk Details

Talk 0:
Topic : my Elisp β€˜load random theme’ function
Description : I wanted to randomly load a theme in Emacs during startup. After i search in online, I achieved this
functionality using Emacs Lisp. this my talk Duration : 10 minutes
Name : Krishna Subramaniyan
About :GNU/Linux and Emacs user πŸ˜‰

Talk 1:
Topic : PDF generation using python
Description : To demo a python program which will generate a PDF output. Duration : 20 minutes
Name : Sethu
About : Member of KanchiLUG & Kaniyam IRC Channel

Talk 2:
Topic : distrobox – a wrapper on podman/docker
Description : Intro about the tool, why I had to use that and a demo Duration : 15 minutes
Name : Annamalai N
About : a GNU/Linux user

Talk 3:
Topic : Real Time Update Mechanisms (Polling, Long Polling, Server Sent Events)
Description : To demo Real Time Update Mechanisms with JS and Python Duration : 30 minutes
Name :Syed Jafer (parottasalna)
About : Developer. Currently teaching postgres at
https://t.me/parottasalna

After Talks : Q&A, General discussion

About KanchiLUG : Kanchi Linux Users Group [ KanchiLUG ] has been spreading awareness on Free/Open Source Software (F/OSS) in
Kanchipuram since November 2006.

Anyone can join! (Entry is free)
Everyone is welcome
Feel free to share this to your friends

Mailing list: kanchilug@freelists.org
Repository : https://gitlab.com/kanchilug
Twitter handle: @kanchilug
Kanchilug Blog : http://kanchilug.wordpress.com

To subscribe/unsubscribe kanchilug mailing list :
http://kanchilug.wordpress.com/join-mailing-list/

Kanchi Linux Users Group Monthly Meeting – Dec 08, 2024

8 December 2024 at 02:43

Hi everyone,
KanchiLUG’s Monthly meet is scheduled as online meeting this week on Sunday, Dec 08, 2024 17:00 – 18:00 IST

Meeting link : https://meet.jit.si/KanchiLugMonthlyMeet

Can join with any browser or JitSi android app.
All the Discussions are in Tamil.

Talk Details

Talk 0:
Topic : my Elisp β€˜load random theme’ function
Description : I wanted to randomly load a theme in Emacs during startup. After i search in online, I achieved this
functionality using Emacs Lisp. this my talk Duration : 10 minutes
Name : Krishna Subramaniyan
About :GNU/Linux and Emacs user πŸ˜‰

Talk 1:
Topic : PDF generation using python
Description : To demo a python program which will generate a PDF output. Duration : 20 minutes
Name : Sethu
About : Member of KanchiLUG & Kaniyam IRC Channel

Talk 2:
Topic : distrobox – a wrapper on podman/docker
Description : Intro about the tool, why I had to use that and a demo Duration : 15 minutes
Name : Annamalai N
About : a GNU/Linux user

Talk 3:
Topic : Real Time Update Mechanisms (Polling, Long Polling, Server Sent Events)
Description : To demo Real Time Update Mechanisms with JS and Python Duration : 30 minutes
Name :Syed Jafer (parottasalna)
About : Developer. Currently teaching postgres at
https://t.me/parottasalna

After Talks : Q&A, General discussion

About KanchiLUG : Kanchi Linux Users Group [ KanchiLUG ] has been spreading awareness on Free/Open Source Software (F/OSS) in
Kanchipuram since November 2006.

Anyone can join! (Entry is free)
Everyone is welcome
Feel free to share this to your friends

Mailing list: kanchilug@freelists.org
Repository : https://gitlab.com/kanchilug
Twitter handle: @kanchilug
Kanchilug Blog : http://kanchilug.wordpress.com

To subscribe/unsubscribe kanchilug mailing list :
http://kanchilug.wordpress.com/join-mailing-list/

Introduction to PostgreSQL database – free online course in Tamil

18 November 2024 at 02:26

Introduction to PostgreSQL database – free online course in Tamil

Monday, wednesday, Friday IST evening.

First class – 18-Nov-2024 7-8 PM IST

Syllabus: https://parottasalna.com/postgres-database-syllabus/

Trainer – Syed Jafer – contact.syedjafer@gmail.com

Get the meeting link here

Telegram Group – https://t.me/parottasalna
Whatsapp channel- https://whatsapp.com/channel/0029Vavu8mF2v1IpaPd9np0s Kaniyam Tech events Calendar – https://kaniyam.com/events/

Introduction to PostgreSQL database – free online course in Tamil

18 November 2024 at 02:26

Introduction to PostgreSQL database – free online course in Tamil

Monday, wednesday, Friday IST evening.

First class – 18-Nov-2024 7-8 PM IST

Syllabus: https://parottasalna.com/postgres-database-syllabus/

Trainer – Syed Jafer – contact.syedjafer@gmail.com

Get the meeting link here

Telegram Group – https://t.me/parottasalna
Whatsapp channel- https://whatsapp.com/channel/0029Vavu8mF2v1IpaPd9np0s Kaniyam Tech events Calendar – https://kaniyam.com/events/

Basic Linux Commands

By: Ragul.M
15 November 2024 at 14:25

Hi folks , welcome to my blog. Here we are going to see some basic and important commands of linux.

One of the most distinctive features of Linux is its command-line interface (CLI). Knowing a few basic commands can unlock many possibilities in Linux.
Essential Commands
Here are some fundamental commands to get you started:
ls - Lists files and directories in the current directory.

ls

cd - Changes to a different directory.

cd /home/user/Documents

pwd - Prints the current working directory.

pwd

cp - Copies files or directories.

cp file1.txt /home/user/backup/

mv - Moves or renames files or directories.

mv file1.txt file2.txt

rm - Removes files or directories.

rm file1.txt

mkdir - Creates a new directory.

mkdir new_folder

touch - Creates a new empty file.

touch newfile.txt

cat - Displays the contents of a file.

cat file1.txt

nano or vim - Opens a file in the text editor.

nano file1.txt

chmod - Changes file permissions.

chmod 755 file1.txt

ps - Displays active processes.

ps

kill - Terminates a process.

kill [PID]

Each command is powerful on its own, and combining them enables you to manage your files and system effectively.We can see more about some basics and interesting things about linux in further upcoming blogs which I will be posting.

Follow for more and happy learning :)

Linux basics for beginners

By: Ragul.M
14 November 2024 at 16:04

Introduction:
Linux is one of the most powerful and widely-used operating systems in the world, found everywhere from mobile devices to high-powered servers. Known for its stability, security, and open-source nature, Linux is an essential skill for anyone interested in IT, programming, or system administration.
In this blog , we are going to see What is linux and Why choose linux.

1) What is linux
Linux is an open-source operating system that was first introduced by Linus Torvalds in 1991. Built on a Unix-based foundation, Linux is community-driven, meaning anyone can view, modify, and contribute to its code. This collaborative approach has led to the creation of various Linux distributions, or "distros," each tailored to different types of users and use cases. Some of the most popular Linux distributions are:

  • Ubuntu: Known for its user-friendly interface, great for beginners.
  • Fedora: A cutting-edge distro with the latest software versions, popular with developers.
  • CentOS: Stable and widely used in enterprise environments. Each distribution may look and function slightly differently, but they all share the same core Linux features.

2) Why choose linux
Linux is favored for many reasons, including its:

  1. Stability: Linux is well-known for running smoothly without crashing, even in demanding environments.
  2. Security: Its open-source nature allows the community to detect and fix vulnerabilities quickly, making it highly secure.
  3. Customizability: Users have complete control to modify and customize their system.
  4. Performance: Linux is efficient, allowing it to run on a wide range of devices, from servers to small IoT devices.

Conclusion
Learning Linux basics is the first step to becoming proficient in an operating system that powers much of the digital world. We can see more about some basics and interesting things about linux in further upcoming blogs which I will be posting.

Follow for more and happy learning :)

Installing Arch Linux in UEFI systems(windows)

12 November 2024 at 15:22

This will be a very basic overview in what is to be done for installing Arch Linux. For more information check out Arch wiki installation guide.

The commands shown in this guide will be in italian(font).

Step 1: Downloading the required files and applications

I have downloaded a few applications to help ease the process for the installation. You can download them using the links below.

Rufus:
This helps in formatting the USB and converting the disc image file to a dd image file. I have used rufus, you can use other tools too. This only works on windows.
rufus link

BitTorrent
The download option in the wiki page suggests we use BitTorrent for downloading the disc image file.
BitTorrent for windows

Arch Linux torrent file
This is for downloading the Arch Linux Torrent File. The download link can be found in the website given below.
Arch Linux Download Page

Step 2: The bootable USB

You will need a USB of size at least 2GB and 4GB or above should be very comfortable to use.

First open the BitTorrent application or the web based version and upload the magnet link or the torrent file to start downloading the disc image file.

Then to prepare the USB:

  1. Launch the application to make the bootable USB like rufus.

2.In the device section select your USB and remember all the data in the drive will be lost after the process.

3.In boot selection, choose the disc image file that was downloaded through torrent.

4.In the target system select UEFI as we are using a UEFI system.

5.In the partition scheme make sure GPT is selected.

6.In file system select fat32 and 4096 bytes as cluster size.

7.When you click ready it will present you with 2 options, select the dd image file which is not the default option.

After the process is done the USB will not be readable to windows, so there is no need to panic if you cannot access the USB.

If you are using a dual boot make sure you have at least 30 GB of unallocated space.

I would recommend to turn off bitlocker settings as it could give rise to other challenges during the installation.

Then get into the UEFI Firmware settings of your system. One easy way is to:
1.Hold shift key while pressing to restart the computer
2.Go into Troubleshoot
3.Go into Advanced Settings
4.Select UEFI Firmware Settings
5.You will have to restart again but you will be in the required place.

Turn off secure boot state. It is usually in the security settings.

Select save changes and exit.

When you log back into your system ensure that secure boot state is off by going into system information.

Go back to UEFI Firmware settings by repeating the process.

In the boot priority section, give your USB device the highest priority. This is usually in the boot section. Then select save changes and exit.

Step 3: Preparing Arch Linux Installation

When all the above steps are done and the system restarts, you will be prompted with a few options. Select Arch Linux install medium and press 'Enter' to enter the installation environment. After this you will need to follow a series of steps.

1. Verifying you are in UEFI mode.

To do that type the command
cat /sys/firmware/efi/fw_platform_size

You should get the result as 32 or 64. If you get no result then you may not be using UEFI mode.

2. Connecting to the internet:

If you are using an ethernet cable then you don't have to worry as you might already be connected to internet.
Use the command
ping -c 4 google.com
or another website to ping from to check if you're connected to the internet.

To connect to wi-fi, type in the command
ip link

This should show you all the internet devices you have. Your wi-fi should typically be wlan0 or something like wlp3s0, which is your device name.

Then type the command
iwctl

This should get you into an interactive command line interface.
You can explore the options by using the command
help

My device name was wlan0 so I'm using wlan0 in the command I'm going to show if yours is different make the appropriate changes.

To connect to the wifi use the command
station wlan0 connect "Network Name"
where "Network Name" is the name of your network.

If you want to know the name of your network before doing this you can try the command
station wlan0 get-networks

To get out of the environment simply use the command
exit

After you exit, you can verify your connection with
ping -c 4 google.com

If it doesn't work, try the command
ping -c 4 8.8.8.8

If the above also doesn't work, the problem may lie with your network.

However if the second option works for you, the fix would be to manually change the DNS server you're using.
To do that, run the command
nano /etc/systemd/resolved.conf

In this file if the DNS part is commented using a #, remove the # and replace it with a DNS server you desire. For eg: 8.8.8.8

ctrl + x to save and exit

Now try pinging a website such as google.com again to make sure you're properly connected to the internet.

3. Set the proper time

When you connect to the internet you should have the proper time. To check you can use the command
timedatectl

4. Create the partitions for Arch Linux

To check what partitions you have, use the command
lsblk

This will list the partitions you have. It will be in the format /dev/sda or /dev/nvme0n1 or something else. Mine was /dev/nvme0n1 so I'll be using the same in the commands below.

To make the partitions, use the command
fdisk /dev/nvme0n1

This should bring you to a separate command line interface.

It will give you an introduction on what to do.

Now we will create the partitions.
To create a partition, use the command
n

It will show you what you want to number your partition and the default option. Click enter as it will automatically take the default option if you don't enter any value. Let's say mine is 1.

It will show you what sector you want the partition to start from and the default option. Click enter.

Then it will ask you where you want the sectors to end: type
+1g

1g will allot 1 GB to the partition you just created.

Then create another partition in the same way, let's say mine is sector number 2 this time and finally instead of
+1g use +4g

This will allot 4 GB to the second partition you just created.

Create another partition and this time leave the last sector to default so it can have the remaining space. Let's say this partition is number 3.

partition 1 - EFI system partition
partition 2 - Linux SWAP partition
partition 3 - Linux root partition

5. Prepare the created partitions for Arch Linux installation

Here, we are going to format the memory in the chosen partitions and make them the appropriate file systems.

For the EFI partition:
mkfs.fat -F 32 /dev/nvme0n1p1

This converts the 1 GB partition into a fat32 file system.

For SWAP partition:
mkswap /dev/nvme0n1p2

This converts the 4 GB partition into something that can be used as virtual RAM.

For root partition:
mkfs.ext4 /dev/nvme0n1p3

This converts the root partition into a file system that is called ext4.

6. Mounting the partitions

This is for setting a reference point to the partitions we just created.

For the EFI partition:
mount --mkdir /dev/nvme0n1p1 /mnt/boot

For the root partition:
mount /dev/nvme0n1p3 /mnt

For the swap partition:
swapon /dev/nvme0n1p2

Step 3: The Arch Linux Installation

1. Updating the mirrorlist (optional)

The mirrorlist is a list of mirror servers from which packages can be downloaded. Choosing the right mirror server could get you higher download speeds.

This step isn't required as the mirror list is automatically updated when connected to the internet but if you would like to manually do it, its in the file
/etc/pacman.d/mirrorlist

2. Installing base Linux kernel and firmware

To do this, use the command
pacstrap -K /mnt base linux linux-firmware

Step 4: Configuring Arch Linux system

1. generating fstab

The fstab is the file system table. It contains information on each of the file partitions and storage devices. It also contains information on how they should be mounted during boot.

To do it, use the command:
genfstab -U /mnt >> /mnt/etc/fstab

2. Chroot

Chroot is short for change root. It is used to directly interact with the Arch Linux partitions from the live environment in the USB.

To do it, use the command:
arch-chroot /mnt

3. Time

The timezone has 2 parts the region and the city. I am from India so my region is Asia and the city is Kolkata. Change yours appropriately to your needs.

The command:
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

We can also set the time in hardware clock as UTC.
To do that:
hwclock --systohc

4. Installing some important tools

The system you have installed is a very basic system, so it doesn't have a lot of stuff. I'm recommending two very basic tools as they can be handy.

i) nano:
This is a text editor file so you can make changes to configuration files.
pacman -S nano

ii) iwd:
This is called iNet wireless daemon. I recommend this so that you can connect to wi-fi once you reboot to your actual arch system.
pacman -S iwd

5. Localization

This is for setting the keyboard layout and language. Go to the file /etc/locale.conf by using
nano /etc/locale.conf

I want to use the english language that is the default in most devices so for doing that you have to uncomment(remove the #) for the line that says
LANG=en_US.UTF-8

As there are a lot of lines you can search using ctrl+F.

Then ctrl+X to save and exit.

Then use the command
locale-gen

This command generates the locale you just uncommented.

6. Host and password

To create the host name, we should do it in the /etc/hostname file. Use
nano /etc/hostname

Then type in what your hostname would be.
ctrl + X to save and exit.

To set the password of your root user, use the command
passwd

7. Getting out of chroot and rebooting the system

To get out of chroot simply use
exit

Then to reboot the system use
reboot

Remove the installation medium(USB) as the device turns off.

Step 5: Enjoy Arch Linux

Arch Linux is one of the most minimal systems. So you can customize it to your liking. You can also install other desktop environments if you feel like it.

❌
❌