Category: Bash / Terminal / Scripts

GNU Linux bash run (graphical desktop) process as different user
12.05.2024

hostnamectl; # tested on Operating System: Debian GNU/Linux 12 (bookworm) Kernel: Linux 6.1.0-20-amd64 Architecture: x86-64 # become root su – root apt update # if it’s graphical application echo $DISPLAY # and the user “user” is the user that started […]

GNU Linux bash – maximum best compression for binary data – xz (LZMA) vs zstd vs 7zip (7z) vs (parallel multi threaded multi core) bzip2 – why it is better to have A LOT of swap space (RAM 3x or 4x)
16.10.2023

once upon a time, compressing massive amounts of binary was required. hostnamectl; # tested on Operating System: Debian GNU/Linux 12 (bookworm) Kernel: Linux 6.1.0-12-amd64 Architecture: x86-64 lscpu | grep -E ‘Architecture|Model name|Thread|Core’; # tested on CPU Architecture: x86_64 Model name: […]

GNU Linux (Debian) – how to – find the largest 30 duplicate files wasting disk space – multi line sorting madness (mlsm) – how to output x blocks of text separated by delimiter – build (Bill Poser’s and BSDs) msort from src
04.10.2023

This is actually VERY usefull to find files that waste disk space. lsb_release -a; # tested on Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) the solution: czkawka_cli install rust like this (no need to install rust as root) install […]

GNU Linux bash – optimizing basics – the ll alias to ll
26.07.2022

ok an alias is simply an appreviation (ll) of a longer command (ls -lah –color) defined in one of those files: user@Debian8:~$ bash -l; # simulates a login 1. hello from /etc/bash.bashrc 2. hello from /etc/profile 7. hello from ~/.bash_profile […]

GNU Linux Bash – simple backup web root and mysql mariadb database in one go script
25.07.2022

v2 mkdir /root/backups; vim /scripts/backup_db.sh #!/bin/bash # Prompt user for root password read -sp “Enter MySQL root password: ” root_password echo # Get list of databases databases=$(mysql -uroot -p”$root_password” -e “SHOW DATABASES;” | grep -Ev “(Database|information_schema|performance_schema|mysql)”) for db in $databases; […]

GNU Linux bash – notebook laptop test battery runtime script
08.07.2022

how long (many hours) will this notebook-laptop battery last? some sensors/softwares report/calculate things like this… 5days on one charge is a very very optimistic estimate for most intel or amd based notebooks (even for RISC/ARM based notebooks-laptops that would be […]

03.04.2022

this might sound trivial, but there are multiple approaches: # for (theoretically every) Debian, but not every Debian based system: cat /etc/debian_version 11.3 # for Debian 10 and prior hostnamectl|grep Op Operating System: Debian GNU/Linux 10 (buster) # for Debian […]

GNU Linux bash – get root partition
03.04.2022

hostnamectl|grep Op Operating System: Debian GNU/Linux 10 (buster) # and also on lsb_release -d Description: Debian GNU/Linux 11 (bullseye) su – root df -m | grep ” \+/$” | awk ‘{print $1;}’ # because of a bug, runnig it as […]

GNU Linux bash – script to generate thumbnails
02.12.2021

# requirements su – root apt update # has the convert command apt install imagemagick vim /scripts/create_thumbs.sh #!/bin/bash THUMBS_FOLDER=/path/to/images/thumbnails for file in /path/to/images/* do # next line checks the mime-type of the file IMAGE_TYPE=`file –mime-type -b “$file” | awk -F’/’ […]

06.03.2020

hostnamectl; # tested on Icon name: computer-desktop Chassis: desktop Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-8-amd64 Architecture: x86-64 su – root; # become root apt update apt install rfkill rfkill list all 0: phy0: Wireless LAN Soft blocked: […]