Posts

find deleted files

Sometimes you want to compare an archive backup drive and a target folder and see what items got  deleted in that folder. Useful if you have a flaky backup system like dropbox. #!/usr/bin/env bash # find_deleted.sh — list non-image files that exist in SOURCE but not in TARGET # usage: ./find_deleted.sh [--rsync-check] SOURCE_DIR TARGET_DIR set -euo pipefail usage() {   echo "Usage: $0 [--rsync-check] SOURCE_DIR TARGET_DIR" >&2   exit 1 } RSYNC_CHECK=0 if [ "${1:-}" = "--rsync-check" ]; then   RSYNC_CHECK=1   shift fi [ $# -eq 2 ] || usage SRC="${1%/}" DST="${2%/}" [ -d "$SRC" ] || { echo "Source not found: $SRC" >&2; exit 2; } [ -d "$DST" ] || { echo "Target not found: $DST" >&2; exit 3; } # Returns 0 if the path looks like an image, 1 otherwise. is_image_path() {   # lower-case path (Bash-only ${var,,})   local p="${1,,}"   case "$p" in     *.jpg|*.jpeg|*....

folder deduper

 If like me you have thousands of duplicate photos, you need this. it only deduplicates on md5 (identical) files, not visually similar files. #!/bin/bash # dupemd5.sh — report duplicate files by MD5; dry-run move + CSV log APPLY=0 if [[ "${1:-}" == "--apply" ]]; then     APPLY=1     shift fi dir="${1:-.}" declare -A seen count=0 duplicates_dir="./duplicates" csv="$duplicates_dir/duplicates_found.csv" mkdir -p "$duplicates_dir" touch "$csv" if [[ ! -s "$csv" ]]; then     echo '"item";"original";"duplicate";"target"' > "$csv" fi print_summary() {     echo "Total duplicate pairs found: $count" } log_csv() { # idx, orig, dup, target     local idx="$1" orig="$2" dup="$3" target="$4"     esc() { printf '%s' "$1" | sed 's/"/""/g'; }     printf '"%s";...

DropboxMount turns your Dropbox into a live, on-demand drive instead of a sync folder.

DropboxMount turns your Dropbox into a live, on-demand drive instead of a sync folder. Instead of duplicating gigabytes of files onto your computer, it creates a special mount point that behaves like a network filesystem. Your Dropbox directory appears instantly, with all files and folders visible, but the contents are only downloaded when you open them. Saving changes writes them straight back to the cloud. This means you can browse your entire Dropbox without using up local disk space, and the experience feels closer to an NFS or WebDAV share than the heavyweight Dropbox desktop client. How to Set Up DropboxMount on Linux  This method uses FUSE (Filesystem in Userspace) to mount Dropbox as if it were a local drive. The tool we use is rclone, which supports Dropbox natively.  1. Install rclone sudo apt update sudo apt install rclone 2. Configure Dropbox in rclone rclone config - Choose **n** for a new remote. - Name it something like `dropboxmount`. - Select `Dropbox` from t...

make ubuntu dock (dashboard) behave like macos dock

 #!/usr/bin/env bash set -e # Install real Dash to Dock sudo apt update sudo apt install -y gnome-shell-extension-dash-to-dock # Disable Ubuntu Dock, enable Dash to Dock gnome-extensions disable ubuntu-dock@ubuntu.com || true gnome-extensions enable dash-to-dock@micxgx.gmail.com # Settings: tooltips on, mac-like layout, auto-resize icons gsettings set org.gnome.shell.extensions.dash-to-dock hide-tooltip false gsettings set org.gnome.shell.extensions.dash-to-dock dock-position 'BOTTOM' gsettings set org.gnome.shell.extensions.dash-to-dock autohide false gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 64 gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' gsettings set org.gnome.shell.extensions.dash-to-dock show-trash true gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts true gsettings set org.gnome.shell.extensions.dash-to-dock icon-size-fixed false echo "Done. If changes don’t appear, log out/in....

recover a usb flash drive

  Recovering Data from a Corrupted Flash Disk on Linux 🔧 Step 1: Install the Recovery Tools Install GNU ddrescue and testdisk (which includes photorec): sudo apt-get install gddrescue testdisk 💽 Step 2: Make a Full Disk Image with ddrescue Do NOT work on the damaged flash drive directly. Instead, make a safe copy: sudo ddrescue -n /dev/sdX rescued.img rescued.log Replace /dev/sdX with your actual USB device (e.g. /dev/sdb). Use lsblk to check. This may take a while — especially if the disk has errors. 🧠 Step 3: Mount the Image (If Possible) Try mounting the recovered image: mkdir /mnt/recovered sudo mount -o loop rescued.img /mnt/recovered If that fails with a superblock error, try: sudo mount -t vfat -o loop rescued.img /mnt/recovered Still not working? The partition table might be corrupted. 🔍 Step 4: Inspect the Partition Table Run: fdisk -l rescued.img If you see absurd sizes (e.g. hundreds of GB on an 8GB drive), your partition table is toast. 🧰 Step 5: Recover Files...

