Normal view

There are new articles available, click to refresh the page.
Yesterday — 1 April 2025Main stream

Linux-Basic command

By: Prasanth
1 April 2025 at 11:23

Table-content:

1.Terminal Cursor movement
2.Basic commands
3.Standard Streams in Linux

1.Terminal Cursor movement

i. Ctrl + A - move to the beginning of the lin e
ii. Ctrl + E - Move to the end of the line
iii. Ctrl + B -- Move backward one character
iv. Ctrl + F - move forward one character
v. Alt + B - Move backward one word
vi. Alt + F - Move forward one word
vii. Ctrl + R - Reverse search command history, Ctrl + R after press up Arrow.
viii. Ctrl + G cancel search history.
ix. Ctrl + L - clear the terminal
X. TAB - auto completion filename or command
xi. Ctrl + Z - stop the current command and resume wit fg in foreground or bg in background
xii. !! = repeat last command.

2.Basic commands

1.check current working directory

=> #pwd

output:-

/root

2.check current logged user

i. $ whoami- Display the username of currently logged in user.
ii.$ who - shows all logged user along with terminal sessions
iii. $ w - shows all logged user along with terminal sessions with activities.

3.chck the system hostname

i. $ hostname

ii. Show the detailed information about Hostname
$ hostnamectl
iii. check system ip & mac with help of hostname
$ hostname -I
(we will see, up coming blogs how to set the hostname temporarily and permanent)

4. check ip address

$ ip a
$ ip addr
$ ifconfig
(we will see, up coming blogs how to set the ip address ,gateway, broadcast,...etc, permanent and detailed result information)
5.clear the screen - $ clear

6.man = man is manual page of all command provide detailed documentation, syntax, options, example.

example:-

$ man ls

7.sudo
sudo is you allows you run command as super user ( admin privileges)

Example:-

$ sudo dnf update
- dnf is RHCL based package manger

8.$ history
-used to find out all those commands we ran previously.

9. create directory(folder)

