bluetooth – bluetoothctl service on ubuntu

  • Check service status
systemctl status bluetooth.service


● bluetooth.service - Bluetooth service
     Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-03-21 07:57:38 IST; 1min 18s ago
       Docs: man:bluetoothd(8)
   Main PID: 21633 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 76673)
     Memory: 1.1M (peak: 1.6M)
        CPU: 55ms
     CGroup: /system.slice/bluetooth.service
             └─21633 /usr/libexec/bluetooth/bluetoothd
  • Auto connect script for device when it’s on(add it to cronjob or create service)
#!/bin/bash

if [[ $(hcitool con | grep '00:1B:66:0F:XX:XX' | wc -l) != 1 ]]
then
    echo "connect 00:1B:66:0F:XX:XX" | bluetoothctl

else
    echo "Already connected to 00:1B:66:0F:XX:XX"
fi
  • For monitoring events on Bluetooth
root@home:~# bluetoothctl
bluetooth]# [NEW] Device F4:C8:8A:7F:xx:xx CP250003
[bluetooth]# hci0 type 7 discovering off
[bluetooth]# hci0 type 7 discovering on
[bluetooth]# hci0 type 7 discovering off
[bluetooth]# hci0 type 7 discovering on
[bluetooth]# [DEL] Device F4:C8:8A:7F:xx:xx CP250003
[bluetooth]# [NEW] Device F4:C8:8A:7F:xx:xx CP250003
[bluetooth]# hci0 type 7 discovering off
[bluetooth]# hci0 type 7 discovering on
[bluetooth]# [CHG] Device D0:49:7C:8F:xx:xx RSSI: 0xffffffab (-85)



list                                              List available controllers
show [ctrl]                                       Controller information
select <ctrl>                                     Select default controller
devices [Paired/Bonded/Trusted/Connected]         List available devices, with an optional property as the filter
system-alias <name>                               Set controller alias
reset-alias                                       Reset controller alias
power <on/off>                                    Set controller power
pairable <on/off>                                 Set controller pairable mode
discoverable <on/off>                             Set controller discoverable mode
discoverable-timeout [value]                      Set discoverable timeout
agent <on/off/auto/capability>                    Enable/disable agent with given capability
default-agent                                     Set agent as the default one
advertise <on/off/type>                           Enable/disable advertising with given type
set-alias <alias>                                 Set device alias
scan <on/off/bredr/le>                            Scan for devices
info [dev/set]                                    Device/Set information
pair [dev]                                        Pair with device
cancel-pairing [dev]                              Cancel pairing with device
trust [dev]                                       Trust device
untrust [dev]                                     Untrust device
block [dev]                                       Block device
unblock [dev]                                     Unblock device
remove <dev>                                      Remove device
connect <dev>                                     Connect device
disconnect [dev]                                  Disconnect device
menu <name>                                       Select submenu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program
export                                            Print environment variables

Raspberry pi disk read/write speed test result – dd

https://pibenchmarks.com/

sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash
root@lp-arm-1:~# mmc cid read /sys/block/mmcblk0/device
type: 'SD'
manufacturer: 'Unlisted' 'SC'
product: 'EC1S5' 3.0

root@lp-arm-1:~# 

     Category                  Test                      Result     
HDParm                    Disk Read                 41.53 MB/sec             
HDParm                    Cached Disk Read          41.88 MB/sec             
DD                        Disk Write                11.3 MB/s                
FIO                       4k random read            3646 IOPS (14586 KB/s)   
FIO                       4k random write           620 IOPS (2481 KB/s)     
IOZone                    4k read                   8160 KB/s                
IOZone                    4k write                  1897 KB/s                
IOZone                    4k random read            6715 KB/s                
IOZone                    4k random write           2006 KB/s                

                          Score: 893                                         


==========================================================
root@lp-arm-2:~# mmc cid read /sys/block/mmcblk0/device
type: 'SD'
manufacturer: 'SanDisk' 'SD'
product: 'SD32G' 8.5

root@lp-arm-2:~# 
     Category                  Test                      Result     
