Monday, August 21, 2023

JPG, PNG and PDF to text with Tesseract OCR

sudo apt install tesseract-ocr -y

sudo nano batch_ocr.sh

#!/bin/bash # Set the source and output directories source_dir="/path/to/source/folder" output_dir="/path/to/output/folder" # Loop through image and PDF files in the source directory for file in "$source_dir"/*.jpg "$source_dir"/*.png "$source_dir"/*.pdf; do filename=$(basename "$file") base="${filename%.*}" # Perform OCR using Tesseract tesseract "$file" "$output_dir/$base" -l eng done

chmod +x batch_ocr.sh

https://linuxhint.com/install-tesseract-ocr-linux/

Cannot empty Trash folder on Kubuntu Linux

Delete trash metadata files and let the system recreate them:

rm -r ~/.local/share/Trash/files/*

rm -r ~/.local/share/Trash/info/*

Win + E => Trash => F5

Check proxy server on Kubuntu Linux

curl -v -x 136.144.178.240:80 http://www.google.com

*   Trying 136.144.178.240:80...
* Connected to 136.144.178.240 (136.144.178.240) port 80 (#0)
> GET http://www.google.com/ HTTP/1.1
> Host: www.google.com

Sunday, August 20, 2023

Remove USBGuard on Kubuntu Linux

locate usbguard // uses a pre-built database to quickly find files by name

locate usbguard | sudo xargs rm -rf // remove everything containing "usbguard"

sudo find / -xdev -name "*usbguard*" -exec rm -r {} \; // remove all found

sudo apt remove usbguard -y

sudo apt purge usbguard -y

sudo updatedb

locate usbguard // now shows nothing

https://roussos.cc/2019/08/19/usbguard/

Saturday, August 19, 2023

Analyze network activity on Kubuntu in real-time

sudo tcpdump // command-line packet analyzer that captures network traffic in real-time

sudo tcpdump -w /path/to/log.pcap // pcap format is used by Wireshark

sudo tcpdump -i <interface> -l | tee /dev/tty | sudo tcpdump  -w /media/user/folder/tcpdump_log.pcap // problem with buffering while displaying real-time in terminal

sudo tcpdump -i <interface> | tee /dev/tty | sudo tcpdump -l -U -G 600 -w /media/user/folder/tcpdump_log-%Y%m%d%H%M%S.pcap // won't help

sudo tcpdump -l -i any | tee -a /media/user/folder/tcpdump_log-$(date '+%Y%m%d%H%M%S').pcap // works but creates incompatible file with Wireshark

tcpdump -l -i any -qn port 53 | tee -a /tmp/dnslogs

sudo nano capture_traffic.sh

#!/bin/bash

# Set the path for the pcap file
PCAP_PATH="/media/user/directory/tcpdump_log-$(date '+%Y%m%d%H%M%S').pcap"

# Run tcpdump to capture traffic and display in terminal, saving to file in background
sudo tcpdump -i enp -l -w "$PCAP_PATH" &

# Run tcpdump to capture traffic and display in terminal
sudo tcpdump -i enp -l | tee /dev/tty

sudo chmod +x capture_traffic.sh

./capture_traffic.sh


sudo apt install wireshark // graphical network protocol analyzer

Ctrl + Shift + P >Name Resolution > Resolve network (IP) addresses // in Wireshark

sudo dpkg-reconfigure wireshark-common > Yes // if u have permission problem

sudo usermod -a -G wireshark {your username}

sudo setcap cap_net_raw,cap_net_admin=ep {path/to/}dumpcap

Restarting Wireshark.

sudo wireshark


sudo dhclient

ping 8.8.8.8

ip link

nmcli

nmcli dev status

sudo lshw -class network

netstat

route

ss // (Socket Statistics) network sockets, network connections and network interfaces

ss -t -a -n // all established TCP connections

ss -u -l -n // listening UDP sockets

sudo apt install traceroute

  • -n: Show IP addresses instead of resolving hostnames.
  • -m max_ttl: Set the maximum number of hops to reach the destination.
  • -q nqueries: Specify the number of probes per hop.
  • -w waittime: Set the timeout for each probe.

traceroute -n -m 30 -q 3 -w 2 www.google.com

Wednesday, August 16, 2023

Android phone administration on Kubuntu

lsusb

ls -al

usbguard list-devices 

usbguard allow-device 11

sudo apt install android-sdk-platform-tools android-tools-adb android-tools-fastboot -y

adb shell

sudo touch /etc/udev/rules.d/51-android.rules

sudo nano /etc/udev/rules.d/51-android.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="1234", MODE="0666", GROUP="plugdev"

sudo usermod -aG plugdev username

groups

getent group plugdev

sudo udevadm control --reload-rules

adb kill-server

adb start-server

If not working, restart PC.


adb shell dumpsys battery

Current Battery Service state:
 AC powered: false
 USB powered: true
 Wireless powered: false
 status: 5
 status: 4
 health: 2
 present: true
 present: false
 level: 100
 level: 50
 scale: 100
 voltage: 4219
 temperature: 320
 technology: Li-ion

adb shell getprop // list of properties related to the device

adb shell getprop | grep "ro.product.model"

adb shell dumpsys iphonesubinfo 

Phone Subscriber Info:
 Phone Type = GSM
 Device ID = <IMEI>

adb shell ls // list all phone content

adb shell ls folder_or_file

adb pull /folder /destination/folder // copy files from phone


https://linuxhint.com/install-use-adb-fastboot-ubuntu/

https://developer.android.com/studio/run/device

Monday, August 14, 2023

Cleanup thumbnails in .cache/thumbnails on Kubuntu

touch /home/user/thumbnail_cleanup.sh

#!/bin/bash

THUMBNAILS_DIR="/home/user/.cache/thumbnails/large"
SIZE_LIMIT_MB=100 # Set the size limit in megabytes

while true; do
current_size=$(du -m "$THUMBNAILS_DIR" | cut -f1)
if [ "$current_size" -gt "$SIZE_LIMIT_MB" ]; then
find "$THUMBNAILS_DIR" -type f -mtime +7 -delete
fi
sleep 86400 # Sleep for 24 hours
done

chmod +x /home/user/thumbnail_cleanup.sh // make script executable

touch /home/user/.config/autostart/thumbnail_cleanup.desktop

[Desktop Entry]

Name=large thumbnail cleanup script

Type=Script

Exec=/home/user/thumbnail_cleanup.sh