`$ mkdir dir

$ mkdir dir1 dir2

$ mkdir -p grandpa/father/son

10 . Change directory

$ cd /home/user/Documents
$ cd .. => parent directory (move up one level in the directory structure)
$ cd . -> stay in the current directory
$ cd ../../ => move up multiple level.
$ cd - => go back to the previous directory
$ cd / = change root directory
$ cd ~ = change the home directory

11. Create file:-

i. create empty file using touch

$touch file.txt
$touch file.txt file1.txt

ii. Using echo

$echo "Welcome to MyLinuxBlog" > welcome.txt

iii. using cat

$cat > file.txt

Hi, this the text file(text somthing)
then Ctr + D(save)

iv. printf

$printf " Line-1 \n Line-2 \n Line-3 " > file.txt

12. List the file and directory

i. $ ls -lah
-l = list
-a = hidden
-h = human readable format
ii. $ ls -li
-i check inode for files and directory.
iii. $ ls -R
-R = recursively search (show the content of sub-ls directory)
iv. $ ls -ld */ (list the directory only)
v. $ ls -ld .. (parent)
vi. $ ls -ld . (current)

-t = sort by modification time

13. Copy the file and directory.

$ cp f1.txt destination-path/dirname

Example:-

$ cp file.txt dir1

Source to Destination copy:

$ cp file.txt /home/user/backup/

$ cp -r dir1 /home/user/backup/

Destination to Source copy:

$ cp /home/user/backup/file2.txt /home/user

option:-

-v verbose
-i = confirmation
-n = copy with without overwriting

14. Move and rename the file and directory

Rename the file:-

mv Oldname.txt Newname.txt

Move the file:-

mv file1.txt /home/usr/backup/

mv file2.txt file3.txt /home/user/backup/

option:-

-i - before moving ask confrimation.
-u -update
-v -verbose
-f force

*same method to follow directory move and rename.

when use mv the directory why do not use -r only using cp -r for dir ?

15. Delete the File and Directory

$rmdir dir1
(empty directory)
$rm -rfi dir (delete everything inside all directory )

option:-

-i - confirmation
-r - recusively
-v - verbose
-f - force
$rm -if file.txt

*-rf * = Be careful to use this option when deletion ,make to confirm once or four before use this option, can not retrieve the data after deletion.
rm -rf * ==> (* means all)Be careful

16. cat – display the content of the file

$cat > file.txt (it create the new file ,
it waits for you enter some text(owerites)
Ctrl + D(save)
$cat >> file.txt
appends to the file without overwriting existing content.
$cat -n file.txt -> Show with line numbers
$cat file1 file2 > merged.txt -> Merge files
$cat file.txt | grep "word" -> Search for a word
$tac file.txt -> Display in reverse.

17.more -Display the content page by page only navigation to forward direction not backward direction.

Example:

$more file.txt

Enter – scroll down one line
space – scroll down one page
-q - quite

$more +n file.txt
$more -n file.txt
n = number,

Example:-

$more +10 file.txt

18. less -Display the content page by page only navigation to forward direction and backward direction.

$less file.txt

output:-

hello welcome to Linux world
/search_word

example:
/Linux
space – scroll down one page
q - quite
b – scroll up up one page
g - go the begning of the file
G -go to end of the file.

19.head -display the first few lines, not real-time monitoring.

Example:-

$head f1.txt

$head -n 420 f1.txt

$head -c 20 f1.txt

-c display first 20 byte of the file content

20.tail-display the last few lines, real-time monitoring.

Example:-

$tail f1.txt
$tail-n 420 f1.txt
$tail -c 20 f1.txt

21. Standard Streams in Linux:-

1.stdin(0) - Takes input from the keyboard and file
2.stdout(1) -shows output like what you see on the screen
3.stderr(2) -shows error message ,also on the screen

1. Standard Streams

i. Standard Input (stdin - File Descriptor 0):

  • Take the input from the user like keyboard, when run the cat, read command it required input , it wait for you type something other wise Ctr + D.

ii. Standard Output (stdout - File Descriptor 1):

*share the output on your screen like when you run echo, ls command .

Example:-

$echo "Hellow Linux world"

*echo command send to text stdout ,it displays on your screen.

iii. Standard Error (stderr - File Descriptor 2):

  • send the error message on your screen
  • when made mistake on terminal send the message stderr not for stdout.

Example:-

$cd dir1

*dir1 is not created really at the time error message sent to stderr.

2. Redirection in Linux: stdin , stdout ,stderr .

Example:-

i.Redirect Input (<):

  • Input from the keyboard:

< -> Take the input from a file instead of the keyboard .
$ sort < names.txt
$ wc -l < nmaes.txt (wc -l -word count line)

  • stdout (1) -Output to the screen: $echo "Welcome To My Blog" > file.txt

ii. Redirect Output (>):

$ echo "Hello" > file.txt
$ echo "Hello world" >> file.txt

iii. Redirect Errors (2>):

Example:-

$ls /usr/home/ 2> err.log

*/usr/home/ this actually not real path ,at the time error message sent to stderr.

output:

No such file or directory.

22.Pipe operator:-

  • Pipe operator (|) connect multiple command.

syntax:-

command1 | command2

Example:-

$ ls | wc -l
$ cat file.txt | grep "Linux" (grep- pattern searcher)

OpenAI - Gibili Portrait Assistance: AI-Powered Image Generation Made Simple

By: angu10
31 March 2025 at 17:50

Introduction

Ever wished you could create stunning portraits with just a few clicks? Meet Gibili Portrait Assistance, an AI-powered tool that makes generating high-quality portraits effortless. Whether you’re an artist, designer, or simply someone who loves experimenting with AI, Gibili can help bring your ideas to life.

In this post, we’ll walk you through how to use Gibili Portrait Assistance and explore the OpenAI architecture behind it.

How to Use Gibili Portrait Assistance

Using Gibili is straightforward and requires no prior technical knowledge. Here’s a simple step-by-step guide:

1. Enter Your Description or Upload an Image
You can either type a text description of the portrait you want or upload an existing image to be enhanced or transformed by AI.

Text Prompt Example:

  • “A realistic portrait of a woman with curly brown hair, wearing a red scarf, in a cinematic lighting style.”

Image Upload:

  • If you have an image you want to modify or enhance, simply upload it, and Gibili will apply AI-powered enhancements or transformations.

2. Customize Your Preferences
You can fine-tune details such as:

  • Art Style: Realistic, digital painting, anime, etc.
  • Background: Solid color, blurred, natural scenery.
  • Facial Expressions: Smiling, neutral, surprised.
  • Additional Features: Glasses, hats, jewelry, etc.

3. Generate the Image
Press Enter, and within seconds, Gibili will produce a high-resolution portrait based on your input or uploaded image.

4. Refine and Download
If you want adjustments, you can tweak your input and regenerate until you’re satisfied. Once ready, download your portrait in high-quality format.

The OpenAI Architecture Behind Gibili

Gibili Portrait Assistance is powered by OpenAI’s advanced image generation models, leveraging diffusion models to create highly detailed and realistic portraits. Here’s a simplified breakdown:

1. Text-to-Image & Image-to-Image Generation
When you provide a text prompt, the AI model translates it into a visual representation using deep learning techniques. If you upload an image, the model can enhance, transform, or stylize it while maintaining its core structure.

2. Fine-Tuned on Portrait Data
The model has been trained on a vast dataset of portraits across different styles, ensuring high accuracy and creativity in generated images.

3. Iterative Refinement
Instead of creating the final image instantly, the AI gradually refines it through multiple steps, ensuring greater precision and quality.

4. User-Guided Adjustments
Users can modify parameters like style and background, and the model will intelligently adjust the portrait while maintaining coherence.

Why Use Gibili Portrait Assistance?

✅ Easy to Use

No need for advanced design skills — just describe what you want or upload an image, and AI does the rest.

🎨 Customizable Output

From photorealistic portraits to artistic illustrations, you can tailor the results to your liking.

🚀 Fast & High-Quality

Generate high-resolution images within seconds.

🖌️ Creative Freedom

Perfect for artists, marketers, and content creators looking for unique visuals.

Get Started with Gibili Today!

Ready to create amazing AI-generated portraits? Try Gibili Portrait Assistance now and explore the limitless possibilities of AI-powered creativity!

Grub

By: Prasanth
31 March 2025 at 12:11

*underworking -issue facing
*

Image description

i.Grub2 configuration

  • main grub2 configuration file is /etc/default/grub
  • Actual grub2 bootloader configuration is stored in /boot/grub/grub.cfg file on Bios based machine UEFI is defer ,like /boot/efi/EFI/centos/grub.cfg ( do not edit manually it'make trouble for when booting ),

EFI not show why mine ? because i not generated to the exact location and my system is bios based machine.

ii.Generate new grub configuration file

#grub2-mkconfig -o /boot/grub2/grub.cfg

grub2-mkconfig - generat the new grub2 config file
-o /boot/grub2/grub.cfg -specifies the output file location.

iii. check grub version

#grub-install --version

iv.view grub2 settings:-

#cat /etc/default/grub

/etc/grub.d/

/etc/grub.d/ useful fo grub detects and organizes boot entries and custom boot entry.

v. Editing Grub2 settings

This part useful for set the boot menu timeout in second and grub boot entry and so on .

#sudo vim /etc/default/grub

let we see important only :-
i. GRUB_TIMEOUT=12

it means 12 secound delay before booting default Os in grub menu ,you can reduce time also.

ii. GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

automatically sets linux distribution name in grub menu. /etc/system-release it helps to get os name with help sed command.

iii. GRUB_DEFAULT=saved

save the last boot in kernel and boot the same one int next time
you can set also GRUB_DEFAULT=0, it means ,to always boot on specify OS,1 is second menu entry.

iv. GRUB_TERMINAL_OUTPUT="console"

  • I force to grub display the output console mode that mean text mode not gui mode, you set also GRUB_TERMINAL_OUTPUT="gfxterm"

v. GRUB_DISABLE_RECOVERY="true"

  • Disable recovery mode in the boot menu ,preferred choice set as false ,incase of emergency it's useful.

vi. GRUB_ENABLE_BLSCFG=true

  • Enables loader specification ,BLS means modern boot entry format .

vii.#GRUB_HIDDEN_TIMEOUT=0

  • I will uncommented using # this part ,this actually hide the grub menu and boot immediately after 0 seconds.

viii. GRUB_TIMEOUT_STYLE=menu

  • make sure always visible GRUB menu
  • You can set also =hidden, skipped the Grub menu immediately boot.

3.Apply the changes to grub

#sudo grub2-mkconfig -o /boot/grub2/grub.cfg

4.if grub corrupted or missing what can we do ?

we will see enter and  use rescue mode in linux.
  1. Enter rescue mode from Grub menu

i. Restart your system
ii. press & hold Shift or press Esc for UEFI bios then GRUB menu show.
iii. selct Advanced options , choose rescue mode or also called recovery mode.
iv press Enter to boot into rescue mode.
V. once you inside ,select into root shell prompt

  1. manually Enter Rescue mode from GRUB
    • your system appeared on grub rescue at the time of problem occurred. after showed prompt you can fallow below steps. i. check all availability disk #ls

ii. find the linux root partition

ls (hd0,1)/

ls (hd0,2)/

ls (hd0,3)/

when you see /boot/grub for like this is your boot partion.

iii. the correct the partition
set root=(hd0,1) # set as root partion where to grub installed ,hd0 mean hard drive,1 is first partion
set prefix=(hd0,1)/boot/grub = set the grub location
insmod normal = load grub normal mode
normal = load grub menu

3.fix the grub permanetly after booting into linux:-

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub2-install /dev/sda # Replace sda with your disk
sudo reboot

then,

regenerate the config file:-

sudo update-grub

4.Boot into rescue and Emergency mode:

if you system is running but u need rescue mode fallow below steps;-

sudo systemctl rescue

sudo systemctl emergency

  1. Boot int rescue and emergency mode using grub menu:

1.Restart your system.
2.Grub menu , select your Linux kernel.
3.after selected, press e (edit) then ,find the line starting with linux ,add the end of line below line then Ctr +x or f10

systemd.unit=rescue.target

  • Follow same steps are emergency mode

systemd.unit=emergency.target

then,remount the root filesystem in emergency mode

mount | grep " / " -current filesystem mount status
mount -o remount,rw / -remount root file system in read-write
fsck -y /dev/sdX - -sdX(yours disk) , if you want fix the filesystem ,we will see detail information upcoming device management blog,then reboot.

  1. Reset Root passwd

1.Restart your system.
2.Grub menu , select your Linux kernel.
3.after selected, press e (edit) then ,find the line starting with linux ,add the end of line below the command line then Ctr +x or f10

init=/bin/bash

after see the panel type below command ,default filesytem is read-only mode,you need to remount read-write mode.
mount -o remount,rw /
touch /.autorelabel (if your system use SELinux - Security Enhanced linux) to proctecte files.
(touch /.autorelabel if not follow this step lables get damage or lost,you get error like permession denied,can not login in after resetting root password.after reboot linux look on this empty file /.autorelabel and automatically fix security label ,after fixing system will delete the .autorelabel and reboots again.note:create with name of autorelabel empty file otherwise linux not understand ,because linux desinged the linux.SELinux won’t detect it, and relabeling won’t happen.
.autorelabel works because it's hardcoded in SELinux.
passwd root
exec /sbin/init (reboot)

or reboot -f

https://www.gnu.org/software/grub/manual/grub/html_node/index

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-working_with_the_grub_2_boot_loader#sec-Making_Temporary_Changes_to_a_GRUB_2_Menu

How to use existing SSH key on my newly installed Ubuntu

30 March 2025 at 13:55

copy the old ssh keys  ~/.ssh/ directory
$ cp /path/to/id_rsa ~/.ssh/id_rsa
$ cp /path/to/id_rsa.pub ~/.ssh/id_rsa.pub

change permissions on file
$ sudo chmod 600 ~/.ssh/id_rsa
$ sudo chmod 600 ~/.ssh/id_rsa.pub

start the ssh-agent in the background
$ eval $(ssh-agent -s)

make ssh agent to actually use copied key
$ ssh-add ~/.ssh/id_rsa

Before yesterdayMain stream

Linux-Directory

By: Prasanth
29 March 2025 at 15:02

1. / = Directory is called root directory . head/parent of the all directory.

Image description

*2./bin
*

*contains executable/program/commands to achieve the basic tasks that accessible for every system user and root user.
Eg: ls,cat,touch,cp,mv.
=> # = Root user
=> $ = Normal user

3. /sbin

=> *contains /executable/program/command to achieve the system level task or system level settings for Only root user can executable . Not accessible for normal user.
Eg: ifconfig,iptables,fsck,fdisk

*4. /dev = Linux/Unix is treats everything as file including hardware devices *

  • /dev is a directory that provides device files acting as interfaces between hardware and user-space programs. These files allow software to communicate with hardware without direct access. *what is mean user space user space - run regular program without direct access of hardware access,like browser and ,text editor, command line tool ls, cat.

/dev paths

/dev/sda - sata disk(primary device)
/dev/hda - IDE hard disk
/dev/sdb - secondary device
/dev/cdrom - CD/DVD drive
/dev/tty - terminal interface.

Two main type of device:-

i. Character device= Transfer the data byte to byte(used for serial communication),perform wise it slower and small data

Example: keyboard ,mouse, serial port,mic
/dev/tty - terminal interface,
/dev/input/mice

ii.Block device = Transfer data block to block, preform wise it faster and large data

example:

storage device:-
ssd ,usb , hhd

Image description

Image description

*we will see device management detailed info and create device and so on.

*5 . /etc
*

*Sytem directory ,it contains system-wide configuraiton file and installed program settings.it not for user specific ,does not contain binary executable like /bin or /sbin only contain text based configuration files, require root(sudo) access to modifying /etc .

  • Linux application and services read the setting from /etc . *etc/ contain ,system and network settings ,serives and boot and startup scripts......etc.

example:

$ sudo vim /etc/hostname

Image description

Common files and Directories:-

i./etc/passwd - store the use account information
ii. /etc/shaddow - store encrypted password
iii. /etc/group - define usr gourps
iv. /etc/hosts - map to hostanme to ip address
v. /etc/fstab - contains info on mounted(connected) filesystems
vi. .etc/hostanme - view hostnbame and also u can edit
vii. /etc/reslov.conf - configure of dns settings
viii. /etc/network/interfaces - stores nework configuration files
ix. /etc/ssh/sshd_config - store ssh server settings
x. /etc/systemd/ stores systemd serice configuation

  • Be careful when editing, as changes affect the entire system.

*6./home (home = ~)
*

  • /home directory in store user home directories , every user on the system has a personal folder inside of /home , you can view
    user related documents , downloads ,file, configuration and settings....etc.

    • System-wide configuration files are not stored here (those are in /etc). --- check

i. change the directory
cd ~
ii. List all user directors in /home
ls /home
iii. check the current home directory
echo $HOME
iv. Navigate the your home directory
cd /home/your-username
v. sudo userdel -r username
-r = recursively(remove)

it Deletes user + home directory
vi. disk usage of /home
du -sh /home
-s = summarizes the total size
-h = human readable
vii. sudo -u alice -s
-u = mean user
-s = mean open a new shell for that new user

viii. sudo userdel username

Deletes only user, keeps home directory

ix. sudo rm -r /home/username

Deletes only the home directory

Image description

*7. /lib = library
*

  • /lib directory contain shared libraries and kernel modules required by system and programs in /bin and /sbin .

Detailed information of /lib

  • Stores the shared libraries(.so files ) needed for basic system programs support commands stored in /bin and /sbin .

Example shared libraries in /lib

=> modules/ → Kernel modules (drivers)
=> systemd/ → System service manager files
=> firmware/ → Hardware firmware
=> libcrypt.so → Example shared library
=> libc.so - standard C library (important of C programm)
=> libc.so - basic system commands>
=> libssl.so - provide encrypt secure internet connerction , uded by google chrome,fire fox,vpns.
=> libGL.so - graphics Library for games ,drones
=> libusb.so - usb communication library
=> libm.so -Math functions (used in calculation)
=> Math functions (used in calculation)
=> libpthread.so - thread support.
=> lirobotics.so = drones,robots,Industrila automation.
.
*purpose of shared libraries:-
*

*Avoid duplicating the same code in every time
*Save disk space and Ram
*Allow programs to update without recompiling.
*shared libraries (.so shared object files) contain reusable code that helps to multiple program can use reducing duplication.
Without /lib, your Linux system won’t boot properly.
*used by applications ( firefox,VLX,chrome) in run is user space.

example

web browser(Chrome,Firefox)

  • All web page needs to display text and image for example you need to diplay the image on you website ,you not need to write your code instead you use to libfreetype.so which provide ready-made functions for text rendering.

Checking Shared Libraries Used by a Program:

=> #ldd /bin/ls

Image description

kernel module

*A kernel module is a driver or extension that can be loaded/unload the linux kernel without rebooting the system.

purpose:-

  • It allows Linux to support new hardaware feature like wifi , usb , graphics...etc.
    • adds new filesystem support (NTFS,ext4,xfx) and help communicate the hardware devise like keyboard ,mouse,printer and also add or remove dynamically without restart the file system.

example:-

when you plug in usb in system ,linux load a kernel usbstorage.ko to access the device then ,unplug usb Linux automatically remove the module.

*used by kernel & Hardware runs in kernel space

Example:-

lsmod | grep <your usb device

i. wl.ko -manage wifi drivers
ii. usb-storage.ko - mange storage device internal and external
iii. btusb.ko - manage Bluetooth device
iv. video.ko - .manage webcam drivers
v. ext4.ko - filesystem handling

Difference Between /lib, /usr/lib, and /lib64

/lib = system libraries for programs in /bin and /sbin for system beet neede
/usr/lib = Libraries for user applications (not critical for system boot not need for boot ).
/lib64 64-bit version of libraries (for 64-bit systems).

*Library files require to not only Linux os apart form Rockets, mobile apps,Autonomous Robots (librrobotics.so used to tesla autopilot,NASA MARS Rover),Ai,web Browser......etc.

*lib used for you do not write all code manually it already pre-written for example in your create website project not need calculation code instated of you use libm.so (which provides sin(), cos(), sqrt(), etc.).

*8. /media = Auto mount(connect) for External device *.

*/media directory is used to automatically mount external device like usb drives , CDs,DVDs,SD cards.

*when you insert a usb drive, it us usually mounted in /media/username/usb-drive//

example:-
ls /media/

*9. /mnt/ manual mounting of device
*

i. mount point directory
why mount in a directory?

*you don not access storage devise directly
instead , you attach(connect or mount) to dir ,then you can access the directory. without mounting do not know where to access the usb. if mount usb dirive /mydir/externdevice you can access it inside of folder.

$ sudo mkdir -p /mydir/externdevice
$ sudo mount /mydir/externdevice
ii. verify the mount
mount | grep /mydir/externdevice

or
df -h

sudo umount /mydir/externdevice
umount -disconnect

why umount?

*without umount you loss your data or corruption

*10. /opt = optional
*

=> *Directory used for store third party application or manually installed software not managed for system package manager

Image description

/usr/bin - system wide installed programs by package manager
/usr/local/bin - locally installed software by admin

*11. /proc
*

*The directory in linux special folder . which show the live system information and computer hardware ,it does not contain real files but create information on the spot .

Example:-

*when you run a program like firefox & ,kernel created the new process and assign to the pid. process details appear in /proc/PID-of-firefox

practical:-

$firefox &
$ps aux | grep firefox
show the snapshot firefox pid and other deatils.
$ls /proc/pidofirefox
show the firefox process,memory usage ...etc
when close or kill fire fox using kill command it pid disappear from /proc directroy because it virtual filesytem, only show live session on when run the process.
$pidof firefox
show the more pid, its mean fire fox separate process for ui ,web pages,extension and so on.

Image description

Image description

Image description

Important directory in /proc:-

/proc/cpuinfo = info about the cpu model,core,speed.
/proc/meminfo = system RAM details
/proc/upting = system how long will be running system.
/proc/version = kernel version info.
/proc/mounts = shows mounted fiessystems
/proc/loadavg = system load average.

12. /root

Image description

  • /root is the home directroy of the root (superuser) account.
  • it stores root personal files, configuration and scripts. Just like normal user.

*normal user can not access /root ,if you need to access you can choose sudo.

example
$sudo ls /root

$sudo cd /root

*13./tmp (temporary files)
*

*stores temporary files that are automatically delted after restart or some time.
*used by application to store temorarery files, like session data, logs,caches.

  • Any user can write file in /tmp delted automatically when restart.
  • the /tmp directory has write permisssion for all users.you can see the t it means sticky bit ,it means owner can delete their own files and every one read and write and execute.
  • Later we will see sticky bit, suid , sgid.

Image description

Example:-
$cd /tmp
$touh temp.txt
then restart system after use below command
$ls /tmp

14. /usr

  • Stores system programs, libraries and shared files for all users
  • / root after this /usr directory is main directroy ,it containg all installed software and tools it contain /usr/bin/ /usr/lib/ /usr/share => Documentation ,icons,fonts

if you read this directory tell me different
for example :
bin/ vs /usr/bin
lib/ vs /usr/lib

15. /var = variable data

*contains variable file like log files and printer spools.L

examlple;-
i. /var/log = system log,auth.log,dmesg
ii. /var/spool = Email queues and printer queues.
iii. var/tmp - Longer time temp file it mean still there after reboot.

example:-
ls /var/log
cat /var/log/syslog - view system log

16 . /boot

  • without /boot, your system won't start,it contains linux kernel,which control hardware and software. And also GRUB is locate in /boot it help you choose which os to boot

example

i.ls /boot
ii. ls /boot/vmlinuz* ( show installed kernels)
iii. cat/boot/grub/grub.cfg ( grub config file)

17 . /run -runtime data storage

  • stores temporary system and process information that is required to system operation. when reboot after you see the /run/ directory data will be wipe out. Note System services recreate necessary files, but manually created files disappear. run/ used to stored as RAM.
    • it store only temporary service-related files like pid,sockets,lock files,runtime configuration file

example

Image description

18 . /srv - service data storage

  • stores files related to service hosted on the machine.

Example:-

Image description

vim editor after opened press i add the last lines as per below image then double press Esc then :wq ,after restart serives, then type http:

Image description

Result:

Image description

19 . /sys - system information

/sys directory is a virtual file system that provide the information about hardware device and kernel,it allow to linux kernel to ineract with system hardware in real time.

Example:-

i.liste the storage device
ls /sys/block

ii.detailed hardware device info
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
iii. Check total memory in system
cat /sys/devices/system/memory/block_size_bytes

iv. ls /sys/module - list kernel modules

display , switch namespace using kubens in K8S

29 March 2025 at 02:23

Install kubectx
$ sudo snap install kubectx --classic

create namespace development
$ kubectl create namespace development

To list available namespace
$ kubens

To switch to another namespace development
$ kubens development

To switch to default namespace from development
$ kubens default

To delete all resources from a namespace
$ kubectl delete all –all -n {namespace}

How to create namespace in K*S

29 March 2025 at 02:04

namespace is a mechanism for logically partitioning and isolating resources within a single cluster, allowing multiple teams or projects to share the same cluster without conflicts

creating a namespace mygroup by manfest file
$ vim mygroup.yml
apiVersion: v1
kind: Namespace
metadata:
name: mygroup
:x

$ kubectl apply -f mygroup.yml

To list all namespace
$ kubectl get namespaces

To switch to mygroup namespace
$ kubectl config set-context --current --namespace=mygroup

To delete namespace mygroup
$ kubectl delete namespace mygroup

The command Line

By: Prasanth
28 March 2025 at 14:21

Reference
1.Book: Linux Administration A Beginner's Guide

*Author * : Wale Soyinka

Bash:-

The login shell is a first program runs when user log into a system. Shell is command language interpreter, shell read and process command execute the user types ,it allow to the user interact with operating system by executing command. Bash(Bourn Again Shell) is improved version of shell , shell used to old linux system, now Bash is used to modern distro .Bash is command line only interface ,it does not have GUi only text-based interaction(CLI),contain built-in commands like cd, echo(print text),bash can lanuch programs and manage running process.
.
Job control:-

when you working in the bash environment, you can start multiple program simultaneously at same prompt . each program consider a job ,by default when run a program, it take over the control terminal, can not type other program until the current program job done. some program require full terminal control to display colored text and fromating for example text editor,now see graphical programs do not need full control the terminal, it just run the background.

example:-

$ firefox ( take over the control terminal)
or
$ firefox & ( run the background keep using terminal)
or
$firefox & gedit & vlc & (multiple program)
$jobs

output show the running

Image description

  • ctr + z pass the current running process
  • ctr + c stop the process (later we will see kill, pkill , killall)

syntax:-

fg job of the firefox number

example:-
$firefox &
$jobs
$ fg 1
fg is bring it to the foreground the job.

bg -background the process

example:-

$sleep 100 (you tell the system
pause 100 second, do nothing)
ctr + z (pause the process sleep)
$bg (resume the last process in the process background)
(bg %jobid = resume particular job in the background, if multiple job running background)
$jobs
$fg (bg jobs bring it to the foreground the job)

Image description

Environment Variables:-

  • Every time you open a new terminal (shell) or run a program (process) in Linux, the system loads environment variables like $HOME, $USER, and $PATH. Each shell session or running process has its own set of settings that control how it behaves. These settings are stored in environment variables, which can be modified to customize the system without changing the original program code.

  • Environment variables in Linux are stored as key-value pairs(VARIABLE=value), either globally or locally. They hold values like file paths, system configurations, and application settings (for example, configuring software behavior). Environment variables can be temporary (session-based) or permanent (saved across reboots).

Practicles:

  1. view all environment varibale $ printenv or $ env

2.set a temporary varibale for current session only

bash:-
$export MY_VAR="Hellow_Linux" (globally set env variable)
$echo $MY_VAR
(varibale set only capital)

3.Remove a temp variable
unset MY_VAR

4.set permeant variable
edit ~/.bashrc or ~/.bash_profile(for bash user only)
$ vim ~/.bashrc
press i for insert mode
Add:-
export MY_VAR="Hellow_Linux"
double tap Esc
then
:wq(save and quite)
then
source ~/.bashrc (apply the changes)

or

echo 'export MY_VAR="Permanent Value"' >> ~/.bashrc
source ~/.bashrc > Apply changes

5.Application configuration

export DB_URL="jdbc:postgresql://localhost:5432/mydatabase"
echo $DB_URL
result:-
jdbc:postgresql://localhost:5432/mydatabase

6.storing Api key securely
set port API_KEY="abcde-123456-fghijk"

7.Setting Language
export LANG="en_US.UTF-8"
echo $LANG
result: en_US.UTF-8

8.simple scripting ,temporarily environment variable:-

Image description

bash:-

mkdir -p ~/scripts

make the directory in scripts(dir name) in side of HOME(~)
-p parent

echo -e '#!/bin/bash\necho "welcome to MY Linux blog"' > ~/scripts/myscript.sh

echo -e = print the text in terminal -e enable escape sequence & \n new line.

!/bin/bash = shebang operator ,tell the system to runt eh script using BASH.
=> > = redirect
~/scripts/myscript.sh = script file location

  1. Commonly used Environment variable:- $PATH = specifies directories executable file $HOME = user home directory $SHELL = default shell $USER = current logged in user $LANG = Language setting $PWD = current working directory $HOSTNAME = Machine hostname

example: $echo $HOME

Installation of “CentOS Stream 9″

By: Prasanth
27 March 2025 at 07:50

Installations way of Linux operating systems:-

1.single Boot(Linux only)
2.Dual Boot( Linux + windows or macOS)
3.other operating system + virtual machine( multiple os run simultaneously)

*Early stage way to choose 2 or 3 option and move to 1 option(Recommend way),now we have see the early stage ,if you need 1 option please commend me the blog.

Operating system: Linux CentOS Stream 9

Prerequisites:-

*Pendrive 32 gb
*Internet connection
*minimum 2 gb ram
*free storage 40gb more

step1: Create a Bootable USB (Pendrive)

for windows user(using Rufus)

1.Download Rufus from => https://rufus.ie/en/
Dowload iso image from -https://www.centos.org/download/(choose iso base d on you system info)most likely x86_64 .
2.insert your usb drive into computer or laptop
3.After installation open rufus, fallow the below option :-

device : select your usb drive
Boot selection : choose the centos 9 iso file.'
partion scheme : choose GPT for UEFI or MBR for Legacy bios
filesystem : FAT32(FILE Allocation TABLE) click start ,now you have ready bootable usb-device.

step2: Configure BIOS/UEFI Settings

1.Restart your machine press f2,f12,Esc based on the system model.
2.find the bootable order or boot priority setting ,enable usb boot ,set as usb drive are first boot options.
3.enable boot mode - Legacy Mode /UEFI mode
4.Disable secure boot if enabled
5.save and exit F10

*step3: start installation:-
*

  1. Insert the bootable USB and restart your pc now your machine start from bootable pen drive.

i. Now display show like this

Image description

choose the install centos stream 9

ii. choose your language

Image description

iii. Setup date and time, keyboard layout and language

Image description

Image description

iv. choose your location

Image description

v. setting up software options server whith GUI
as per below image.

Image description

Image description

vi. Installation Destination:-

Now i choose Automatic ,u can choose also custom(Recommended) if you not already available disk, network& host part skip now later we will discuses.
if you choose custom:-

Image description

  1. /boot = Directory store all boot configuration related files & Linux kernels relate file

Example:-
/boot/vmlinuz-5.14.0-70.el9.x86_64
/boot/initramfs-5.14.0-70.el9.x86_64.img
/boot/grub2/grub.cfg (GRUB configuration)
/boot/efi/EFI/centos/grubx64.efi (If using UEFI)
2.Swap

when you physical ram is full , Linux moves inactive data to swap area, it prevent your system crash and keep process running ,when ram is free now data move back from swap to ram.
3./ (Root)

head/parent of the all directory in the Linux. All important files and application ,configuration save this location.

4./home
Directory contain user related files and documents and personal data.

Image description

Image description

vii. user creation & root password set:-

Image description

Image description

Image description

Image description

viii. GNOME at Boot:-

once you reboot system, CLI appear on the screen, login with user and passwd then CLI to GUI change for the below command

$su
=># systemctl enable --now gdm

Image description

Linux Introduction-II

By: Prasanth
26 March 2025 at 16:45

Table of Contents:

1.Linux Architecture
2.Linux vs unix
3.Linux Distro
4.Booting Process

1.Linux Architecture

Image description

1. Hardware Layer


*The hardware layer is base of the Linux
architecture, it contain all the physical parts of a computer for example CPU , Ram , Storage, i/o device. The linux kernel communicates withe hardware using device drivers to control the physical parts.

2. Kernel Layer


*Linux kernel is a core part of the operating system
It acts as a bridge between hardware and software. It directly interacts with the hardware and manages system resources like CPU, memory, and devices.
*users give commands to the shell and the shell processes these commands the by interacting with the kernel .
example, if you runs ls, the kernel requests the file system to get file information from the hard disk.
Types

  1. Monolithic kernel
  2. Micro kernel
  3. Hybrid kernle.

3. Shell Layer

* shell in linux is a command line interface that allow to user interact withe operating system . It Acts as bridge b/w the user and kernel
Type:

1.Bash - default shell used to linux globally
2.Zsh(Z shell) - extended version of Bash shell like auto suggestion
3.fish(fish shell - it provides auto suggestion and web based config.
4.c shell - work like c programming ,mainly used developers

for real case work example

$cat /etc/shells - show only you installed shells
$echo #SHELL -show current shell
$chsh -s /bin/youinstalledshellname

4. User Applications Layer


include all programs and utilites(small programme or tool that help user perform specfic task like ls,cp,ping,top,ps)

2.Linux vs unix

Origin:-
Linux -Created by Linus Torvalds (1991)

Unix -Developed by AT&T Bell Labs (1970s)
License:-
Linux - Open-source & free (GPL)

Unix - Mostly proprietary (licensed)& paid

Usage:-
Linux -Used in PCs, servers, mobile (Android)
Unix - Used in enterprises, mainframes(big companies (like banks, telecoms, government)

Shell Support:-
Linux - Bash, Zsh, Fish, etc.
Unix - Bourne Shell, C Shell, Korn Shell

File System:-
Linux - ext4, XFS, Btrfs... etc

Unix - UFS, JFS, ZFS .... etc

Hardware Support:-
Linux - Runs on all devices (PCs, ARM, etc.)
ARM is type of process used in mobile,tablet,computer.
Unix - Runs on specific hardware (IBM, HP)

Strong security, frequent updates
Linux - gets regular update and fix the security issues and performance
Unix - very secure and less updates

Performance:-
Linux - high performece and flexible(code-chage and install different software and use may device)
Unix - less flexible and run on specific hardware

Examples:-
Linux - ubuntu ,Red hat,fedora,arch
Unix - AIX,HP-UX,solaris,macos

*3.Linux Distro
*

  1. Ubuntu - ubuntu.com
  2. Debian - debian.org
  3. Fedora - getfedora.org
  4. Arch Linux - archlinux.org
  5. Linux Mint - linuxmint.com
  6. openSUSE - opensuse.org
  7. Manjaro - manjaro.org
  8. Kali Linux - kali.org
  9. CentOS - centos.org
  10. Rocky Linux - rockylinux.org

4.Booting Process

i. BIOS/UEFI (Basic input/output system):-

Bios is firmware(means something does not change) store on a non-volatile memory chip on the motherboard that initialize and tests hardware components when a computer is powered on. It also loads the operating system. firmware it stored in a type of rom (read only memory) called firmware ,simply say firmware is written on to the Rom (Read only memory) during manfacturing ,it cannot be alteret,updated or erased later, permantely fixed in the memory.Now current environment used EEPROM(Electrically Erasable Programmable Read -only memory) or flash memory.

Functions of BIOS:

1.POST (Power-On Self-Test) – Checks if hardware components (CPU, RAM, storage,hardware ...etc) are working correctly.if any problem occurred (for example hdd not connect propery in motherboard,ram dust and not detect) show like beeps or error code.

2.Bootstapping (boot process) -find and load the os from storage into ram.

3.Harwae initalization - configure and initialize system hardware before os take the control.

4.Bios setup utility - allows users to configure system settings (boot order,secure boot ,bios password set)

5.basic i/o operations - acts as an interface b/w the os and hardware.

Types of Bios:-

*Legacy Bios _ older system used , it support only MBR partitioning and 16 bit interface( 16 bit processor) not support to GPT, user interface text-based ,keyboard-only, storage support 2.2 TB and 4 primary partition ,basic password protection and slower boot time.
UEFI - (Unified Extensible Firmware Interface)
*Now modern system used UEFi , user interface support graphical and keyboard ,mouse. operating system used 32 64 bit processor , storage support 18 exabyte and 128 partition. security boot ,advanced security feature, faster boot time.

  • search the bootloader in the MBR if bios otherwise UEFI means GPT. bios passes the control bootloader.

ii. Bootloader (GRUB, LILO, etc.)

  • MBR is responsible for loading and executing the grub boot loader ,let we discuss depth , GRUb(GRand Unified Bootloader) is bootloader used in Linux sysem to load the operating system into primary memory RAM when computer starts. it is the first software that after runs firmware(BIOS/UEFi) complete the hardware initialization.

stage 1:(MBR/EFI Execution)
BIOS/UEFI load the first stage o GRUp the MBR if

BIos (or) EFI system partion for UEFI.
MBR fist stage 512 bytes in the boot disk

stage 2:(Loading Kernel & initrd)

GRUB Loads the kernel (vmlinuz) into ram .
vmlinuz = "Virtual Memory LINUx gZip-compressed"
*It is the compressed Linux kernel used for booting the system and also GRUB load the initrd(initial ram disk ) or initramfs(initial Ram Filesystem),which contains essential drivers and tools,
initrd(old)/initramfs(modern) temporary root filesystem load into ram by the bootloader like grub, before then mount root filesystem (mount attach(connect) ,umount detach(disconnect),initramfs not need to mounted like initrd,load the directely in the ram.

*The main GRUB menu is displayed here,
You can select the operating system or kernel version,
If you no selected , it will boot the default OS automatically.
Passes control to the kernel.ck3(custom file)

Kernel Initialization

  • The kernel starts execution and mount the root file system read only mode , it runs systemd/init process , start the essential sevices, you can check the Linux os first prosses(pid) is systemd using top command.

    • systemd is system manager it manage sytem services and control the run levels and so on.

*kernel manage the system resource(cpu,memory,device) and hardware components.

System Initialization (systemd/init)

*Systemd starts all required services and daemons (e.g., networking, logging).
*The kernel starts the init system (older Linux) or systemd (modern Linux).
*Systemd is the first process (PID 1) that manages system services.

  • It manages runlevels (SysVinit(older)) or targets (systemd) to start necessary services: 1.Networking 2.Filesystem mounting 3.Daemons (background services) 4.Login services

Runlevel/Target Execution

OldRunlevesl(SYsVinit)

runlevel
0 shutdown
1 singel user mode (resuce mode)
2 multi user mode (no networking)
3 multi user mode (with networking,CLI)
4 unused/custom mode
5 multi user mode with gui
6 reboot

example :
bash
$ runlevel
$ init 0

New Targets (systemd)

poweroff.target => Equivalent to Runlevel 0 (Shutdown)
rescue.target => Equivalent to Runlevel 1 (Single-user mode)
multi-user.target => Equivalent to Runlevel 2 & 3 (CLI, Networking)
graphical.target => Equivalent to Runlevel 5 (GUI mode)
reboot.target => Equivalent to Runlevel 6 (Reboot)

example :
bash
$ systemctl get-default (check runlevel)
$ systemctl isolate poweroff.target
$ systemctl set-default reboot.target
(isolate -temporary)
(set-default - permanent )

*Login Prompt (getty)
*

Displays a CLI login (TTY) or a Graphical Login (GDM/KDM).Allows the user to log in and access the system.
example:
$who
TTY column
tty1 - local terminal
pts/0 - remote ssh sessions1
pts/1 -remote ssh sessions2

Reference
https://medium.com/%40gangulysutapa96/6-stages-of-linux-boot-process-5ee84265d8a0
https://www.thegeekstuff.com/2011/02/linux-boot-process/
https://www.freecodecamp.org/news/the-linux-booting-process-6-steps-described-in-detail/
https://www.geeksforgeeks.org/linux-vs-unix/
https://www.linuxjournal.com/content/unix-vs-linux-what-is-the-difference
https://www.diffen.com/difference/Linux_vs_Unix

Introduction to Linux

By: Prasanth
25 March 2025 at 08:59

Reference Book: Linux Administration A Beginner's Guide
*Author * : Wale Soyinka

Linux: The operating system:-

  • Linux is an open-source operating system; it contains a kernel, and that kernel is the heart of Linux. The kernel operates the hardware components (RAM, CPU, storage device, and input/output devices) and manages system resources, for example, files, processors, memory, devices, and networks.
  • The kernel is a nontrivial program; it means complex, significant, and not easy to implement.
  • Linux: All distros use different customized versions of the kernel, but core functionality is the same for all distros, such as file management, processing, and networking.
  • Linux distro RHEL, Fedora, Debian, Ubuntu, CentOS, Arch...etc. Linux differentiates two categories. One is commercial (supported by vendor company distro longer release life cycle; it means support and update for a long year with a paid subscription); another one is uncommercial (free), managed by the open source community with a short year release.
  • The open source (uncommercial) and commercial Linux distros are interconnected because commercial companies support free distros as testing grounds. Most Linux software is developed by independent contributors, not the company side.

kernel differences:-

Each company sells its own developed distro and customizes the kernel. The company says that its kernel is better than the others. Why say it is better than other kernels? Most of the company and vendor companies stay updated with patches that are posted on www.kernel.org, the "Linux Kernel Archives." However, the vendor company does not track the release of the single kernel version released on wwe.kernel.org; instead of applying the custom patches to it to run the kernel quality assurance process, it tells the production is ready to help the commercial customer; it makes them confident. Any exception that occurs on the kernel-related vendor team immediately takes the action and fixes the issue, so every vendor maintains its own patch maintenance. Every vendor makes its own market strategies in the traditional environment, and the distro is designed as per the user's requirements, like making the kernel version customizable for purposes such as desktop, server, and enterprise.

The GNU Public License:-

In 1980, Richard Stallman was the founder of the Free Software Movement and the initiator of the GNU Project.

Richard Stallman is quoted as saying:

“Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech,” not as in “free beer.”

  • The main goal of giving away source code is freedom and flexibility. The user should have control over the software; the user cannot depend on the developer or officials. Open source's main goal is that anyone can modify and improve it. The advantage of open-source software is that it allows the community user with necessary skills to collaborate and add new features and contribute to improving software for the benefit of everyone.

  • The Gnu project is the GNU public license (GPL); it means any GPL software anyone can view the source code, edit, reconstruct, release the full source code, sell, and get profit, but one condition is the GPL editable version released under the GPL license. Other licenses are there, such as BSD and Apache, that have similar rules but differ in terms and redistribution. For the BSD license, anyone can change the source code and use it. You can hide that you made changes to keep it private from others, but GPL is not allowing this term. You must showcase what you modified in the software. You can see more related info from www.opensource.org.

Upstream and Downstream:-

  • Upstream is a source code of original project where the code is first developed , you take the code for open source project and modify it, original upstream means for example you buy the normal veg pizza in a pizza shop you gathered all ingrediencies info take it and make it new version chesses pizza include your ingrediency.

  • Downstream is modify version of code ,the project use, modify, extend the upstream code , you can take the opensource project build your own version your project is downstream. Key points is changes made upstream it affect downstream project for example Linux kernel upstream source code for the many Linux distro, ubuntu, fedora ,downstream project do not go back the upstream.

Single Users vs. Multiple Users vs. Network Users

  • window was originally designed purpose is one time one user can work in window . two people can not work with co incidentally at a time .Linux is support multiuser environment ,it means two user work single time multiuser environment in Linux.
  • Network user and server client model for both Linux and windows provide services like database example sql, mysql, postgresql over a network ,from windows designed for client and server communication with restrictive and Linux flexible ,any program run remotely with admin permission.

The Monolithic Kernel and the Micro-Kernel:-

The kernel has three different types of use in operating systems. One is a monolithic kernel, everything inside of a single program, like Unix and Linux. The second one is a micro-kernel, a limited core set of services needed to implement the operating system example window. The third one is a hybrid; it combines the first two kernels. The current industry uses a Windows hybrid kernel. The Windows kernel provides a small set of services that interface with other executive services like process and I/O management.

Domains and Active Directory:-

  • AD is a centralized device; it manages authentication and authorization for the domain. The domain synchronization model means that the domain controller checks everything for up-to-date information. DNS style, It means following the root domain and child domain architecture; for example, abc.com is the root domain, and it. ABC.com and sales.ABC.com as child domains; each domain maintains its own user and computer, but it is part of the root domain network.-
  • Linux does not have tightly coupled (components do not depend on each other directory) authentication/authorization. Linux handles authentication used for the PAM pluggable authentication module; it means multiple authentication methods follow. Name resolution libraries help Linux find and verify user and group information from different sources, like local files, LDAP, and NIS.-
  • Authentication option is linux, flat files basic authentications using /etc/passwd and /etc/shadow, NIC used to older network for centralized authentication ,LDAP (Lightweight Directory Access Protocol) work like AD but is open source, Kerberos secure authentication using tickets, Samba and Ad it allows to authenticate against windows domain.

Setting Up Kubernetes and Nginx Ingress Controller on an EC2 Instance

By: Ragul.M
19 March 2025 at 16:52

Introduction

Kubernetes (K8s) is a powerful container orchestration platform that simplifies application deployment and scaling. In this guide, we’ll set up Kubernetes on an AWS EC2 instance, install the Nginx Ingress Controller, and configure Ingress rules to expose multiple services (app1 and app2).

Step 1: Setting Up Kubernetes on an EC2 Instance
1.1 Launch an EC2 Instance
Choose an instance with enough resources (e.g., t3.medium or larger) and install Ubuntu 20.04 or Amazon Linux 2.
1.2 Update Packages

sudo apt update && sudo apt upgrade -y  # For Ubuntu 

1.3 Install Docker

sudo apt install -y docker.io  
sudo systemctl enable --now docker

1.4 Install Kubernetes (kubectl, kubeadm, kubelet)

sudo apt install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubelet kubeadm kubectl

1.5 Initialize Kubernetes

sudo kubeadm init --pod-network-cidr=192.168.0.0/16

Follow the output instructions to set up kubectl for your user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

1.6 Install a Network Plugin (Calico)

For Calico:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

Now, Kubernetes is ready!

Step 2: Install Nginx Ingress Controller
Nginx Ingress Controller helps manage external traffic to services inside the cluster.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml

Wait until the controller is running:

kubectl get pods -n ingress-nginx

You should see ingress-nginx-controller running.

Step 3: Deploy Two Applications (app1 and app2)
3.1 Deploy app1
Create app1-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
    spec:
      containers:
      - name: app1
        image: nginx
        ports:
        - containerPort: 80

Create app1-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: app1-service
spec:
  selector:
    app: app1
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: ClusterIP

Apply the resources:

kubectl apply -f app1-deployment.yaml 
kubectl apply -f app1-service.yaml

3.2 Deploy app2
Create app2-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app2
spec:
  replicas: 2
  selector:
    matchLabels:
      app: app2
  template:
    metadata:
      labels:
        app: app2
    spec:
      containers:
      - name: app2
        image: nginx
        ports:
        - containerPort: 80

Create app2-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: app2-service
spec:
  selector:
    app: app2
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
  type: ClusterIP

Apply the resources:

kubectl apply -f app2-deployment.yaml 
kubectl apply -f app2-service.yaml

Step 4: Configure Ingress for app1 and app2
Create nginx-ingress.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: app1.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
  - host: app2.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80

Apply the Ingress rule:

kubectl apply -f nginx-ingress.yaml

Step 5: Verify Everything
5.1 Get Ingress External IP

kubectl get ingress

5.2 Update /etc/hosts (Local Testing Only)
If you're testing on a local machine, add this to /etc/hosts:

<EXTERNAL-IP> app1.example.com
<EXTERNAL-IP> app2.example.com

Replace with the actual external IP of your Ingress Controller.
5.3 Test in Browser or Curl

curl http://app1.example.com
curl http://app2.example.com

If everything is set up correctly, you should see the default Nginx welcome page for both applications.

Conclusion
In this guide, we:

  • Installed Kubernetes on an EC2 instance
  • Set up Nginx Ingress Controller
  • Deployed two services (app1 and app2)
  • Configured Ingress to expose them via domain names

Now, you can easily manage multiple applications in your cluster using a single Ingress resource.

Follow for more . Happy learning :)

Lulu Mall: More Than Shoppings — A Business Viewpoint

Lulu Mall: More Than Shoppings🛒 — A Business Viewpoint

Source: https://www.kochi.lulumall.in/

“Use people’s laziness and become rich.”

If someone can capitalize on people’s laziness, they can become rich. By providing comfort and convenience, businesses can charge premium prices — and people are willing to pay. Swiggy and Zomato are prime examples of this business model.

Hi everyone 👋! Last week, I visited Kerala, exploring Vagamon and Kochi. It was an experience filled with beautiful memories. During this trip, I visited the famous Lulu Mall. Ever since I was a child, I’ve been intrigued by the business strategies behind places and events, and Lulu Mall was no exception.

We all know that for middle-class people, shopping at a mall may not always fit their budget. I realized this during my visit to Chennai’s Phoenix Market City Mall, and I had the same thoughts while visiting Lulu Mall.

🔍 Interesting Business Insights I Observed at Lulu Mall

1. Premium Enjoyment for Kids Lulu Mall’s indoor amusement area offers attractions like the Roller Coaster, Ferris Wheel, and Cine Coaster. It also features arcade games and VR experiences. I noticed many kids enjoying themselves here — it truly is an exciting place for them. However, these premium rides and games come at a high cost. While the enjoyment is top-notch, it’s clearly a premium experience designed to encourage spending.

Source: Own Phone Camera | Samsung M34

2. The Food Court Strategy On the third floor, Lulu Mall presents a diverse range of dining options. A subtle but clever observation I made was the pricing strategy: food outlets near the escalators charge higher prices due to increased foot traffic, while those located farther away offer comparatively lower rates. This model successfully capitalizes on customer behavior and convenience.

Source: Own Phone Camera | Samsung M34

3. Strategic Store Placement The mall’s layout is meticulously designed with anchor stores like Lulu Hypermarket and PVR Cinemas placed at strategic locations. This encourages visitors to walk through the entire mall, exposing them to other shops along the way. It’s a smart way to boost foot traffic and create opportunities for impulse purchases, benefiting both large and small retailers.

4. Seasonal Themes and Promotions To attract repeat visitors, Lulu Mall frequently adopts seasonal promotions and festive decorations. Events such as cultural festivals, sales, and themed displays keep the mall lively and engaging. This ensures that customers always have a reason to return.

5. Focus on Luxury and Aspirational Brands Lulu Mall caters to a broad demographic by offering both essentials for middle-class families and high-end luxury brands. This balance attracts a wide customer base, including those looking to indulge occasionally in premium experiences. It’s a strategy that drives sales while maintaining the mall’s aspirational appeal.

6. Catchy quotes help to keep the brand in customers’ minds. There are numerous examples of this. Each shop in the mall uses advertisements with a quote. These quotes are strategically placed in the mall by the shops.

Source: Own Phone Camera | Samsung M34

❓ A Fun Question:

I’ve yet to try burgers or pizza — what do they taste like? Can you compare them to South Indian dishes like Sambar Rice with Potato Fry, Rasam with Potato Fry, or Biryani? I’d love to hear your thoughts!

Alright, guys, that’s it for this blog. Oh, and one more thing! Today, I’ve been on a blogging spree. If you have time, don’t forget to check out my latest post on Emacs & Org Mode in Windows.”

When you feel this content is valuable, follow me for more upcoming Blogs.

Connect with Me:

Emacs & Org Mode in Windows

Source: OpenSource.com
Note: I am not an expert in Emacs and Org Mode. But I have always loved exploring tech, coding, and finance. This blog is about my journey of exploring Emacs and Org Mode for Static Site Generation using Windows.

When I first know about “Static Site Generation” as a developer, I was amazed. Normally, we develop websites using HTML, and even when using other frameworks, HTML serves as the foundation. But in Static Site Generation, markup languages like Markdown, Org Mode, and others are used. These are then converted into HTML through scripting languages or tools like Emacs, Hugo, and more. This concept was totally new to me!

To be honest, I was astonished when I first heard about it from my brother, Thanga Ayyanar. He exclusively uses Org Mode to maintain his website and blogs. Inspired by his approach, I wanted to learn, use, and explore this tool for myself, and I like to work on Thanga Ayyanar’s website(golayan.in). I also took the opportunity to work on the UI. However, there was one condition from Thanga Ayyanar. They strictly required that I only use HTML and CSS. It was a slight headache, but a challenge I embraced with love.

I aim to host this project soon, and once I do, I will attach the link in this blog below. The challenge, though, is that while Emacs works wonderfully in Linux, I primarily use Windows due to storage constraints. I am unable to use both Windows & Linux like previously on my laptop. Despite this, my curiosity about Emacs and Org Mode drove me to explore them further.

I initially referred to ChatGPT, Perplexity, and Gemini AI for guidance, but their suggestions weren’t helpful enough. Eventually, I discovered my way forward:

Source: freeCodeCamp.org
  1. Since I am comfortable using VS Code, I downloaded the Org Mode extension for it.
  2. I then downloaded and installed the latest version of Emacs from:

3. To build the site, to convert from org to HTML. I ran the following command:

emacs --script build-site.el

4. Finally, I used Python to serve the site locally:

cd public python -m http.server

Then, I went through the code and began to understand how Emacs & Org work . Then how it converts the Org to HTML. I understand the whole process slightly. But, till I have full awareness of Emacs & Org.

Then, I started working on Thanga Ayyanar’s website’s CSS, striving to make it visually appealing. The UI reflects their name in gold, paired with a dark theme. Since Ayyanar bro prefers dark red & gold, I used it for ::selection. You can check out the code I wrote for the website here: https://github.com/anandsundaramoorthysa/goldayan.github.io

This blog is a brief account of my journey into exploring Emacs, Org Mode, and figuring out how to use them on Windows. Initially, it was somewhat challenging, much like when I began learning Python back in 2022. However, as with any skill, it gradually became easier with time and persistence.

When you feel this content is valuable, follow me for more upcoming Blogs.

Connect with Me:

How to Manage Multiple Cron Job Executions

16 March 2025 at 06:13

Cron jobs are a fundamental part of automating tasks in Unix-based systems. However, one common problem with cron jobs is multiple executions, where overlapping job runs can cause serious issues like data corruption, race conditions, or unexpected system load.

In this blog, we’ll explore why multiple executions happen, the potential risks, and how flock provides an elegant solution to ensure that a cron job runs only once at a time.

The Problem: Multiple Executions of Cron Jobs

Cron jobs are scheduled to run at fixed intervals, but sometimes a new job instance starts before the previous one finishes.

This can happen due to

  • Long-running jobs: If a cron job takes longer than its interval, a new instance starts while the old one is still running.
  • System slowdowns: High CPU or memory usage can delay job execution, leading to overlapping runs.
  • Simultaneous executions across servers: In a distributed system, multiple servers might execute the same cron job, causing duplication.

Example of a Problematic Cron Job

Let’s say we have the following cron job that runs every minute:

* * * * * /path/to/script.sh

If script.sh takes more than a minute to execute, a second instance will start before the first one finishes.

This can lead to:

✅ Duplicate database writes → Inconsistent data

✅ Conflicts in file processing → Corrupt files

✅ Overloaded system resources → Performance degradation

Real-World Example

Imagine a job that processes user invoices and sends emails

* * * * * /usr/bin/python3 /home/user/process_invoices.py

If the script takes longer than a minute to complete, multiple instances might start running, causing

  1. Users to receive multiple invoices.
  2. The database to get inconsistent updates.
  3. Increased server load due to excessive email sending.

The Solution: Using flock to Prevent Multiple Executions

flock is a Linux utility that manages file locks to ensure that only one instance of a process runs at a time. It works by locking a specific file, preventing other processes from acquiring the same lock.

Using flock in a Cron Job

Modify the cron job as follows

* * * * * /usr/bin/flock -n /tmp/myjob.lock /path/to/script.sh

How It Works

  • flock -n /tmp/myjob.lock → Tries to acquire a lock on /tmp/myjob.lock.
  • If the lock is available, the script runs.
  • If the lock is already held (i.e., another instance is running), flock prevents the new instance from starting.
  • -n (non-blocking) ensures that the job doesn’t wait for the lock and simply exits if it cannot acquire it.

This guarantees that only one instance of the job runs at a time.

Verifying the Solution

You can test the lock by manually running the script with flock

/usr/bin/flock -n /tmp/myjob.lock /bin/bash -c 'echo "Running job..."; sleep 30'

Open another terminal and try to run the same command. You’ll see that the second attempt exits immediately because the lock is already acquired.

Preventing multiple executions of cron jobs is essential for maintaining data consistency, system stability, and efficiency. By using flock, you can easily enforce single execution without complex logic.

✅ Simple & efficient solution. ✅ No external dependencies required. ✅ Works seamlessly with cron jobs.

So next time you set up a cron job, add flock and sleep peacefully knowing your tasks won’t collide. 🚀

Deploying a Two-Tier Web Application on AWS with MySQL and Apache

By: Ragul.M
12 March 2025 at 12:46

In this blog, I will guide you through step-by-step instructions to set up a two-tier architecture on AWS using VPC, Subnets, Internet Gateway, Route Tables, RDS, EC2, Apache, MySQL, PHP, and HTML. This project will allow you to host a registration web application where users can submit their details, which will be stored in an RDS MySQL database.

Step 1: Create a VPC
1.1 Login to AWS Management Console

  • Navigate to the VPC service
  • Click Create VPC
  • Enter the following details:
  • VPC Name: my-vpc
  • IPv4 CIDR Block: 10.0.0.0/16
  • Tenancy: Default
  • Click Create VPC

Image description

Step 2: Create Subnets
2.1 Create a Public Subnet

  • Go to VPC > Subnets
  • Click Create Subnet
  • Choose my-vpc
  • Set Subnet Name: public-subnet
  • IPv4 CIDR Block: 10.0.1.0/24
  • Click Create

2.2 Create a Private Subnet
Repeat the steps above but set:

  • Subnet Name: private-subnet
  • IPv4 CIDR Block: 10.0.2.0/24

Image description

Step 3: Create an Internet Gateway (IGW) and Attach to VPC
3.1 Create IGW

  • Go to VPC > Internet Gateways
  • Click Create Internet Gateway
  • Set Name: your-igw
  • Click Create IGW 3.2 Attach IGW to VPC
  • Select your-igw
  • Click Actions > Attach to VPC
  • Choose my-vpc and click Attach

Image description

Step 4: Configure Route Tables
4.1 Create a Public Route Table

  • Go to VPC > Route Tables
  • Click Create Route Table
  • Set Name: public-route-table
  • Choose my-vpc and click Create
  • Edit Routes → Add a new route:
  • Destination: 0.0.0.0/0
  • Target: my-igw
  • Edit Subnet Associations → Attach public-subnet

Image description

Step 5: Create an RDS Database (MySQL)

  • Go to RDS > Create Database
  • Choose Standard Create
  • Select MySQL
  • Set DB instance identifier: my-rds
  • Master Username: admin
  • Master Password: yourpassword
  • Subnet Group: Select private-subnet
  • VPC Security Group: Allow 3306 (MySQL) from my-vpc
  • Click Create Database

Image description

Step 6: Launch an EC2 Instance

  • Go to EC2 > Launch Instance
  • Choose Ubuntu 22.04
  • Set Instance Name: my-ec2
  • Select my-vpc and attach public-subnet
  • Security Group: Allow
  • SSH (22) from your IP
  • HTTP (80) from anywhere
  • MySQL (3306) from my-vpc
  • Click Launch Instance

Image description

Step 7: Install Apache, PHP, and MySQL Client
7.1 Connect to EC2

ssh -i your-key.pem ubuntu@your-ec2-public-ip

7.2 Install LAMP Stack

sudo apt update && sudo apt install -y apache2 php libapache2-mod-php php-mysql mysql-client

7.3 Start Apache

sudo systemctl start apache2
sudo systemctl enable apache2

Step 8: Configure Web Application
8.1 Create the Registration Form

cd /var/www/html
sudo nano index.html
<!DOCTYPE html>
<html>
<head>
    <title>Registration Form</title>
</head>
<body>
    <h2>User Registration</h2>
    <form action="submit.php" method="POST">
        Name: <input type="text" name="name" required><br>
        DOB: <input type="date" name="dob" required><br>
        Email: <input type="email" name="email" required><br>
        <input type="submit" value="Register">
    </form>
</body>
</html>

Image description

8.2 Create PHP Script (submit.php)

sudo nano /var/www/html/submit.php
<?php
$servername = "your-rds-endpoint";
$username = "admin";
$password = "yourpassword";
$dbname = "registration";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$name = $_POST['name'];
$dob = $_POST['dob'];
$email = $_POST['email'];
$stmt = $conn->prepare("INSERT INTO users (name, dob, email) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $dob, $email);
if ($stmt->execute()) {
    echo "Registration successful";
} else {
    echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>

Image description

Step 9: Create Target Group

  1. Go to the AWS EC2 Console → Navigate to Target Groups
  2. Click Create target group
  3. Choose Target type: Instance
  4. Enter Target group name: my-target-group
  5. Select Protocol: HTTP
  6. Select Port: 80
  7. Choose the VPC you created earlier
  8. Click Next
  9. Under Register Targets, select your EC2 instances
  10. Click Include as pending below, then Create target group

Image description

Image description

Step 10: Create an Application Load Balancer (ALB)

  1. Go to AWS EC2 Console → Navigate to Load Balancers
  2. Click Create Load Balancer
  3. Choose Application Load Balancer
  4. Enter ALB Name: my-alb
  5. Scheme: Internet-facing
  6. IP address type: IPv4
  7. Select the VPC
  8. Select at least two public subnets (for high availability)
  9. Click Next

Image description

Step 11: Test the Application

  1. Restart Apache sudo systemctl restart apache2
  2. Open your browser and visit: http://your-ec2-public-ip/
  3. Fill in the form and Submit
  4. Check MySQL Database:
mysql -u admin -p -h your-rds-endpoint
USE your_database;
SELECT * FROM table_name;

Image description

This setup ensures a scalable, secure, and high-availability application on AWS! 🚀

Follow for more and happy learning :)

Write a video using open-cv

By: krishna
11 March 2025 at 13:30

Use open-cv VideoWriter function to write a video

Source Code

import cv2

video = cv2.VideoCapture("./data/video.mp4")
fourcc = cv2.VideoWriter.fourcc(*'FMP4')
writeVideo = cv2.VideoWriter('./data/writeVideo.mp4',fourcc,24,(1080,720))

while(video.isOpened()):
    suc, frame = video.read()
    if(suc):
        frame = cv2.resize(frame,(1080,720))
        cv2.imshow("write video",frame)
        writeVideo.write(frame)
        if(cv2.waitKey(24)&0xFF == ord('q')):
            break
    else:
        break

writeVideo.release()
video.release()
cv2.destroyAllWindows()

Video

Pre-Required Knowledge

If you know OpenCV, you can use it to open a video. If you don’t know this, visit this open video blog.

Functions

Explain Code

Import open-cv Library import cv2
Open a Video Using videoCapture Function

fourcc

The fourcc function is used to specify a video codec.
Example: AVI format codec for XVID.

VideoWriter

The videoWriter function initializes the writeVideo object. it specify video properties such as codec, FPS, and resolution.
There are four arguments:

  1. Video Path: Specifies the video write path and video name.
  2. fourcc: Specifies the video codec.
  3. FPS: Sets an FPS value.
  4. Resolution: Sets the video resolution.

The read() function is used to read a frame.

After reading a frame, resize() it.
Note: If you set a resolution in writeVideo, you must resize the frame to the same resolution.

write

This function writes a video frame by frame into the writeVideo object.

The waitKey function is used to delay the program and check key events for program exit using an if condition.

Release objects

Once the writing process is complete, release the writeVideo and video objects to finalize the video writing process.

Additional Link

github code

How Failure Feels?

Source: CanvaGPT AI

Like hell…Failure is just a part of life — an unskippable, teaching part. But when we fail once, twice, and even three times, we tackle that pain. But how is it to fail 98 out of 100 times? How does it feel?

Hi guys, 👋 today I’d like to share my feelings about failures in life and how I try to tackle them. To be frank, I’m not an expert, but I will share my experience.

We are not superheroes who can tackle all issues simply. Even superheroes failed in both comics and movies.

How do you feel about failures?

The feelings should be like “Our eyes are darkened, our mind is frustrated, our body is not in our control,” right? Even I have the same mentality when I fail. But continuous failure should be an unexplainable hell moment. We try something, we don’t enjoy life like others, we don’t have our meals perfectly, we don’t go to the ground to play games — we sacrifice all for the purpose. The purpose can be anything, like studying, learning, developing, coding, designing, editing, reading, or anything else. But what if we don’t win? If there is no difference between the life of others and us? How do they feel?

In one word, hell, right?

Trying many things without rest, like freelancing, developing, writing, designing, editing, approaching jobs and intern roles, and even podcasting, with the desire to shine anywhere. But zero output or an output without any financial benefits. How does it feel?

In one word, hell, right?

In the past, I was in the same situation as you, like all of us.

How to Tackle?

I have two simple solutions. But first, what do we need to do?

The first important thing is to throw your phones away or switch them off. When parents call us at that time, the situation becomes worse, or we call them unnecessarily and scold them. So the first advisable thing is to switch off the phones.

First Way: Write that pain on a piece of paper, then throw it in the dustbin after completing it. Even type it on a computer, then erase the file. Even a WhatsApp Status. It all depends on you.

Second Way: Don’t make any decisions at that time. Make yourself alone, cry until you become cool, then don’t plan anything, don’t do anything. Life will give you a way — just travel on that way.

Personally, I follow both of these methods.

At one moment, I felt like “I was not a good developer. In the upcoming days, I didn’t touch my laptop. I have not coded and developed any webpage”. But a few days after, a work came from my friend for web development. At first, I didn’t like to code and develop in the moment. But, after starting, I enjoy it. One of the quotes from my mother is, “When it’s for you, it must come”.

When I am in the confusion stage, I should carry on as a developer or move on to any other role in IT. I just imagine myself without development. It feels bad. Then I understood. I Love to develop. I only love to develop. So I decide, I achieve or not. Join in Big Jaint companies or not. But I should not leave from the development journey.

So, failure hurts. But it hurts more and more in the way of not being faced. Just move on as a traveller in the life giving way. I hope by the blog I share the moment of “How failure feels?”

If you feel it is true and useful idea to tackle that failure. Just comment your thoughts below 👇

When you feel this content is valuable, follow me for more upcoming Blogs.

Connect with Me:

❌
❌