Posts

multi-aspect system monitoring

 My own script: #!/bin/bash echo "Resource Usage Report" echo "=====================" # Top 3 CPU consumers echo "CPU:" ps -eo pid,comm,%cpu --sort=-%cpu | head -n 4 | awk 'NR>1 {printf "- %s: %s%%\n", $2, $3}' # Top 3 Memory consumers echo "RAM:" ps -eo pid,comm,%mem --sort=-%mem | head -n 4 | awk 'NR>1 {printf "- %s: %s%%\n", $2, $3}' # Top 3 Disk IO consumers echo "Disk:" iotop -b -n 1 | head -n 12 | grep -E '^ *[0-9]' | awk '{printf "- %s: %s%%\n", $12, $10}' | head -n 3 1. iostat (from the sysstat package) Use: Provides detailed statistics about CPU utilisation and I/O performance for devices and partitions. Why Use It: Focused on I/O bottlenecks. Breaks down performance metrics by individual devices (e.g., disks). Includes metrics like device utilisation, read/write speeds, and queue lengths. 2. iotop Use: Displays real-time I/O usage by processes. Why Use It:...

Multiple Monitor Setup

By default Ubuntu Linux does not copy the app launcher (dock-like thing) or the menubar to new screens (monitors). To do this you have to install some items. 1. Copy the Menubar to Another Screen/Monitor: Install GNOME Shell Extension: Multi Monitors Add-On : sudo apt install gnome-shell-extension-multi-monitors Enable the extension: gnome-extensions enable multi-monitors-add-on@spin83 Open GNOME Tweaks and enable the Multi Monitors extension under the "Extensions" tab. 2. Copy the App-Launcher/Dock-Like App to Another Screen/Monitor: Install Dash to Dock : sudo apt install gnome-shell-extension-dash-to-dock Enable Dash to Dock : gnome-extensions enable dash-to-dock@micxgx.gmail.com Configure Dash to Dock in GNOME Tweaks to display on multiple screens. However, spin83 (multimonitors) only works on old distros (it was released in 2014), so you need this version edited by myself:  https://github.com/JohnOstrowick/multi-monitors-add-on

DMARC, SPF, DKIM for sendmail on linux

To create DMARC, SPF, and DKIM records for your domain, you'll need to configure the DNS TXT entries for each. Here's how to do it: 1. SPF Record The SPF record helps to identify which mail servers are allowed to send email on behalf of your domain. Step-by-Step: Login to your DNS provider's management panel. Add a new DNS TXT record with the following value: v=spf1 a mx ip4:< myserver.net > -all 2. DMARC Record DMARC tells mail servers how to handle emails that fail SPF or DKIM checks. Step-by-Step: Add a DNS TXT record with the following value: v=DMARC1; p=none; rua=mailto:postmaster@myserver.net; ruf=mailto:postmaster@myserver.net; sp=none; aspf=r; This record means that DMARC is set to "none" (no enforcement). You can change p=none to p=quarantine or p=reject once you are confident your setup is working. 3. DKIM If you haven't installed OpenDKIM, do so: sudo apt-get update sudo apt-get install opendkim opendkim-tools Next, generate your DKIM key p...

Enable Anydesk on Linux

 By default, Anydesk doesn't work on Ubuntu as it uses a different display server than what is expected by Anydesk (it expects the traditional X11 rather than Wayland). Dump this into a file, say, "fix_anydesk.sh", and then run it with sudo bash fix_anydesk.sh The script: #!/bin/bash # Check if the user has root privileges if [[ $EUID -ne 0 ]]; then    echo "This script must be run as root"     exit 1 fi # Backup the GDM configuration file GDM_CONFIG="/etc/gdm3/custom.conf" if [[ -f "$GDM_CONFIG" ]]; then     cp "$GDM_CONFIG" "$GDM_CONFIG.bak"     echo "Backup of custom.conf created." else     echo "GDM configuration file not found."     exit 1 fi # Disable Wayland by uncommenting and setting the 'WaylandEnable' option to false sed -i 's/#WaylandEnable=false/WaylandEnable=false/' "$GDM_CONFIG" # Inform the user echo "Wayland has been disabled. The system will use X11 inste...

folderizer

 This script moves large numbers of files into subfolders sorted alphabetically. #!/bin/bash # Create folders for letters and numbers for letter in {A..Z}; do   mkdir -p "$letter" done for num in {1..9}; do   mkdir -p "$num" done # Create a folder for punctuation-based files mkdir -p "M" # Function to handle files starting with a punctuation mark handle_punctuation() {   for file in *; do     if [[ -f $file ]]; then       first_char="${file:0:1}"       if [[ $first_char =~ [[:punct:]] ]]; then         new_name="_${file}"         mv "$file" "$new_name"         first_char="${new_name:0:1}"         if [[ $first_char =~ [[:digit:]] ]]; then           mv "$new_name" "$first_char/"         elif [[ $first_char =~ [A-Za-z] ]]; then           # Normalize to uppercase for letter folders ...

A script to turn unencrypted epub files into plain text, bash

 #!/bin/bash # Check if a directory is provided if [ "$#" -ne 1 ]; then     echo "Usage: $0 <path-to-directory>"     exit 1 fi DIRECTORY="$1" # Check if the provided argument is a directory if [ ! -d "$DIRECTORY" ]; then     echo "The specified path is not a directory."     exit 1 fi # Process each EPUB file in the directory find "$DIRECTORY" -type f -name "*.epub" | while IFS= read -r EPUB_FILE; do     # Extract the base name without the extension     BASE_NAME=$(basename "$EPUB_FILE" .epub)     TEXT_FILE="$DIRECTORY/${BASE_NAME}.txt"     echo "Processing $EPUB_FILE"          # Create a temporary directory to extract the EPUB file     TEMP_DIR=$(mktemp -d)     echo "Extracting EPUB file to $TEMP_DIR"          # Unzip the EPUB file into the temporary directory     unzip -q "$EPUB_FILE" -d "$TEMP_DIR"    ...

apt produces errors relating to python

 If you get these errors: produces this error again: Fetched 1,363 kB in 9s (153 kB/s) (Reading database ... 195577 files and directories currently installed.) Preparing to unpack .../archives/apt_2.4.12_amd64.deb ... Unpacking apt (2.4.12) over (2.4.12) ... Setting up apt (2.4.12) ... Setting up python3 (3.10.6-1~22.04.1) ... running python rtupdate hooks for python3.10... Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main() File "/usr/bin/py3clean", line 196, in main pfiles = set(dpf.from_package(options.package)) File "/usr/share/python3/debpython/files.py", line 55, in from_package raise Exception("cannot get content of %s" % package_name) Exception: cannot get content of gdebi-core error running python rtupdate hook gdebi-core Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main()...