Wednesday, October 1, 2025

Moving apace, mariadb and php project from a debian site to other debian site

I want to create a bash script to backup and restore the project (apache, mariadb and php) easily. I need to work at 2 debian machine with the same configuration in 2 different location. I ask to duck.ai to solve the problem. Here is the result.

Create a file myconfig.conf

# myconfig.conf
DB_NAME="your_database_name"
DB_USER="your_username"
DB_PASS="your_password"
PROJECT_ROOT="/path/to/your/php/project"  # Add this line

Create bash script mybackup.sh 

#!/bin/bash

# Load database configuration from myconfig.conf
source myconfig.conf

# Create a backup file name for the database
DB_BACKUP_FILE="${DB_NAME}_$(date +%Y-%m-%d).sql"
# Create a zip file name for the project
PROJECT_BACKUP_FILE="$(basename "$PROJECT_ROOT")_backup_$(date +%Y-%m-%d).zip"

# Function to backup the database
backup_database() {
    echo "Backing up database: $DB_NAME"
    mysqldump -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" > "$DB_BACKUP_FILE"
    if [ $? -eq 0 ]; then
        echo "Database backup successful: $DB_BACKUP_FILE"
    else
        echo "Database backup failed!"
        return 1
    fi
}

# Function to zip the project files
zip_project() {
    echo "Zipping project files from: $PROJECT_ROOT"
    zip -r "$PROJECT_BACKUP_FILE" "$PROJECT_ROOT"
    if [ $? -eq 0 ]; then
        echo "Project backup successful: $PROJECT_BACKUP_FILE"
    else
        echo "Project backup failed!"
        return 1
    fi
}

# Function to restore the database
restore_database() {
    echo "Restoring database: $DB_NAME from $1"
    mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" < "$1"
    if [ $? -eq 0 ]; then
        echo "Database restore successful!"
    else
        echo "Database restore failed!"
    fi
}

# Function to unzip the project files
unzip_project() {
    echo "Unzipping project files to: $PROJECT_ROOT"
    unzip -o "$1" -d "$PROJECT_ROOT"
    if [ $? -eq 0 ]; then
        echo "Project restore successful!"
    else
        echo "Project restore failed!"
    fi
}

# Check command line arguments
if [ "$1" == "backup" ]; then
    backup_database
    zip_project
elif [ "$1" == "restore" ]; then
    if [ -z "$2" ] || [ -z "$3" ]; then
        echo "Please provide the SQL backup file and the project zip file to restore from."
        exit 1
    fi
    SQL_BACKUP_FILE="$2"
    PROJECT_BACKUP_FILE="$3"
    restore_database "$SQL_BACKUP_FILE"
    unzip_project "$PROJECT_BACKUP_FILE"
else
    echo "Usage: $0 {backup|restore [sql_backup_file] [project_backup_file]}"
    exit 1
fi

To backup

./mybackup.sh backup

It will create 2 files

  1. zip for backup and restore web root project
  2. sql for backup and restore mariadb database 

To restore

./mybackup.sh restore your_database_backup.sql your_project_backup_file.zip

 

Tuesday, September 30, 2025

How to fix error HY000/1045 after upgrading phpmyadmin

I used Debian 13 repository to upgrade phpmyadmin. During upgrading from previous version, configuration can not be continue and must be ignore. After phpmyadmin installed error messages come to web:

  • mysqli::real_connect(): (HY000/1045): Access denied for user 'phpmyadmin'@'localhost' (using password: YES) 
  • Connection for controluser as defined in your configuration failed.

Create user pma (default) and password:

MariaDB [(none)]> CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.002 sec)

Edit file /etc/phpmyadmin/config-db.php

...
$dbuser='pma';
$dbpass='pmapass';
...

Edit file /etc/phpmyadmin/config.inc.php

...
/* Configure according to dbconfig-common if enabled */
if (!empty($dbname)) {
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    /* Server parameters */
    if (empty($dbserver)) $dbserver = 'localhost';
    $cfg['Servers'][$i]['host'] = $dbserver;

    if (!empty($dbport) || $dbserver != 'localhost') {
        $cfg['Servers'][$i]['connect_type'] = 'tcp';
        $cfg['Servers'][$i]['port'] = $dbport;
    }
    //$cfg['Servers'][$i]['compress'] = false;
    /* Optional: User for advanced features */
    $cfg['Servers'][$i]['controluser'] = $dbuser;
    $cfg['Servers'][$i]['controlpass'] = $dbpass;
    /* Optional: Advanced phpMyAdmin features */
    $cfg['Servers'][$i]['pmadb'] = $dbname;
    $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma__relation';
    $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
    $cfg['Servers'][$i]['history'] = 'pma__history';
    $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
    $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
    $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
    $cfg['Servers'][$i]['recent'] = 'pma__recent';
    $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
    $cfg['Servers'][$i]['users'] = 'pma__users';
    $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
    $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
    $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
    $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
    $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
    $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

    /* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

    /* Advance to next server for rest of config */
    $i++;
}

/* Authentication type */
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
//$cfg['Servers'][$i]['host'] = 'localhost';
//$cfg['Servers'][$i]['connect_type'] = 'tcp';
//$cfg['Servers'][$i]['compress'] = false;
/* Uncomment the following to enable logging in to passwordless accounts,
 * after taking note of the associated security risks. */
// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

/**
 * phpMyAdmin configuration storage settings.
 */

/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = '';
$cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
...

 

Debian 13: how to limit cpu frequency to preserve power or keep cpu cooler

Since Debian 13, cpufreq is being replaced by cpupower. Don't mix using power-profiles-daemon and linux-cpupower. I prefer to use linux-cpupower.

Install 

# apt-get install linux-cpupower

Show available frequency

# cpupower frequency-info
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 4.0 us
  hardware limits: 1000 MHz - 2.20 GHz
  available frequency steps:  2.20 GHz, 2.00 GHz, 1.80 GHz, 1.60 GHz, 1.30 GHz, 1000 MHz
  available cpufreq governors: performance schedutil
  current policy: frequency should be within 1000 MHz and 2.20 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: 1.30 GHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: no
    Boost States: 2
    Total States: 8
    Pstate-Pb0: 2500MHz (boost state)
    Pstate-Pb1: 2400MHz (boost state)
    Pstate-P0:  2200MHz
    Pstate-P1:  2000MHz
    Pstate-P2:  1800MHz
    Pstate-P3:  1600MHz
    Pstate-P4:  1300MHz
    Pstate-P5:  1000MHz

Available frequency steps are:  2.20 GHz, 2.00 GHz, 1.80 GHz, 1.60 GHz, 1.30 GHz, 1000 MHz. Use frequency 1.8 GHz for all core:

# cpupower frequency-set -u 1.80 GHz
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3

After applying maximum frequency

# cpupower frequency-info
analyzing CPU 2:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 4.0 us
  hardware limits: 1000 MHz - 2.20 GHz
  available frequency steps:  2.20 GHz, 2.00 GHz, 1.80 GHz, 1.60 GHz, 1.30 GHz, 1000 MHz
  available cpufreq governors: performance schedutil
  current policy: frequency should be within 1000 MHz and 1000 MHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: 1000 MHz (asserted by call to hardware)
  boost state support:
    Supported: yes
    Active: no
    Boost States: 2
    Total States: 8
    Pstate-Pb0: 2500MHz (boost state)
    Pstate-Pb1: 2400MHz (boost state)
    Pstate-P0:  2200MHz
    Pstate-P1:  2000MHz
    Pstate-P2:  1800MHz
    Pstate-P3:  1600MHz
    Pstate-P4:  1300MHz
    Pstate-P5:  1000MHz

To make it persistent, create or edit /etc/systemd/system/cpu-limit.service

[Unit]
Description=Set CPU power management settings
# latest state runlevel 3 in SysVinit, let CPU run maximum frequency during starting system services
After=multi-user.target
# run after network ready
#After=network.target
# network may not run
#After=sysinit.target