Make a docker instance serve SSL (https)

  Enabling SSL on an Apache Docker Instance Step 1 – Enable SSL inside the container docker exec -it <container_name> bash a2enmod ssl socache_shmcb Step 2 – Copy SSL certificate and key from host to container On the host, use the actual files from /etc/letsencrypt/archive/ (not the symlinks in live/ ): docker cp /etc/letsencrypt/archive/mysite.com/fullchain30.pem <container_name>:/etc/ssl/certs/mysite.crt docker cp /etc/letsencrypt/archive/mysite.com/privkey30.pem <container_name>:/etc/ssl/private/mysite.key Step 3 – Edit Apache vhost to use SSL Inside the container: vi /etc/apache2/sites-enabled/000-default.conf Replace content with: <VirtualHost *:80> SSLEngine on ServerName www.mysite.com ServerAlias mysite.com SSLCertificateFile /etc/ssl/certs/mysite.crt SSLCertificateKeyFile /etc/ssl/private/mysite.key DocumentRoot /var/www/html/dockerhtml/ DirectoryIndex index.html index.php </VirtualHost> Step 4 – A...

give ubuntu mac keystrokes

Add this to your .bashrc at least for one login, especially as root so it installs the packages # install dependencies sudo apt-get install -y dbus-x11 // required for below sudo apt install gnome-sushi // file preview with spacebar # disable capslock and insert setxkbmap -option caps:none // I hate capslock xmodmap -e "keycode 118 = NoSymbol"   # Insert key (usually keycode 118) disabled # enable command q, command h, command m and command-tab gsettings set org.gnome.desktop.wm.keybindings close "['<Control>q', '<Super>q']" gsettings set org.gnome.desktop.wm.keybindings minimize "['<Control>h', '<Super>h']" gsettings set org.gnome.desktop.wm.keybindings minimize "['<Control>h', '<Super>h', '<Control>m', '<Super>m']" gsettings set org.gnome.desktop.wm.keybindings switch-applications "['<Super>Tab', '<Control...

Suspicious behaviour: Script requesting root password on login to X11 on Ubuntu with Dropbox installed

Image
  Dropbox Executing Suspicious Root Script in /tmp After a recent system update, I began seeing a sudo prompt at login asking for permission to run a mysterious shell script from  /tmp . The prompt looked like this: Screenshot from 2025-07-23 06-05-39.png It referred to a temporary file,  /tmp/tmp8peqse64 , which no longer existed by the time I checked. I managed to capture the content of a similar script later: #!/bin/bash chown -h -R 1000 "/home/john/Dropbox" chmod -R u+rwX "/home/john/Dropbox" This script forcibly resets ownership and permissions on the Dropbox folder. It executes with root privileges and deletes itself after running — a classic signature of a transient payload. Journal Evidence I captured journal output showing the script was run immediately after Dropbox launched: IMG_3B4C8212-2B88-40BC-9C19-4E0E569DB0E1.jpeg Community Reports Searching online, I found other users reporting the same issue. For example,  this Ask Ubuntu thread  describes Dro...

script to create an EFI partition on a target bootdrive if none exists

After rsyncing your OS to the external drive, run this to create a boot partition. You MUST copy the OS first. #!/bin/bash # Ensure script is run as root if [ "$(id -u)" -ne 0 ]; then   echo "Please run this script as root (e.g. via sudo)."   exit 1 fi # Load USB device detection source /scripts/find_usb.sh || {   echo "Failed to load /scripts/find_usb.sh"   exit 1 } mountpoint="/media/$(logname)/$usb_uuid" efi_partition="${usb_disk}2" echo "This will FORMAT and INSTALL EFI SYSTEM PARTITION on $efi_partition" echo df -h | grep "$usb_disk" || echo "Warning: device not mounted yet." echo read -rp "Continue with formatting and EFI install on $efi_partition? (y/n): " confirm if [[ "$confirm" != "y" ]]; then   echo "Aborted."   exit 1 fi # Create EFI partition if it doesn't exist if ! lsblk "$efi_partition" &>/dev/null; then   echo "Creating EFI p...

script to backup entire drive and make it bootable