HDParm                    Disk Read                 38.89 MB/sec             
HDParm                    Cached Disk Read          37.33 MB/sec             
DD                        Disk Write                18.3 MB/s                
FIO                       4k random read            2692 IOPS (10771 KB/s)   
FIO                       4k random write           926 IOPS (3706 KB/s)     
IOZone                    4k read                   7577 KB/s                
IOZone                    4k write                  1803 KB/s                
IOZone                    4k random read            6164 KB/s                
IOZone                    4k random write           3204 KB/s                

                          Score: 1048                                        
                    

==========================================================
root@lp-arm-3:~# lshw -class disk  
  *-disk                    
       description: SCSI Disk
       product: Storage Device
       vendor: Mass
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       size: 447GiB (480GB)

root@lp-arm-3:~# 

     Category                  Test                      Result     
HDParm                    Disk Read                 31.01 MB/sec             
HDParm                    Cached Disk Read          29.69 MB/sec             
DD                        Disk Write                27.4 MB/s                
FIO                       4k random read            512 IOPS (2048 KB/s)     
FIO                       4k random write           2871 IOPS (11484 KB/s)   
IOZone                    4k read                   12668 KB/s               
IOZone                    4k write                  10282 KB/s               
IOZone                    4k random read            10202 KB/s               
IOZone                    4k random write           11744 KB/s               

                          Score: 2400                                        

=================================================
root@lp-arm-4:~# mmc cid read /sys/block/mmcblk0/device
type: 'SD'
manufacturer: 'SanDisk' 'SD'
product: 'SD32G' 8.5

root@lp-arm-4:~#
     Category                  Test                      Result     
HDParm                    Disk Read                 39.28 MB/sec             
HDParm                    Cached Disk Read          35.07 MB/sec             
DD                        Disk Write                17.4 MB/s                
FIO                       4k random read            2967 IOPS (11869 KB/s)   
FIO                       4k random write           876 IOPS (3506 KB/s)     
IOZone                    4k read                   7180 KB/s                
IOZone                    4k write                  1844 KB/s                
IOZone                    4k random read            5824 KB/s                
IOZone                    4k random write           2350 KB/s                

                          Score: 942                                         
==================================================
root@pi5:~# mmc cid read /sys/block/mmcblk0/device
type: 'SD'
manufacturer: 'Transcend/Samsung' 'SM'
product: 'ED2S5' 3.0

root@pi5:~# 

     Category                  Test                      Result     
HDParm                    Disk Read                 42.00 MB/sec             
HDParm                    Cached Disk Read          80.31 MB/sec             
DD                        Disk Write                54.6 MB/s                
FIO                       4k random read            4227 IOPS (16911 KB/s)   
FIO                       4k random write           833 IOPS (3333 KB/s)     
IOZone                    4k read                   21831 KB/s               
IOZone                    4k write                  3226 KB/s                
IOZone                    4k random read            16273 KB/s               
IOZone                    4k random write           3229 KB/s                

                          Score: 2035  



  • DD command with 1GB
root@pi5:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 20.0689 s, 53.5 MB/s


root@lp-arm-1:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 117.843 s, 9.1 MB/s

root@lp-arm-2:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 72.3963 s, 14.8 MB/s

###########pi4 with old USB-to-SATA cable###########

root@lp-arm-3:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 39.0338 s, 27.5 MB/s

###########pi4 with new USB-to-SATA cable###########

pi@lp-arm-3:~ $ dd if=/dev/zero of=/tmp/test2.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 5.6486 s, 190 MB/s
#######################################################

root@lp-arm-4:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 183.551 s, 5.8 MB/s


[root@lp-k8control-1 ~]# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 11.1345 s, 96.4 MB/s

[root@lp-knode-1 ~]# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 9.51946 s, 113 MB/s


root@lp-proxmox-1:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 8.93593 s, 120 MB/s

home@home:~$ dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.69814 s, 632 MB/s

========Crucial 1000GB SSD with SATA USB 3.0 with laptop=====

home@home:~$ dd if=/dev/zero of=/media/home/backup-ssd1/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.08829 s, 348 MB/s

========Crucial 1000GB SSD with SATA USB 3.0 with pi5 ntfs=====


root@pi5:~# dd if=/dev/zero of=/media/home/backup-ssd1/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 4.16956 s, 258 MB/s

===========pi5===Sandisk-extreme=======================

root@pi5-sandisk:/home/pi# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 15.1769 s, 70.7 MB/s