[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower frequency-set -u 2.00GHz
#ExecStart=/usr/bin/cpupower frequency-set --max 2.00GHz
#ExecStart=/usr/bin/cpupower frequency-set -g performance
# You can customize the cpupower command here.
# For example, to set to powersave:
# ExecStart=/usr/bin/cpupower frequency-set -g powersave
# Or to set a specific frequency:
# ExecStart=/usr/bin/cpupower frequency-set -f 2.5GHz

[Install]
WantedBy=multi-user.target

Note: you can copy paste and adjust frequency for your laptop/PC.

Change file permission

# chmod 644 /etc/systemd/system/cpu-limit.service

Reload system daemon

# systemctl daemon-reload
# systemctl enable cpu-limit.service
Created symlink '/etc/systemd/system/multi-user.target.wants/cpu-limit.service' → '/etc/systemd/system/cpu-limit.service'.

Everytime your restart this daemon will run time to set maximum frequency.

 

 

Sunday, September 28, 2025

Debian 13: Fresh install dual boot Axioo Hype 5 AMD X6 using usb flash disk with ventoy boot manager installed

Spesification Axioo Hype 5 AMD X6:

  • Ryzen™ 5 6600H & grafis Radeon™ 660M
  • 16GB DDR5 RAM & 512GB SSD Gen 3

Shrink your windows 11 partition. We need 84 GB free space. 80 GB for debian / ext4 and 4 GB for swap. We do need to reserve 500 MB for ESP (EFI System Partition), windows 11 already create it.

Use windows disk manager and shrink partition. Fill

Enter the amount of space in MB 84000 MB

It is good practice to separate partition for windows system and application, and user data partition.

To install Ventoy boot manager in flash disk follow this.

Insert your USB flash disk contain Debian 13 net installer and ventoy installed. Press and hold “Shift” and restart windows. Unpress shift after laptop restarted.

Select “Use Device” and choose USB flash disk to boot.

Ventoy boot manager will give you any iso file you stored on flash disk if any. Choose debian, select “Boot in normal mode”.

Debian installer started, follow the instruction. You need an internet connection to install the xfce desktop environment. 

At the partition section, choose “Manual”. Create 80 GB type “ext4” mount / and 4 GB type “Swap”. Write change to disk.

Beware, there is a USB flash disk appear in the partition menu. It is shown as “SCSI1 (0.0.0) (sda)” on my laptop.

In package manager, I choose 

  • Xfce
  • Standard system utility

For special purpose installation choose debian blend. Release of debian pure blend can be read on www.debian.org/blends/.

Finally, restart your laptop. Press F2 to enter bios. At boot menu, select debian boot manager first and then windows. Debian grub has the option to enter windows not vice versa.

If you wish, to select windows as default grub selection, edit /etc/default/grub

GRUB_DEFAULT=2

Save it and run

# update-grub

Friday, September 26, 2025

Debian 13: Using Ventoy to create bootable flash disk for multiple ISO

Download ventoy from www.ventoy.net, choose tar.gz. At this documentation wrote, it was ventoy-1.1.07-linux.tar.gz.

Extract it here, it will create directory ventoy-1.1.07. You can move directory from download to your home.

To avoid any typo or wrong device storage, it is recommended to use GUI. Insert you new or unused flash disk and open ventoy GUI, from terminal

$ cd ventoy-1.1.07/
$ ./VentoyGUI.x86_64&

It will ask root/sudo password. Click Install and you will get warning all data will be destroyed and flash disk will be formatted. Wait until finish.

Unmount your flash disk. Remove and reinsert your flash disk. You can add your iso file into your flash disk.

Note: Do not store your iso files too deep under subdirectory. 

Sample Directory:

Ventoy
-- debian
   -- debian-13.1.0-amd64-netinst.iso
-- windows
   -- 

Note:  size of debian-13.1.0-amd64-netinst.iso is more then 700MB which it is not fit into CD ROM anymore.

Use flash disk USB 3.0 or above. I use Adata flash disk USB 3.0.

It is hard to find CD or DVD in Indonesia.  Almost software is distribute directly from cloud, no disk media anymore. Some provide flash disk installer in part of package.

 

 

Saturday, September 20, 2025

Debian 13: solving error ring 2 stalled on HP 15-AF109AX AMD A8-7410 APU Radeon R5

Laptop:

AMD A8-7410 APU Radeon R5 GCN 1.2 (Spectre)
HP 15-AF109AX 

symptom: Screen flickering continuously at some interval  time

Dmesg error:

[ 3806.507278] radeon 0000:00:01.0: ring 2 stalled for more than 29348msec
[ 3806.507310] radeon 0000:00:01.0: GPU lockup (current fence id 0x000000000000038f last fence id 0x0000000000000390 on ring 2)

Which non free firmware? These are generation AMD Graphics Processor

Use radeon for older then GCN and RDNA

Use amdgpu for Graphic Core Next/GCN generation

  1. GCN 1.0 Radion HD 7000
  2. GCN 2.0 Radeon 200
  3. GCN 3.0 Radeon 300
  4. GCN 4.0 Radeon 400/500/600
  5. GCN 5.0 Radeon RX Vega, Radeon VII

Use  ROCm for RDNA

  1. RDNA 1 Radeon RX 5000
  2. RDNA 2 Radeon RX 6000
  3. RDNA 3 Radeon RX 7000
  4. RDNA 4 Radeon RX 8000 

Install firmware, you need add non-free repository

# apt-get install firmware-amd-graphics  

Check firmware loaded

# lspci -k | grep -A 3 VGA
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Mullins [Radeon R4/R5 Graphics] (rev 45)
    Subsystem: Hewlett-Packard Company Device 80cc
    Kernel driver in use: radeon
    Kernel modules: radeon, amdgpu

or

# lspci -nn | grep VGA

The Mullins Accelerated Processing Units (APUs), which include the Radeon R4/R5 Graphics, use the GCN 1.1 architecture.  Googling for yours if necessary. Create/Edit /etc/X11/xorg.conf.d/20-radeon.conf 

Section "Device"
    Identifier "AMD Graphics"
    Driver "amdgpu"
    Option "TearFree" "true"
EndSection

If your card is GCN 1.0 and 1.2 ("Southern Islands" or "Sea Islands" cards) , for potentially better performance and Vulkan support, you need to add kernel parameter. Edit /etc/default/grub and add parameter

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash radeon.cik_support=0 amdgpu.cik_support=1"

update grub

# update-grub update-grub

Example old AMD Graphic

  • Wrestler [Radeon HD 6310] 

google-chrome use gpu acceleration, this can also causing ring 2 stalled. Disabling google-chrome gpu accelerated.

$ google-chrome-stable --disable-gpu --disable-software-rasterizer

Create script to run start_chrome.sh

#!/bin/bash
google-chrome-stable --disable-gpu --disable-software-rasterizer "$@" &

Make it runnable

$ chmod 764 ./start_chrome.sh

 

Friday, September 19, 2025

Debian 13: using systemd-resolved to replace old way to resolving dns

Install systemd-resolved 

# apt-get install  systemd-resolved

Enable it

# systemctl enable systemd-resolved

Old fashion /etc/resolv.conf 

# Generated by NetworkManager
nameserver 45.90.28.186
nameserver 8.8.8.8
nameserver 1.1.1.1

Change/Edit configuration file /etc/systemd/resolved.conf 

DNS=45.90.28.186 8.8.8.8 1.1.1.1
DNSOverTLS=yes

Restart systemd-resolved

# systemctl restart systemd-resolved

Test it

# nslookup duckduckgo.com
Server:        127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:    duckduckgo.com
Address: 20.43.161.105

Done.  

Dig

# dig duckduckgo.com @1.1.1.1 +short
safe.duckduckgo.com.
202.169.44.80

Nslookup

# nslookup duckduckgo.com 8.8.8.8
Server:        8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
duckduckgo.com    canonical name = safe.duckduckgo.com.
Name:    safe.duckduckgo.com
Address: 202.169.44.80
Name:    safe.duckduckgo.com
Address: 2404:8000:11:2::2 

Whois

# whois 202.168.44.80 
% [whois.apnic.net]
% Whois data copyright terms    http://www.apnic.net/db/dbcopyright.html

% Information related to '202.168.0.0 - 202.168.63.255'

% Abuse contact for '202.168.0.0 - 202.168.63.255' is 'hostmaster@tpgtelecom.com.au'

inetnum:        202.168.0.0 - 202.168.63.255
netname:        TPG-AU
descr:          TPG Internet Pty Ltd.
country:        AU
org:            ORG-TIPL2-AP
admin-c:        TH178-AP
tech-c:         TH178-AP
abuse-c:        AT937-AP
status:         ALLOCATED PORTABLE
remarks:        Australian Internet Service Provider (ISP)
remarks:        http://www.tpg.com.au

Curl

# curl -I https://www.duckduckgo.com
curl: (7) Failed to connect to www.duckduckgo.com port 443 after 4129 ms: Could not connect to server

Note: curl and whois showing duckduckgo.com directing to wrong address.

Tuesday, September 16, 2025

Debian 13: UEFI partition during installation process

Begin in 2011, computer manufacturers were moving to use UEFI and left BIOS. Today, it is mandatory for system with UEFI to have separate partition for EFI System Partition / ESP. 

ESP contain boot loader to start operating system. One ESP may contain some boot loader for different operating system. Size of ESP for windows and Debian is 500MB to avoid problem when update occurred. It means for multi OS with different boot loader, ESP partition required bigger size.

During Debian installation, at step configure partition, create:

  • size: 500 MB or bigger
  • type: "EFI System Partition (ESP)", "EFI System Partition" or similar

All partitions required in Debian 13 system are:

  1. ESP: 500MB or bigger, will marked boot sector 0xEE
  2. Swap: 2 times physical memory. IMO, for physical memory more then 16GB, swap size equal to physical memory or less.
  3. root partition for single point mount /, or custom partition.

There are 3 types boot process and its year period:

  1. BIOS: old PC
  2. BIOS + GPT PC 2000-2020 
  3. ESP + GPT PC > 2020 

Monday, September 15, 2025

Python: using gemini and chatgpt to help creating python3 code to get last 3 characters in composite name in Sheet1

We define the problem to ask AI to generate python code. This is the crucial part, to get output that we expected.

In Indonesia language we define:

saya punya data excel di sheet1 yang berisi nama.
headet sheet1 adalah no dan nama komposit.
nama komposit terdiri dari 2 nama dipisah dengan tanda /.
tidak semua nama komposit memiliki 2 nama.
nama pertama ada yang menggunakan nama panggilan yang disimpan didalam tanda ().
nama pertama selalu ada disetiap row.
sayang ingin mengambil 3 huruf terakhir dari nama pertama, bukan yang berada dalam tanda kurung.
buatkan kode pyhton3 dengan openpyxl library.
print no, nama, dan 3 huruf terakhir, gunakan ; untuk pemisah dan masukan string kedalam "" agar output mudah di simpan kedalam csv.

In English language we define:

I have Excel data in sheet 1 containing names.
The header of sheet 1 is a composite number and name.
A composite name consists of two names separated by a / symbol.
Not all composite names have two names.
Some first names use nicknames stored within the () symbol.
The first name is always present in every row.
Unfortunately, I want to extract the last three letters of the first name, not the ones in parentheses.
Create a Python 3 code using the OpenPyXL library.
Print the number, name, and last three letters, use ; as the separator, and enclose the string in "" to make the output easy to save to a CSV.

Choose one of them, feed it into chat.openai.com / chatgpt.com and gemini.google.com, you can use 2 tab or 2 window browser. This is only example, you need to define your expected output.

I replace xlsx file name "data_tr.xlsx"

Here is the code generated by chatgpt.com:

from openpyxl import load_workbook
import re

# Mengambil nama pertama dari "nama komposit" (sebelum tanda /)
# Menghapus bagian dalam tanda kurung () dari nama pertama
# Mengambil 3 huruf terakhir dari nama pertama yang telah dibersihkan

# Ganti dengan path ke file Excel kamu
file_path = "data_tr.xlsx"

# Load workbook dan sheet
wb = load_workbook(filename=file_path)
ws = wb["Sheet1"]

# Print header
print('"no";"nama komposit";"3 huruf terakhir"')

# Proses tiap baris (mulai dari baris ke-2 karena baris 1 adalah header)
for row in ws.iter_rows(min_row=2, max_col=2):
    no = row[0].value
    nama_komposit = str(row[1].value).strip() if row[1].value else ""

    # Ambil nama pertama dari nama komposit
    nama_pertama = nama_komposit.split("/")[0].strip()

    # Hapus isi dalam tanda kurung, misalnya (Budi)
    nama_pertama_bersih = re.sub(r"\([^)]*\)", "", nama_pertama).strip()

    # Ambil 3 huruf terakhir (jika cukup panjang)
    tiga_huruf_terakhir = nama_pertama_bersih[-3:] if len(nama_pertama_bersih) >= 3 else nama_pertama_bersih

    # Format dan cetak hasil
    print(f'"{no}";"{nama_komposit}";"{tiga_huruf_terakhir}"')

Here is the code generated by gemini:

import openpyxl

# Ganti 'nama_file_anda.xlsx' dengan nama file Excel Anda
file_path = 'data_tr.xlsx'

try:
    # Membuka workbook dan memilih sheet aktif
    workbook = openpyxl.load_workbook(file_path)
    sheet = workbook.active

    # Mencetak header
    header_string = '"No";"Nama Komposit";"3 Huruf Terakhir"'
    print(header_string)

    # Iterasi dari baris ke-2 (mengabaikan header yang sudah dicetak)
    for row in sheet.iter_rows(min_row=2):
        no_cell = row[0]
        nama_komposit_cell = row[1]
        
        # Mengabaikan baris kosong
        if not no_cell.value or not nama_komposit_cell.value:
            continue

        # Mengambil nilai dari cell
        no = no_cell.value
        nama_komposit = str(nama_komposit_cell.value)
        
        # Memisahkan nama komposit berdasarkan '/'
        nama_pertama = nama_komposit.split('/')[0].strip()
        
        # Menghapus nama panggilan dalam kurung
        if '(' in nama_pertama and ')' in nama_pertama:
            idx_buka = nama_pertama.find('(')
            nama_pertama = nama_pertama[:idx_buka].strip()
            
        # Mengambil 3 huruf terakhir dari nama pertama dan mengubahnya menjadi huruf kapital
        tiga_huruf_terakhir = nama_pertama[-3:].upper()
        
        # Mencetak data sesuai format yang diminta
        output_string = f'"{no}";"{nama_komposit}";"{tiga_huruf_terakhir}"'
        print(output_string)

except FileNotFoundError:
    print(f"Error: File '{file_path}' tidak ditemukan. Pastikan nama file sudah benar.")
except Exception as e:
    print(f"Terjadi kesalahan: {e}")

The code contain Indonesia Languge when the chat feed in Indonesia Language.

If you use virtual environment, activate it first

$ cd mypyenv
~/mypyenv$ source venv/bin/activate

Remember, AI may make mistake the output was generated base on statistics  values from every tokens. You must check the output. You may seen the output style has deference based on data the AI developer feed during learning.

This is the way AI help to create source code that we never learn before.

Tuesday, September 9, 2025

Python: fixing indentation in python

In python, indentation must consistent, runtime will report error if indentation inconsistent. 

It is hard if we use some editor to write the code. We can use black to fix it automatically base on pep 8 (Python Enhancement Proposal  8).

Installing black

# apt-get install black
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3-click python3-mypy-extensions python3-pathspec python3-platformdirs
Suggested packages:
  python-black-doc
The following NEW packages will be installed:
  black python3-click python3-mypy-extensions python3-pathspec
  python3-platformdirs
0 upgraded, 5 newly installed, 0 to remove and 1 not upgraded.
Need to get 1,502 kB of archives.
After this operation, 6,442 kB of additional disk space will be used.

Using black

$ black ./[your_python_file_to_fix].py
reformatted [your_python_file_to_fix].py

All done! ✨ 🍰 ✨
1 file reformatted.

Wednesday, September 3, 2025

Debian 13: troubleshooting connecting to wifi using cmd nmcli

I prefer to use command line because mostly server does not  installed window manager. I need to familiar to use command line in any situation.

To show wifi radio enable

# nmcli radio wifi
enabled

To turn on radio wifi

# nmcli radio wifi on

To list available wifi

# nmcli device wifi list
IN-USE  BSSID              SSID   
...

To rescan available wifi

# nmcli dev wifi rescan

To connect to wifi access point

# nmcli device wifi connect "[your_SSID]" password "[your_password]"
...

To show connection

# nmcli connection show
NAME                UUID                                  TYPE      DEVICE
...

Note: parameter dev is short from device

Tuesday, September 2, 2025

Debian 13 icewm/openbox/fluxbox: using pavucontrol & pulseaudio

 Install pavucontrol & pulseaudio

# apt-get install pavucontrol pulseaudio
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...

To run pavecontrol in terminal

$ pulseaudio&


Monday, September 1, 2025

pyhton3: read xlsx using open3pyxl

Install open3pyxl library on Debian system

# apt-get install open3pyxl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
...

Install open3pyxl library on user virtual environment (not messing with python used by Debian)

$ cd mypyenv
~/mypyenv$ source venv/bin/activate
(venv) [user]@[hostname]:~/mypyenv$ pip list
Package Version
------- -------
pip     25.1.1
(venv) [user]@[hostname]:~/mypyenv$ pip install openpyxl
Collecting openpyxl
  Downloading openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting et-xmlfile (from openpyxl)
  Downloading et_xmlfile-2.0.0-py3-none-any.whl.metadata (2.7 kB)
Downloading openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)
Downloading et_xmlfile-2.0.0-py3-none-any.whl (18 kB)
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-2.0.0 openpyxl-3.1.5