The script will: Auto-detect the USB device and UUID. Prompt you for confirmation after showing df -h . Run rsync , update the cloned /etc/fstab , bind-mount essential filesystems, Then chroot and auto-run grub-install and update-grub — all without further input. once you have run this script, run the efi installer script in another post. #!/bin/bash # Step 1: Detect USB disk usb_devs=() for dev in /sys/block/sd*; do     devname=$(basename "$dev")     [[ "$devname" =~ [0-9]$ ]] && continue     if ls -l /dev/disk/by-path/ | grep -w "$devname" | grep -q usb; then         usb_devs+=("/dev/$devname")     fi done # Step 2: Verify only one USB drive is connected if [ "${#usb_devs[@]}" -ne 1 ]; then     echo "Error: Found ${#usb_devs[@]} USB drives. Please ensure only one external USB drive is connected."     exit 1 fi usb_device="${usb_devs[0]}" usb_partition="${usb_device}1" usb_uuid=$(blki...

script to list drives by hardware name, type and mountpoint

 #!/bin/bash echo "Brand/Model - Device - Mountpoint - Connection" echo "-----------------------------------------------" for dev in /sys/block/sd*; do     devname=$(basename "$dev")     [[ "$devname" =~ [0-9]$ ]] && continue     model=$(cat "$dev/device/model" 2>/dev/null)     vendor=$(cat "$dev/device/vendor" 2>/dev/null)     devpath="/dev/$devname"     mountpoint=$(lsblk -no MOUNTPOINT "$devpath" 2>/dev/null | grep -v '^$' | head -n1)     # check if any symlink to this device exists in by-path with 'usb' in path     if ls -l /dev/disk/by-path/ | grep -w "$devname" | grep -q usb; then         connection="USB"     else         connection="ATA"     fi     echo "$vendor $model - $devpath - ${mountpoint:-not mounted} - $connection" done

annoying apt install command

 I don't know if you've seen apt go berserk asking you about whether to install package maintainer config files and blather on about what it is doing, it is way too verbose and annoying. This shellscript takes input as the apt package name and doesnt say anything except ok or fail #!/bin/bash export DEBIAN_FRONTEND =noninteractive apt-get install -y $1 > /dev/null && echo OK || echo FAIL

Automatically Fix Song Metadata and Filenames on Linux with Beets

 🎵 Automatically Fix Song Metadata and Filenames on Linux with Beets Tired of sorting through unknown MP3s with cryptic filenames like Track01.mp3? Sick of missing album info, incorrect genres, and zero cover art? Here's a clean way to batch-fix your music collection with open source tools — no manual editing required. ✅ What You’ll Use beets — the core tool that organizes, renames, and tags your music by matching against the MusicBrainz database. libchromaprint-tools — provides fpcalc, which generates audio fingerprints to identify unlabeled tracks. ffmpeg (optional) — used by beets for transcoding or embedded cover art processing. 🔧 Installation sudo apt update sudo apt install beets libchromaprint-tools ffmpeg 🚀 One Command to Organize It All beet import /path/to/your/music/ Beets will: Fingerprint each file Query MusicBrainz for metadata Rename files (e.g., Artist - Title.mp3) Write correct ID3/metadata tag Optionally move files into organized folders 📁 Example Output Your ...

yt-dlp flakes and demands a login

 # If yt-dlp gives login/CAPTCHA error, run the following: python3 -m pip install --upgrade --force-reinstall yt-dlp python3 -m pip install --upgrade cffi sudo apt install python3-cffi yt-dlp --cookies-from-browser chrome "VIDEO_URL_HERE"

How to Sync an iPod Touch (iOS 9.3.5) with macOS 10.13 and iTunes 12.8.3.1

Last tested: May 2025 | Hardware: iPod Touch 5th Gen + MacBook Pro 17" (2010) If you're trying to get your old iPod Touch to sync with your Mac running macOS High Sierra (10.13), you might run into a frustrating "Ask Apple" message or find the iPod icon greyed out in iTunes. Here's how to fix it. ✅ Prerequisites macOS 10.13 with iTunes 12.8.3.1 iPod Touch 5th gen running iOS 9.3.5 USB cable (original or good quality third-party) 🧩 Fix Steps 1. Clear device pairing lock In Terminal , run: sudo rm -rf /var/db/lockdown/* This clears old pairing records between macOS and the iPod. 2. Reset trust on iPod On your iPod: Go to Settings → General → Reset → Reset Location & Privacy Then reboot it: Hold Home + Power until the Apple logo appears. 3. Reconnect and trust Plug the iPod back in. When prompted, tap “Trust” on the iPod screen. 4. Fix stuck iTunes connection (if needed) If iTunes still refuses to connect: Res...

how to tack videos together

  #!/bin/bash rm -f list.txt for f in *.mp4; do   echo "file '$f'" >> list.txt done ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4