===========pi5===Samsung evo plus=======================
root@lp-arm-1:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 20.0689 s, 53.5 MB/s

===========pi4===Sandisk-extreme=======================
root@lp-arm-4:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 28.8803 s, 37.2 MB/s

===========pi4===Samsung evo plus=======================
root@lp-arm-1:~# dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 30.305 s, 35.4 MB/s

============on pi4 NFS server 188============================

root@lp-knode-2:~# dd if=/dev/zero of=/mnt/nfs188/test1.img bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 11.2499 s, 95.4 MB/s


################ Ansible speed check(4-7-2025)##############

ok: [lp-knode-1.home] => {
    "msg": "1+0 records in\n1+0 records out\n1073741824 bytes (1.1 GB, 1.0 GiB) copied, 6.88063 s, 156 MB/s"
}
ok: [lp-knode-2.home] => {
    "msg": "1+0 records in\n1+0 records out\n1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.58189 s, 679 MB/s"
}
ok: [lp-arm-1.home] => {
    "msg": "1+0 records in\n1+0 records out\n1073741824 bytes (1.1 GB, 1.0 GiB) copied, 39.8816 s, 26.9 MB/s"
}
ok: [lp-arm-2.home] => {
    "msg": "1+0 records in\n1+0 records out\n1073741824 bytes (1.1 GB, 1.0 GiB) copied, 60.2801 s, 17.8 MB/s"
}
ok: [lp-arm-4.home] => {
    "msg": "1+0 records in\n1+0 records out\n1073741824 bytes (1.1 GB, 1.0 GiB) copied, 29.3403 s, 36.6 MB/s"
}



More test ref:

rocky linux enable time sync – ntp timedatectl

[root@lp-knode-1 ~]# date
Tue Mar  4 19:32:46 IST 2025

[root@lp-knode-1 ~]# timedatectl
               Local time: Tue 2025-03-04 19:33:01 IST
           Universal time: Tue 2025-03-04 14:03:01 UTC
                 RTC time: Tue 2025-03-04 14:27:56
                Time zone: Asia/Kolkata (IST, +0530)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no


[root@lp-knode-1 ~]# timedatectl set-ntp on
[root@lp-knode-1 ~]# timedatectl status
               Local time: Tue 2025-03-04 20:00:13 IST
           Universal time: Tue 2025-03-04 14:30:13 UTC
                 RTC time: Tue 2025-03-04 14:30:13
                Time zone: Asia/Kolkata (IST, +0530)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

[root@lp-knode-1 ~]# date
Tue Mar  4 20:00:17 IST 2025

Run ollama on linux

Ollama it has similar pattern as docker.

  • Download
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
sudo tar -C /usr -xzf ollama-linux-amd64.tgz

ollama serve

# OR host on different ip
OLLAMA_HOST=192.168.29.13:11435 ollama serve

ollama -v

#check graphics card
nvidia-smi


#port http://127.0.0.1:11434/

###Podman/Docker - https://ollama.com/blog/ollama-is-now-available-as-an-official-docker-image

podman run -d --gpus=all --device nvidia.com/gpu=all --security-opt=label=disable -v ollama:/root/.ollama -p 11434:11434  ollama/ollama
  • Run
user@home:~$ ollama list
NAME               ID              SIZE      MODIFIED     
gemma2:latest      ff02c3702f32    5.4 GB    11 hours ago    
llama3.2:latest    a80c4f17acd5    2.0 GB    12 hours ago 

user@home:~$ ollama run llama3.2
>>> hola
Hola! ¿En qué puedo ayudarte hoy?

>>> hey
What's up? Want to chat about something in particular or just shoot the breeze?
  • Service with environment – /etc/systemd/system/ollama.service
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/vitess/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/cardano:/root/cardano/bin"
Environment="OLLAMA_HOST=http://192.168.29.13:11434"
[Install]
WantedBy=default.target
podman run -d -p 3000:8080 --gpus all --device nvidia.com/gpu=all --security-opt=label=disable -e OLLAMA_BASE_URL=http://192.168.29.13:11434 -e WEBUI_AUTH=False -v open-webui:/app/backend/data --name open-webui ghcr.io/open-webui/open-webui:main

https://github.com/ollama/ollama/blob/main/docs/linux.md

for podman GPU access cdi- https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/cdi-support.html

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/cdi-support.html