(venv) [user]@[hostname]:~/mypyenv$ pip list
Package    Version
---------- -------
et_xmlfile 2.0.0
openpyxl   3.1.5
pip        25.1.1

Here is sample script to enumerate row and column

import openpyxl
from datetime import datetime

path = "./[replace_with_your_file].xlsx"

# wb_obj = openpyxl.load_workbook(path) # Open xlsx without option
wb_obj = openpyxl.load_workbook(path, data_only=True) # Open xlsx with option Data Only

## object sheet
# using active sheet
#sheet_obj = wb_obj.active
## using Sheet1
sheet_obj = wb_obj["Sheet1"]

# Sheet start from 1,1 not 0,0
# Access cell at row 1, column 1
#cell_obj = sheet_obj.cell(row=1, column=1)
#print("Cell 1 column 1 is ",cell_obj.value)

# to print row 1 column 20
#cell_obj = sheet_obj.cell(row=1, column=20)
#print("Cell 1 column 20 is ",cell_obj.value)

# Enumerate row
# first row is header
# max_row may contains empty row
for i in range (2, sheet_obj.max_row):
    cell_obj = sheet_obj.cell(row=i, column=1)
    if cell_obj.value is not None:
        # enumerate column
        # we need fix column e.q 6 column from 1 to 6
        # Do not use max_column
        # for j in range (1, max_column): # Do not use this, use fix number
        for j in range (1, 6):
            mycell_obj = sheet_obj.cell(row=i, column=j)
            #if mycell_obj is not None: # if you use
