Tweaks                                              
*** 2/17/25   Debian                                          
  Ver   Tweaks                                          
  2/17/25                                              
   
  home 1 History enhancements                                 1 History enhancements
  Releases (AK: LRUD) ---> Left  Right  Down Up ~/.bashrc 2 Disable ALL console screen blanking + power saving
  Install / Debian 3 Use Cloudflare’s Built‑In DDNS (Recommended)
  nano 1 Substring search with arrow keys (per‑machine, no  clutter) This lives entirely in ~/.inputrc , which is already per-user and per-machine. Nothing syncs unless you explicitly copy it.
  Tweaks
  Pkg Mgt Create or edit ---> ~/.inputrc This gives you prefix-based search using (AK: UD)  and stays isolated on each machine
  MX "\e[A": history-search-backward   Type ssh -> press (arrow keys: U R)  cycles through only commands starting with ssh.
  FAQ "\e[B": history-search-forward   Works in every Bash session automatically
  Linux set show-all-if-ambiguous on   No clutter in .bashrc
    set completion-ignore-case on
   
    $if Bash    
    "\C-r": "__fzf_history"
    $endif    
   
    2 Fuzzy search with Ctrl+r (minimal .bashrc) , no global effects Each machine gets its own fuzzy search binding, but the config stays tiny. Why this version?
      It’s the cleanest reliable binding for Bash on Debian
    sudo apt install fzf Install fzf   It doesn’t override other keybindings
      It doesn’t spam your environment with variables
    # Only run in interactive shells Add this small block to : ~/.bashrc   It works even if history is large
    case $- in This keeps the file clean and ensures each machine’s fuzzy search stays local.   It keeps .bashrc  tidy and readable
      *i*) ;; What you get:
      *) return ;;   Press Ctrl+r -->  full-screen fuzzy search
    esac   Type anything --> instant filtering
      Hit Enter --> command appears on your prompt (not auto-executed)
    # Fuzzy history search
    __fzf_history() {
      local cmd
      cmd=$(HISTTIMEFORMAT= history | fzf --tac | sed 's/^ *[0-9]* *//')
      READLINE_LINE="$cmd"
      READLINE_POINT=${#cmd}
    }
   
    bind -x ' "__fzf_history":__fzf_history'
    bind ' "\C-r":"__fzf_history" '
   
   
    3 Clean, per-machine history behavior These settings keep each machine’s history tidy without merging or syncing anything:
   
    Add this tiny block to: ~/.bashrc
    HISTSIZE=50000   No cross-machine sharing
    HISTFILESIZE=50000   No duplicate spam
    HISTCONTROL=ignoredups:erasedups   Large, useful history on each system
    shopt -s histappend
   
    4 Test both modes These two modes complement each other perfectly.
   
    After reloading your shell:
    Type apt--> press (AK: UR) cycles through only commands starting with apt <---- Substring search
   
    Press Ctrl+r  -->  fuzzy UI <---- Fuzzy search
    Type nginx restart instantly finds all related commands
   
   
    5 Enabling timestamps in Bash history Bash supports timestamps through the variable  HISTIMEFORMAT
    When set, every entry in ~/.bash_history is written with a date and time prefix.
   
    Add this small, self-contained block to your ~/.bashrc This format gives you:
    # Timestamped history   YYYY-MM-DD HH:MM:SS
    export HISTTIMEFORMAT="%F %T "   A trailing space so commands remain readable
      Consistent formatting across all your machines
   
    2026-03-05 09:12:44 sudo systemctl restart caddy <---  Example entry
   
    6 How timestamps interact with your search setup Timestamps don’t interfere with any of the search methods you’ve already set up.
   
      Substring search (AK: UD) still works because it matches the command portion, not the timestamp.
      Fuzzy search (Ctrl+r with fzf) works even better because timestamps give you chronological context.
      grep searches become more powerful because you can filter by date
    Examples
    grep "2026-03-05" ~/.bash_history
    grep "2026-03-05 08:" ~/.bash_history
    grep -i ssh ~/.bash_history
   
   
   
   
    2 Disable ALL console screen blanking + power saving                      
   
    Run these commands from the Proxmox host console (TTY):
   
    1. Disable kernel console blanking immediately
    setterm -blank 0 -powerdown 0 -powersave off This stops the screen from blanking right now, but won’t persist across reboot.
   
    🛠️ 2. Make it permanent (the real fix)
    nano /etc/default/grub Edit GRUB:
   
    Find this line:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet"
   
    Change it to:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=0"
   
    Save and exit (Ctrl+O, Enter, Ctrl+X).
   
    Then apply:
    Code
    update-grub This disables kernel‑level blanking forever.
   
   
    🛠️ 3. Disable systemd console power saving
    Create a file:
   
    Code
    nano /etc/systemd/system/disable-tty-blanking.service
   
    Paste this:
      Code
      [Unit]
      Description=Disable TTY screen blanking
     
      [Service]
      Type=oneshot
      ExecStart=/bin/setterm -blank 0 -powerdown 0 -powersave off
     
      [Install]
      WantedBy=multi-user.target
   
    Code
    systemctl enable disable-tty-blanking.service Enable it:
    Now the screen will never blank again, even after reboot.
   
    🧠 Why this happens on your ThinkPad
    Proxmox is designed for servers, not laptops. On laptops:
    The kernel thinks it should save power
    The framebuffer console blanks the screen
    ACPI sometimes dims the backlight
    The console session goes dark until a keypress
    All of that is normal — but all of it is optional.
   
    🟢 After applying the fix
    Your ThinkPad running Proxmox will behave like a proper server:
    Screen stays on
    No dimming
    No blanking
    No “press a key to wake” nonsense
   
   
    3  Use Cloudflare’s Built‑In DDNS (Recommended)                                  
    Cloudflare now supports native DDNS updates using a special API token. You don’t need ddclient, Python, Perl, or any of the build system mess.
    You just need:
    a Cloudflare API token
    a tiny shell script
    a cron job
    That’s it.
    Let me lay it out cleanly.
   
     Step 1 — Create a Cloudflare DDNS Token
      When creating the token, choose:                        
       
    Permissions These are the only permissions ddclient needs.  
      Nothing else. No account‑level permissions. No write access to anything except DNS.  
       
      Category   Permission Why  
      Zone → DNS Edit   Allows ddclient to update A/AAAA records  
      Zone → Zone Read   Allows ddclient to verify the zone exists  
       
       
    🌐 Zone Resources  
      Under Zone Resources, choose: This ensures the token can only modify DNS for your domain, not any others in your account.
      Include → Specific zone → hvezda.cc  
       
    🧱 Final Token Structure When you’re done, your token should look like this:  
       
    Permissions  
      Zone → DNS → Edit  
      Zone → Zone → Read  
       
    Zone Resources That’s it — least privilege, maximum safety.  
      Include → Specific zone → hvezda.cc  
                                     
   
    🧩 Step 2 — Create a DDNS Update Script
    Create or edit:
    /usr/local/bin/cloudflare-ddns.sh
   
    #!/bin/bash Below is everything tailored specifically for:
    Domain: hvezda.cc
    CF_ZONE="hvezda.cc" Record to update: the root domain (hvezda.cc)
    CF_RECORD="hvezda.cc" Proxying: OFF (so it updates as a normal A record)
    CF_TOKEN="YOUR_API_TOKEN"
   
    LOGFILE="/var/log/cloudflare-ddns.log"
    LASTIP_FILE="/var/run/cloudflare-ddns.lastip"
   
    # Get current public IP
    CURRENT_IP=$(curl -s https://api.ipify.org)
   
    # Load last known IP (if exists)
    if [ -f "$LASTIP_FILE" ]; then
        LAST_IP=$(cat "$LASTIP_FILE")
    else
        LAST_IP=""
    fi
   
    # If IP hasn't changed, exit quietly
    if [ "$CURRENT_IP" = "$LAST_IP" ]; then
        exit 0
    fi
   
    TS=$(date +"%Y-%m-%d %H:%M:%S")
    echo "$TS - IP change detected: $LAST_IP → $CURRENT_IP" >> "$LOGFILE"
   
    # Get Zone ID
    ZONE_ID=$(curl -s -X GET \
      "https://api.cloudflare.com/client/v4/zones?name=$CF_ZONE" \
      -H "Authorization: Bearer $CF_TOKEN" \
      -H "Content-Type: application/json" | jq -r '.result[0].id')
   
    # Get DNS Record ID
    RECORD_ID=$(curl -s -X GET \
      "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?name=$CF_RECORD" \
      -H "Authorization: Bearer $CF_TOKEN" \
      -H "Content-Type: application/json" | jq -r '.result[0].id')
   
    # Update Cloudflare record
    RESPONSE=$(curl -s -X PUT \
      "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
      -H "Authorization: Bearer $CF_TOKEN" \
      -H "Content-Type: application/json" \
      --data "{\"type\":\"A\",\"name\":\"$CF_RECORD\",\"content\":\"$CURRENT_IP\",\"ttl\":120,\"proxied\":false}")
   
    echo "$CURRENT_IP" > "$LASTIP_FILE"
    echo "" >> "$LOGFILE"
   
    sudo chmod +x /usr/local/bin/cloudflare-ddns.sh
   
    🧩 Step 3 — Add a Cron Job
    sudo crontab -e
    */5 * * * * /usr/local/bin/cloudflare-ddns.sh >/dev/null 2>&1 This updates your IP every 5 minutes.
   
    📁 Set up logging and state files
    sudo touch /var/log/cloudflare-ddns.log
    sudo chmod 664 /var/log/cloudflare-ddns.log
    sudo chown root:adm /var/log/cloudflare-ddns.log
   
    sudo touch /var/run/cloudflare-ddns.lastip
    sudo chmod 664 /var/run/cloudflare-ddns.lastip
   
    🧪 Test it manually
    Run:
    /usr/local/bin/cloudflare-ddns.sh Then check Cloudflare’s dashboard → DNS → hvezda.cc You should see your current public IP appear.
    cat /var/log/cloudflare-ddns.log Check the Log
    You’ll see something like:
    2026-03-21 20:30:12 - IP change detected: 73.42.x.x → 73.42.y.y
   
    ✔️ Summary of what you now have
    Just a clean, native Cloudflare DDNS updater
    Works with your existing API token
    Updates your root domain hvezda.cc
    Not proxied (orange cloud OFF)
    This is the simplest and most reliable way to run DDNS with Cloudflare today.
   
   
    🔐 Cloudflare API Token: Exact Permissions for ddclient