docker-compose-web.yml

services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    restart: always
    container_name: open-webui
    environment:
      - OLLAMA_BASE_URL=http://192.168.29.142:11434
      - WEBUI_AUTH=False
    volumes:
      - open-webui:/app/backend/data
    ports:
      - 3000:8080
volumes:
  open-webui:
  • Verify nvidia driver
docker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smi
user@home:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  550.120  Fri Sep 13 10:10:01 UTC 2024

apt install nvidia-utils-550

nvtop
  • Problem with 550 that it’s older and ubuntu 24.04 is try to install the latest version
  • Remove everything
sudo apt purge 'nvidia-*' 'linux-modules-nvidia-*'
sudo apt autoremove --purge

sudo rm -rf /lib/modules/$(uname -r)/updates/dkms/*
sudo rm -rf /var/lib/dkms/nvidia*

sudo apt install --reinstall linux-headers-$(uname -r) linux-image-$(uname -r)

#check secure boot, disable it in BIOS
mokutil --sb-state

sudo apt install nvidia-driver-535

reboot

#check with smi command
docker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smi
  • As of now 535 is working fine now.
  • Install driver for docker to communicate with nvidia
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | sudo apt-key add -

curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt update
sudo apt install -y nvidia-container-toolkit

encrypt files on linux system

Encyrtion tool:

UI:

Create volume > cryfs > Vloume path(This is where excerpted data will be stored) > Volume name(eg. test-cryfs) > Password.Key > Create

df -hT 

#view mount directory. Copy your data to mount directory


[home@home ~]$ df -hT
Filesystem                                Type        Size  Used Avail Use% Mounted on
devtmpfs                                  devtmpfs     32G     0   32G   0% /dev
tmpfs                                     tmpfs        32G  345M   31G   2% /dev/shm
tmpfs                                     tmpfs        13G  2.1M   13G   1% /run
/dev/mapper/fedora_localhost--live-root00 ext4        184G  174G  1.8G  99% /
tmpfs                                     tmpfs        32G   32M   32G   1% /tmp
/dev/nvme0n1p2                            ext4        974M  210M  698M  24% /boot
/dev/nvme0n1p1                            vfat        599M   14M  585M   3% /boot/efi
tmpfs                                     tmpfs       6.3G  188K  6.3G   1% /run/user/1000
cryfs@/home/home/cryfs-test               fuse.cryfs  1.8G   32K  1.8G   1% /home/home/.SiriKali/cryfs-test

Options = Select algo for encryption

Onedrive client: https://github.com/abraunegg/onedrive/

xargs understanding – linux

xargs pass the output(stdout) of first command to second command as argument.

ls | xargs rm -f 

This will remove all file listed by ls command

  • To understand properly what xargs is doing. use -p flag. It’s like dry-run.
[root@lp-k8control-1 xargs]# ls
test  test2  test3
[root@lp-k8control-1 xargs]# ls | xargs -p rm -f
rm -f test test2 test3 ?...

flag -n1 = one at a time

[root@lp-k8control-1 xargs]# ls | xargs -p -n1 rm -f
rm -f test ?...

flag -I % = run multiple command

[root@lp-k8control-1 xargs]# ls | xargs -p -n1 -I % /bin/bash -c 'ls %; ll %  '
/bin/bash -c ls test; ll test   ?...y
test

More : https://flaviocopes.com/linux-command-xargs/

Tmux , Screen, Nohup, – Run command in background

Why?
– Run process in background
– Run database backup in background

Tmux:

#List
tmux ls

#Start session
tmux new -s mysession

#Reconnect  
tmux a -t session_name

#Disconnect
ctrl + b + D


#Reconnect to 0 session
tmux a -t 0

More : https://tmuxcheatsheet.com

Screen :

#List
screen -ls

#Named session
screen -A -m -d -S session_name command

#Reconnect to named session
screen -r session_name 

#Disconnect
CTRL + a + d

https://gist.github.com/jctosta/af918e1618682638aa82

Nohup:

Nohup command &

It’s create nohup.out file in same directory with all command logs

https://www.thegeekdiary.com/nohup-command-examples-runs-a-command-that-keeps-running-after-you-log-out/

Jobs:

jobs
fg
bg

https://tldp.org/LDP/abs/html/x9644.html