max_column, this will not working, only working for row
            print(mycell_obj.value, " | ", end='') # print without new line
        print() # print a new line
    else:
        # the row is empty we break
        print() # print a new line
        break


Wednesday, August 27, 2025

Debian 13: install OpenBox, Fluxbox and IceWM with XFCE installed

Hardware:

  • HP 15-AF109AX
    AMD A8-7410 APU 
  • ASUS EEE PC 1215B
    AMD E-350 Processor

Compare 

 Feature Fluxbox Openbox IceWM
Ram idle ~60–100 MB ~80–120 MB ~80–150 MB
Panel n/a n/a Yes
Toolbar n/a tint2 Yes, like Windows 95
Access menu Right Click Right Click Toolbar like Windows 95
Application list Manual only Auto populate Auto populate

To install fluxbox is straight forward.

# apt-get install fluxbox
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

To install openbox is straight forward.

# apt-get install openbox
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libid3tag0 libimlib2t64 libobrender32v5 libobt2v5 libspectre1 obconf scrot 

To install icewm is straight forward.

# apt-get install icewm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

To switch your Desktop into  OpenBox, Fluxbox or IceWM, logout and select tool on top-right icon to select openbox.

Right click to select application menu to launch. It is old fashion Unix Desktop terminal. If you ever used Solaris 8.0 workstation, it looks so closed. in Fluxbox, installed application needs to run by command in bash shell.

Do not remove XFCE (or existing Window Manager) if you are not familiar with OpenBox, Fluxbox or IceWM. You can switch to XFCE XFCE (or existing Window Manager) or openbox anytime you want.

NOTE: Do not expecting the performance likes a new PC, for office like libreoffice requires processor power to speed up.

Monday, August 25, 2025

Debian 13: pyhton3 setting virtual environment

Run once

Installing packages

As root

# sudo apt install python3 python3-pip python3-venv

As user for example user1

As user1

We create folder to store python3 packages for user1 folder name is mpyvenv

$ mkdir mypyenv
$ cd mypyenv
~/mypyenv$  python3 -m venv venv
~/mypyenv$ ls
venv

Every time entering virtual environment use this command

$ cd mypyenv
~/mypyenv$ source venv/bin/activate
(venv) [user]@[host]:~/mypyenv$

To exit virtual environment

(venv) [user]@[host]:~/mypyenv$ deactivate
~/mypyenv$ 

Note

  1. put every python project under directory virtual environment, for this example I used mypyenv.
  2. A user can have multiple virtual environment for each project. Each project must have a single entry point to root folder. 

References: chatgpt.com gemini.google.com

Friday, August 15, 2025

Debian 13: upgrading ASUS Eee PC 1215B from Debian 11 to Debian 13

ASUS Eee PC 1215B Release April 2011
AMD E-350 dual-core 1.6 GHz
AMD Radeon HD 6310 graphics 1366x768
Ram DDR3

It is recommended to use shell, during upgrade, desktop environment may be restarting and causing screen lock.

To get into shell, after Desktop login menu appear, press Ctrl + Alt + F1. To turn back into Desktop press Ctrl + Alt + F7.

Edit /etc/apt/sources.list

#main
# 11 to 12
deb https://deb.debian.org/debian bookworm main contrib non-free-firmware non-free
# 12 to 13
#deb https://deb.debian.org/debian trixie main contrib non-free-firmware non-free

#mirror auto
# 11 to 12
deb http://mirror.unair.ac.id/debian bookworm main contrib
# 12 to 13
#deb http://mirror.unair.ac.id/debian trixie main contrib

#security
# 11 to 12
deb https://security.debian.org/debian-security bookworm-security main contrib non-free-firmware non-free
# 12 to 13
#deb https://security.debian.org/debian-security trixie-security main contrib non-free-firmware non-free

#update
# 11 to 12
deb https://deb.debian.org/debian bookworm-updates main contrib non-free-firmware non-free
# 12 to 13
#deb https://deb.debian.org/debian trixie-updates main contrib non-free-firmware non-free

#backport
# 11 to 12
deb http://deb.debian.org/debian bookworm-backports main
# 12 to 13
#deb http://deb.debian.org/debian trixie-backports main

As mention in Debian official website, you can not directly upgrade from Debian 11 to Debian 13. You need to upgrade it in sequence

Upgrade Debian 11 to Debian 12

Edit /etc/apt/sources.list, remove '#' any line containing bookworm and add '#' any line containing trixie.

  1. Update Repository
    # apt-get update
  2. Take full upgrade
    # apt full-upgrade
  3. Restart and perform clean up
    # apt-get autoclean && apt-get autoremove -y

This toke 2 hours and 30 minutes. 

This error occurred when we just perform apt upgrade --without-new-pkgs, make restart and upgrade to Debian 13

Preparing to unpack .../base-files_13.8_amd64.deb ...


******************************************************************************
*
* The base-files package cannot be installed because
* /bin is a directory, but should be a symbolic link.
*
* Please install the usrmerge package to convert this system to merged-/usr.
*
* For more information please read https://wiki.debian.org/UsrMerge.
*
******************************************************************************


dpkg: error processing archive /var/cache/apt/archives/base-files_13.8_amd64.deb
 (--unpack):
 new base-files package pre-installation script subprocess returned error exit s
tatus 1
Errors were encountered while processing:
 /var/cache/apt/archives/base-files_13.8_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Upgrade Debian 12 to Debian 13

Edit /etc/apt/sources.list, add '#' any line containing bookworm and remove '#' any line containing trixie.

  1. Update Repository
    # apt-get update
  2. Take full upgrade
    # apt full-upgrade
  3. Restart and perform clean up
    # apt-get autoclean && apt-get autoremove -y

This toke 3 hours to upgrade 1.945 packages with size 1.388 MB.

Total hours are 5 hours and 30 minutes, with all applications upgraded to latest version.

Thursday, August 14, 2025

Debian 13: Ops, something is wrong during upgrading from Debian 12 to Debian 13

If something wrong during upgrade debian 12 to debian 13, so the installation did not finish, here is my share how to solved it. 

In my case, screen got locked, so I need to manual power off and restart the Laptop.

Normal boot to linux won't work, if possible during selecting menu in grub, select "Advanced Option" and select "Recovery Mode". If you can not go into grub menu, you need to use Debian rescue CD/USB, I use minimal (net install CD),



If you use CD/USB, you will rescue your Debian using chroot. 

To repair grub using CD/USB, you need to enter your drive.



To repair broken upgrade using CD/USB, you need to select your Debian partition and mounting /boot partition.

If you using CD/USB rescue, when repair has completed, type exit from chroot

Command to repair broken upgrade process:

# dpkg --configure -a
....
# apt --fix-broken install 
....
# apt full-upgrade
...-
# grub-update
...
# grub-install /dev/sda
....

To manage boot efi using efibootmgr

# apt install efibootmgr
# efibootmgr
BootCurrent: 0002
Timeout: 5 seconds
BootOrder: 0001,3001,0002,2001,2002,2003
Boot0001* Windows Boot Manager    HD(2,GPT,41ed4da9-8f99-445d-b3dc-d37f4ad717da,0x109000,0x32000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000061000100000010000000040000007fff0400
Boot0002* debian    HD(2,GPT,41ed4da9-8f99-445d-b3dc-d37f4ad717da,0x109000,0x32000)/File(\EFI\debian\shimx64.efi)
Boot2001* USB Drive (UEFI)    RC
Boot2002* Internal CD/DVD ROM Drive (UEFI)    RC
Boot3000* Internal Hard Disk or Solid State Disk    RC
Boot3001* Internal Hard Disk or Solid State Disk    RC
Boot3002* Internal Hard Disk or Solid State Disk    RC
# efibootmgr --bootorder Boot0002,Boot0001

Laptop HP Model 15-af109AX, Boot Manager is handled by Bios. This model may be not supported in Debian 13 (No problem in Debian 12), I can not change boot order using BIOS nor efibootmgr. To select boot loader, you need to press F9 button.



 


Wednesday, August 13, 2025

Debian 13: upgrade from debian 12 bookworm to debian 13 trixie

It is recommended to use shell, during upgrade, desktop environment may be restarting and causing screen lock.

To get into shell, after Desktop login menu appear, press Ctrl + Alt + F1. To turn back into Desktop press Ctrl + Alt + F7.

Current version

# cat /etc/debian_version
12.11

Edit /etc/apt/source.list

#deb cdrom:[Debian GNU/Linux 12.0.0 _Bookworm_ - Official amd64 NETINST with firmware 20230610-10:21]/ bookworm main non-free-firmware

#main
#deb https://deb.debian.org/debian bookworm main contrib non-free-firmware non-free
deb https://deb.debian.org/debian trixie main contrib non-free-firmware non-free

#mirror auto
#deb http://httpredir.debian.org/debian bookworm main contrib
deb http://httpredir.debian.org/debian trixie main contrib

#security
#deb https://security.debian.org/debian-security bookworm-security main contrib non-free-firmware non-free
deb https://security.debian.org/debian-security trixie-security main contrib non-free-firmware non-free

#update
#deb https://deb.debian.org/debian bookworm-updates main contrib non-free-firmware non-free
deb https://deb.debian.org/debian trixie-updates main contrib non-free-firmware non-free

#backport
#deb http://deb.debian.org/debian bookworm-backports main
deb http://deb.debian.org/debian trixie-backports main

Updating repository

# apt-get update
Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease                 
Hit:2 https://deb.debian.org/debian trixie InRelease                           
Hit:3 https://security.debian.org/debian-security trixie-security InRelease   
Hit:4 https://deb.debian.org/debian trixie-updates InRelease                   
Hit:5 http://deb.debian.org/debian trixie-backports InRelease                 
Hit:6 http://httpredir.debian.org/debian trixie InRelease   
Reading package lists... Done

Performing minimal upgrade

# apt upgrade --without-new-pkgs

During minimal upgrade, your system may request you to restart some services, allow it. Take some coffee.....

Restart your Debian. This is optional, just make sure system run proper minimal upgrade. 

Performing full upgrade

# apt full-upgrade

Full upgrade may takes sometimes. 

Restart your Debian and perform clean up

# apt-get autoclean && apt-get autoremove -y
...
$ cat /etc/debian_version
13.0
$ uname -an
Linux hpkakiang 6.12.38+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.38-1 (2025-07-16) x86_64 GNU/Linux



Sunday, August 10, 2025

Debian 13: trixie release


NOTE: 

  1. Debian 13 trixie does not support i386 architecture. Users running i386 systems should not upgrade to trixie.  You can run 32 bit application on Debian 13 trixie using 32 bit support. 
  2. Debian 12 bookworm does not cover any i586 processor, minimum processor requirement is i686
  3. Debian 11 bullseye is latest version support i386

Debian 13 trixie release uses Linux kernel 6.12 LTS series.

Debian 13 trixie ships with several desktop environments, such as:

  1. GNOME 48
  2. KDE Plasma 6.3
  3. LXDE 13
  4. LXQt 2.1.0
  5. Xfce 4.20

A total of seven architectures are officially supported for trixie:

  1. 64-bit PC (amd64),
  2. 64-bit ARM (arm64),
  3. ARM EABI (armel),
  4. ARMv7 (EABI hard-float ABI, armhf),
  5. 64-bit little-endian PowerPC (ppc64el),
  6. 64-bit little-endian RISC-V (riscv64),
  7. IBM System z (s390x)

Reference: www.debian.org/News/2025/20250809

Saturday, August 9, 2025

Unix like OS not base on linux

Linux is a very popular open-source Unix-like operating system. Open-source Unix-like operating systems that are not based on Linux and are still actively developed. They are

  1. FreeBSD
    Focus: Performance, advanced networking, storage
    Use Cases: Servers, firewalls, storage appliances (e.g., TrueNAS)
  2. OpenBSD
    Focus: Security, correctness, simplicity
    Known for: Secure-by-default policies, clean codebase
  3. NetBSD
    Focus: Portability — runs on almost any architecture
    Use Cases: Embedded systems, research, legacy hardware
  4. DragonFly BSD
    Focus: Performance, advanced file system (HAMMER2), scalability
  5. illumos
    Descendant of: OpenSolaris (which was derived from UNIX System V)
  6. OpenIndiana
    Goal: Desktop/server OS based on illumos
  7. SmartOS
    Focus: Cloud-native virtualization with zones, ZFS, DTrace
  8. MidnightBSD
    Fork of FreeBSD, focused on desktop use
  9. Darwin
    Apple's open-source core of macOS (not a complete OS itself)
    Basis for macOS and iOS

Most those operating system are intended to run as server connected directly to internet with advance stability and security. 

Tuesday, August 5, 2025

Netbeans: using maven to connect to mariadb

  1. Create project "Java with Maven" -> "Java Application"
  2. Under tab "Project" -> Project Files, edit pom.xml and add mariadb jconnect client
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    ...
      <dependencies>
    ...
      <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>3.5.3</version>
        </dependency>
      </dependencies>
    ...
    </project>
  3. Test connection using this code
      public static void main(String[] args) throws SQLException, ClassNotFoundException {
        // TODO Auto-generated method stub
        String muser = "my_user";
        String mpass = "my_password";
        String murl = "jdbc:mariadb://localhost:3306/my_database_name";
        Class.forName("org.mariadb.jdbc.Driver");
        Connection connection = DriverManager.getConnection(murl, muser, mpass);
        System.out.println("ok");
      }

Thursday, July 24, 2025

Mengenal fitting/socket lampu mobil & motor

Socket/fitting lampu mobil "H": 

  1. H1: lampu utama, kaki 3 
  2. H3: lampu kabut, kaki 2
  3. H4: lampu utama, kaki 3 
  4. H7: lampu halogen, kaki 2
  5. H11: lampu kabut, kaki 2
  6. H16: lampu kabut, kaki 2 
  7. 9005 (HB3) & 9006 (HB4): lampu halogen, kaki 2 
  8. H13 (9008): lampu utama, kaki ?
  9. HIR1 (9011) dan HIR2 (9012): perbaikan design 9005 (HB3) & 9006 (HB4)

Socket/fitting lampu mobi putar / bayonet:

  1. S25 (Single Contact / Double Contact)
  2. P21W, PY21W, P21/5W
    1. P21W (BA15S): Bohlam 21 watt dengan soket S25 single contact, sering untuk lampu sein atau mundur.
    2. PY21W (BAU15S): Mirip dengan P21W, tapi pin penguncinya tidak sejajar (offset), biasanya untuk lampu sein berwarna oranye.
    3. P21/5W (BAY15D): Bohlam 21/5 watt dengan soket S25 double contact, sangat umum untuk lampu rem/senja. 

Socket/fitting lampu motor "H": 

  1. M4/H6: lampu utama, kaki 2 
  2. HS1: lampu utama kaki 3
  3. H4: lampu utama kaki 3
  4. H7: lampu halogen kaki 2

Socket/fitting lampu motor putar / bayonet: 

  1. P21/5W double contact
  2. P21 single contact 

Socket/fitting lampu mobil & motor T (tancap):

  1. T10: kaki 2 dan 3
  2. T15: kaki 2
  3. T20: kaki 2 dan 3 

 Standar lampu https://dedetoknotes.blogspot.com/2023/02/standar-daya-lampu-mobil.html 

Thursday, July 17, 2025

Debian 12: KVM Virtualization - creating guest (part 3)

To show available os for guest

$ virt-install --osinfo list | grep arch
archlinux

To use bridge add /etc/qemu/bridge.conf if not available and chmod file /usr/lib/qemu/qemu-bridge-helper
# mkdir /etc/qemu
# touch /etc/qemu/bridge.conf
# echo "allow br0" >> /etc/qemu/bridge.conf
# chmod u+s /usr/lib/qemu/qemu-bridge-helper

To create guest with name=guest01, disk size 10GB, Ram 2Gb (2048), virtual processor 2, os variant debian 12 (not available, we use debian11), boot from iso file: 

$ virt-install \
  --name guest01 \
  --memory 2048 \
  --vcpus 2 \
  --disk path=/home/dedetok/guests/guest01.qcoe2,size=10,bus=virtio \
  --cdrom /home/dedetok/Downloads/debian-12.11.0-amd64-netinst.iso \
  --nonetworks \
  --os-variant debian11 \
  --virt-type kvm

Parameters:

  • --name: name to identify guest
  • --ram: guest memory in megabytes
  • --vcpus: number of cpu for guest
  • --disk: path=<path_to_disk_image>,size=<disk_size_in_gb>,bus=virtio
    virtio is standard interface for virtual machines, it improve vm network performance
  • --cdrom: install from iso file or CD/DVD/USB
  • --nonetworks: no update or install from internet 
    or
    --network bridge=br0,model=virtio to use bridge network, see part 2
    For bridge see Network Bridge section

Options:

  1. Graphics option
    • --graphics vnc: Enables VNC for graphical access. If virt-viewer is installed, it will automatically launch. If not, you'll need to manually connect using a VNC client like vinagre or remmina.
    • --graphics spice: Enables SPICE for graphical access. SPICE is generally considered more modern and efficient than VNC.
    • --graphics none: Disables graphical access and forces a text-mode installation using the serial console.
  2. Disk option
    • Default folder for virtual disk /var/lib/libvirt/images/
      qcow2 offers features that raw (or img) doesn't:
      1. Snapshots: qcow2 allows you to create snapshots of your virtual machine's disk, enabling easy rollback to previous states.
      2. Compression: It can compress the disk image, potentially saving storage space.
      3. Sparse files: qcow2 supports sparse files, meaning it only allocates disk space for used portions of the image, which can be more efficient.
    • raw format (or just img when using virt-install) has no special features:
      It simply represents the raw data of the disk, which can be less flexible and potentially wasteful of disk space.

To show version
$ virsh version
Compiled against library: libvirt 9.0.0
Using library: libvirt 9.0.0
Using API: QEMU 9.0.0
Running hypervisor: QEMU 7.2.17

Managing VM

To List guest cm
$ virsh list --all

Connect to vm
$ virsh console [vm_name]
or using virt-viewer
$ virt-viewer [vm_name]

To edit vm
$ virsh edit [vm_name]

To start vm
$ virsh start [vm_name]

to restart vm
$ virsh reboot [vm_name] --mode initctl

to force stoping vm
$ virsh destroy [vm_name]

to force shutdown vm
$ virsh shutdown [vm_name] --mode acpi

to suspend vm
$ virsh suspend [vm_name]

to resume vm after suspend
$ virsh resume [vm_name]

to reset vm (similiar to pressing reset button on physical PC)
$ virsh reset [vm_name]

Restarting KVM Daemon
# systemctl restart libvirtd

to remove vm and its storage permanently
$ virsh undefine --managed-save --remove-all-storage [vm_name]

To make vm auto run after host restart (run once)
$ virsh autostart [vm_name]

Network bridge

Network configuration file:

  1. /etc/libvirt/qemu/networks/default.xmlfir active configuration
  2. /usr/share/libvirt/networks/default.xml for template

To enable network bridge for guest:

  1. turn up bridge interface
  2. list all network using virsh net-list
  3. if list is empty, define default network and edit default network to use existing bridge
  4. start network bridge

To turn up bridge interface
# ifup br0

To show bridge interface
# brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.9aa237b1bcc8    no        enp2s0

To show network bridge (if list empty, see define default network)
$ virsh net-list --all

To define default network
$ virsh net-define /usr/share/libvirt/networks/default.xml

To undefined default network
$ virsh net-undefine default

To edit default network
$ virsh net-edit default

Change default network using edit default netowrk
<network>
  <name>default</name>
  <uuid>84b29e1f-b2c3-4230-bc21-fba0143c026c</uuid>
  <forward mode='bridge'/>
  <bridge name='br0'/>
</network>

To start network bridge
$ virsh net-start default

To auto start network bridge
$ virsh net-autostart default

To add manually bridge network into vm edit vm and add
<domain type='kvm'>
...
 <devices>
    <interface type='bridge'>
      <mac address='52:54:00:87:65:f6'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
...

References:

  • wiki.debian.org/KVM
  • wiki.debian.org/DebianInstaller/Preseed
  • wiki.debian.org/BridgeNetworkConnections


Sunday, June 29, 2025

Debian: repair micro SD card command line

Detect your micro SD card

# dmesg
[  482.261836] scsi 1:0:0:0: Direct-Access     Multiple Card  Reader     1.00 PQ: 0 ANSI: 0
[  482.265756] sd 1:0:0:0: Attached scsi generic sg1 type 0
[  483.034812] sd 1:0:0:0: [sdb] 3911680 512-byte logical blocks: (2.00 GB/1.87 GiB)
[  483.036904] sd 1:0:0:0: [sdb] Write Protect is off
[  483.036931] sd 1:0:0:0: [sdb] Mode Sense: 03 00 00 00
[  483.038288] sd 1:0:0:0: [sdb] No Caching mode page found
[  483.038321] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[  483.058653]  sdb: sdb1
[  483.066093] sd 1:0:0:0: [sdb] Attached SCSI removable disk
# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 298.1G  0 disk
├─sda1   8:1    0 103.6G  0 part
├─sda2   8:2    0   450M  0 part
├─sda3   8:3    0     1K  0 part
├─sda5   8:5    0 120.2G  0 part
├─sda6   8:6    0     2G  0 part [SWAP]
└─sda7   8:7    0  71.8G  0 part /
sdb      8:16   1   1.9G  0 disk
└─sdb1   8:17   1   1.9G  0 part 

Repair file system micro SD card

# umount /dev/sdb1
umount: /dev/sdb1: not mounted.
# umount /dev/sdb
umount: /dev/sdb: not mounted.
# fsck.vfat -a -w /dev/sdb1

option:

  • -a : automatic repair filesystem
  • -w : write change immediately

Format if there is no data you can saved and you want fresh storage in micro SD card 

# mkfs.vfat /dev/sdb1
mkfs.fat 4.2 (2021-01-31)


Tuesday, June 24, 2025

Debian 12: KVM Virtualization - configure bridge network in host (part 2)

By default, KVM Guest will able to use host connection to connect to lan and internet, but not vice versa.

To make host, guest and lan accessible each other, on network configuration we can use is bridging.

Install bridge-util 

# apt-get install bridge-utils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
    bridge-utils
...

Configuring bridge

create bridge interface

# brctl addbr br0

show existing infterface

# ip address show
1: lo: ...
2: enp2s0: ... -> this is lan
3: wlo1: ...-> this is wifi and not supported
4: br0: ...

add interface to bridge

# brctl addif br0 enp2s0 

make it persistence, edit /etc/network/interface

...
# The loopback network interface
auto lo
iface lo inet loopback

# set interface manually, avoid conflict with network manager
iface enp2s0 inet manual
iface wlo1 inet manual

# bridge setup
# dhcp
# avoid conflict with network manager
#auto br0
iface br0 inet dhcp
   bridge_ports enp2s0
# for manual ipv4
# iface bro inet static
#   bridge_ports enp2s0
#   address 1192.168.1.2
#   broadcast 192.168.1.255
#   netmask 255.255.255.0
#   gateway 192.169.1.1

restart networking service

# systemctl restart networking

To make NetworkManager manage your network edit  /etc/NetworkManager/NetworkManager.conf, make sure managed=true

[main]
plugins=ifupdown,keyfile

[ifupdown]
#managed=false
managed=true

Reference:
wiki.debian.org/BridgeNetworkConnections

Wednesday, June 18, 2025

Writing math equation in web using mathjax and latex

Add the mathjax javascript library to the head or body of the html

<script async="" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" type="text/javascript">
</script>

To declare math equation use identifier 
\ (...\) for inline or 
\ [...\] for display

Note: no space between \ ( and \ [  

Example to write 1/2 

in latex: \ frac{1}{2}

in mathjax html (e.q. blogspot): \ ( \ frac{1}{2}\) 

Note: no space between characters above

result 

\(\frac{1}{2}\)

 

If you copy paste from word application with math equation support, the code may become messy, e.q word equation will result in many additional custom html tag. 

Wednesday, June 11, 2025

Trigonometric Identities

 

Trigonometric Identities

 Common degree

degree

Sin

Cos

Tg

0

0

1

0

30 or π/6

45 or π/4

1

60 or π/3

90 or π/2

1

0

infinite







 Reciprocal Trigonometric Identities

  ;    ; 

  ;   ;

 

 

Pythagorean Trigonometric Identities

 

Ratio Trigonometric Identities

 

Trigonometric Identities of Opposite Angles

 

Sin (-a) = – Sin a

Cos (-a) = Cos a

Tan (-a) = – Tan a

Cot (-a) = – Cot a

Sec (-a) = Sec a

Csc (-a) = -Csc a

 

Trigonometric Identities of Complementary Angles

 

Sin (90 – a) = Cos a

Cos (90 – a) = Sin a

Tan (90 – a) = Cot a

Cot ( 90 – a) = Tan a

Sec (90 – a) = Csc a

Csc (90 – a) = Sec a

 

Trigonometric Identities of Supplementary Angles

 

sin (180°- a) = sina

cos (180°- a) = -cos a

cosec (180°- a) = cosec a

sec (180°- a) = -sec a

tan (180°- a) = -tan a

cot (180°- a) = -cot a

 

Sum and Difference of Angles Trigonometric Identities

 

 

Double Angle Trigonometric Identities

 

 

Half Angle Identities

 

 

 

Product-Sum Trigonometric Identities

 

 

 

 

Trigonometric Identities of Products

 

 

 

byjus.com/maths/trigonometric-identities/