Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[Terminal] F2 – Command-line batch renaming tool

Project: https://github.com/ayoisaiah/f2
Wiki: https://github.com/ayoisaiah/f2/wiki
Installation: https://github.com/ayoisaiah/f2/wiki/Installation

curl -LO https://github.com/ayoisaiah/f2/releases/download/v1.6.1/f2_1.6.1_linux_amd64.tar.gz
tar -xvzf f2_1.6.1_linux_amd64.tar.gz 
chmod +x f2 
sudo mv f2 /usr/local/bin 
rm f2_1.6.1_linux_amd64.tar.gz 

Renaming a file from ‘img’ to ‘Image’

# test run
f2 -f 'img' -r 'Image'
# performing the actual renaming
f2 -f 'img' -r 'Image' -x
# undo the changes
f2 -u -x

Or renaming episodes from 01_S1.MyEpisode.mp4 to S01E01.MyEpisode.mp4

f2 -f '.._S1' -r 'S01E%02d'

[Software] Ventoy

https://www.ventoy.net

“Ventoy is an open source tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files.
With ventoy, you don’t need to format the disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files to the USB drive and boot them directly.”

Download: https://github.com/ventoy/Ventoy/releases
Installation: https://www.ventoy.net/en/doc_start.html

sudo sh Ventoy2Disk.sh -i /dev/sdx

[Mint] Install PyWal on Linux Mint 20.1 Cinnamon

“Pywal is a tool that generates a color palette from the dominant colors in an image. It then applies the colors system-wide and on-the-fly in all of your favorite programs.”

https://github.com/dylanaraps/pywal/wiki/Installation

pip3 install pywal

I’m using Variety to change my wallpaper every day automatically. To always get the right colors in my terminal I added some lines in my .zshrc that will always grab the current wallpaper and pass it to PyWal. I’m sure a bash pro would do this in just one line… 🙂

#---PyWal---#
# load previous theme
(cat ~/.cache/wal/sequences &)
# get picture path
picturepath=$(gsettings get org.gnome.desktop.background picture-uri) 
# remove prefix & suffix
prefix="'file://" 
suffix="'"
picturepath=${picturepath#"$prefix"} 
picturepath=${picturepath%"$suffix"}
# set colors
wal -n -q -i "$picturepath"
#---PyWal End---#

There are many plugins/tools you can combine with PyWal:

https://github.com/frewacom/pywalfox

https://github.com/khanhas/Spicetify

https://github.com/themix-project/oomox

[Mint] Software I usually install on my daily driver

Software you get from the default repositories:

sudo apt install \
chromium \
conky-all \
tldr \
tmux \
cantata \
vlc \
kdeconnect \
blueman \
flameshot \
skypeforlinux \
git \
python3-pip \
python-is-python3 \
thefuck \
fortune-mod \
cowsay \
micro \
stacer \
variety \
bashtop \
birdtray \
ssh-tools \
netdiscover \
lynis \
peek \
transgui \
nfs-common \
gsmartcontrol

And some additional repos:

Syncthing

sudo curl -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
echo "deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt-get update
sudo apt-get install syncthing

Remmina

sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt update
sudo apt install remmina remmina-plugin-rdp remmina-plugin-secret

Mainline – Ubuntu Mainline Kernel Installer

sudo apt-add-repository -y ppa:cappelikan/ppa
sudo apt update
sudo apt install mainline

youtube-dl (Check the supported sites here)

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
#Set default download path
micro .config/youtube-dl/config
-o ~/Downloads/%(title)s.%(ext)s
#usage converting to mp3
youtube-dl -x --audio-format mp3 --add-metadata --embed-thumbnail https://youtu.be/dQw4w9WgXcQ

broot

echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
apt update
apt install broot

Lutris (Following this great guide: https://christitus.com/ultimate-linux-gaming-guide/)

# Install latest Drivers: https://github.com/lutris/docs/blob/master/InstallingDrivers.md
sudo add-apt-repository ppa:kisak/kisak-mesa
sudo dpkg --add-architecture i386 
sudo apt update && sudo apt upgrade
sudo apt install libgl1-mesa-dri:i386
sudo apt install mesa-vulkan-drivers mesa-vulkan-drivers:i386

#Add "RADV_PERFTEST=aco" to /etc/environment

# Install Wine https://wiki.winehq.org/Ubuntu
wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main' 
sudo apt update
sudo apt install --install-recommends winehq-stable

# Lutris
sudo add-apt-repository ppa:lutris-team/lutris
sudo apt update
sudo apt install lutris

Sound Switcher Indicator

sudo apt-add-repository ppa:yktooo/ppa
sudo apt update
sudo apt install indicator-sound-switcher

gdu

curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
chmod +x gdu_linux_amd64
mv gdu_linux_amd64 /usr/bin/gdu

Telegram

sudo add-apt-repository ppa:atareao/telegram
sudo apt-get update
sudo apt-get install telegram

Signal

wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | sudo tee -a /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null

echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt/ xenial main' |\
  sudo tee -a /etc/apt/sources.list.d/signal.list

sudo apt update && sudo apt install signal-desktop

Papirus Icons

sudo add-apt-repository ppa:papirus/papirus
sudo apt-get update
sudo apt-get install papirus-icon-theme

Nextcloud Client

sudo add-apt-repository ppa:nextcloud-devs/client
sudo apt update
sudo apt install nextcloud-client    

Czkawka

sudo add-apt-repository ppa:xtradeb/apps
sudo apt update
sudo apt install czkawka

And some more software and extensions…

Lolcat https://nocin.eu/shell-neofetch-lolcat/

Cinnamon Extension Transparent panels

Cinnamon Applets QRedshift & Spices Update

Zsh https://nocin.eu/terminal-zsh-oh-my-zsh-powerlevel10k/

Thunderbird with https://addons.thunderbird.net/de/thunderbird/addon/tbsync/ + https://protonmail.com/bridge/ and Thunderbird Conversations (+ configuring birdtray!)

FreeOffice https://www.freeoffice.com/de/download/programme

SAP Gui https://nocin.eu/sap-install-sap-gui-for-java-7-50-on-linux-mint-20/

Steam https://store.steampowered.com/about/

Bashtop https://nocin.eu/software-bashtop-alternative-to-top-and-htop/

Syncthing Tray: https://github.com/Martchus/syncthingtray

Flatpacks: Bitwarden and TS3

FreeOffice: https://www.freeoffice.com/en

Increase GRUB Timeout (#)

sudo micro /etc/default/grub

# if not already set, update
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5

sudo update-grub

Create new shortcut for the “System Monitor”

Copying my dotfiles over. First the .aliases

alias ll='ls -Al --color=auto --block-size=MB --group-directories-first'
alias ls='ls -l --color=auto --block-size=MB --group-directories-first'
alias cp='cp -vRi'
alias rm='rm -vRi'
alias mv='mv -vi'
alias ln='ln -v'
alias mkdir='mkdir -pv' # Creates parent directories if needed
alias chown='chown -v'
alias chmod='chmod -v'
alias rmdir='rmdir -v'
alias ps='ps -f'
#alias tar='tar -xvf' #made some problems
alias df='df -Th'
alias lsd='lsd -Al --group-dirs first'
alias jobs='jobs -lr'

alias sudo='sudo ' #Allows for aliases to work with sudo.
alias pls='sudo $(history -p !!)'
alias wget='wget -qc --show-progress' #Download with WGet with pretty and useful features.
alias grep='grep -sI --color=auto' #Colorful (auto) 'grep' output.
alias psf='ps -faxc -U $UID -o pid,uid,gid,pcpu,pmem,stat,comm' #Less excessive, current-user-focused ps alternative.
alias klog="sudo dmesg -t -L=never -l emerg,alert,crit,err,warn --human --nopager" #Potentially useful option for viewing the kernel log.
alias lsblk='lsblk -o name,label,fstype,size,type,uuid'
alias ping='ping -c 5' # Stop after sending 5 pings


# Docker
alias dpsa='docker ps -a --format "table{{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Ports}}\t{{.Status}}"'

# Find commands I type often so I can alias them
# https://www.jakeworth.com/alias-terminal-commands/
alias typeless='history n 20000 | sed "s/.*  //"  | sort | uniq -c | sort -g | tail -n 100'

# Micro Editor
alias mic='micro'
alias nano='micro'

# Make mount command output pretty and readable
alias mnt='mount | column -t'

# jump to my download directory
alias dl='cd "$HOME"/Downloads'

# Youtube-dl
alias dlvid='youtube-dl --add-metadata --embed-thumbnail'
alias dlmp3='youtube-dl -x --audio-format mp3 --add-metadata --embed-thumbnail' 
alias dlbest='youtube-dl -f bestvideo+bestaudio'

# Git
alias git add .='git aa'
alias git commit -m='git cm'

# mkdir && cd
function mcd() {
    mkdir -p $1
    cd $1
}

# Archive extraction
# usage: ex <file>
ex ()
{
  if [ -f "$1" ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1   ;;
      *.tar.gz)    tar xzf $1   ;;
      *.bz2)       bunzip2 $1   ;;
      *.rar)       unrar x $1   ;;
      *.gz)        gunzip $1    ;;
      *.tar)       tar xf $1    ;;
      *.tbz2)      tar xjf $1   ;;
      *.tgz)       tar xzf $1   ;;
      *.zip)       unzip $1     ;;
      *.Z)         uncompress $1;;
      *.7z)        7z x $1      ;;
      *.deb)       ar x $1      ;;
      *.tar.xz)    tar xf $1    ;;
      *.tar.zst)   unzstd $1    ;;
      *)           echo "'$1' cannot be extracted via ex()" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}


# navigation
up () {
  local d=""
  local limit="$1"

  # Default to limit of 1
  if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
    limit=1
  fi

  for ((i=1;i<=limit;i++)); do
    d="../$d"
  done

  # perform cd. Show error if cd fails
  if ! cd "$d"; then
    echo "Couldn't go up $limit dirs.";
  fi
}

Followed by my .zshrc

neofetch | lolcat

# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME=powerlevel10k/powerlevel10k

# zsh-syntax-highlighting has to be the last plugin!
plugins=(git tmux zsh-autosuggestions zsh-syntax-highlighting)

# Preferred editor for local and remote sessions
 if [[ -n $SSH_CONNECTION ]]; then
   export EDITOR='micro'
 else
   export EDITOR='nano'
 fi

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

source $ZSH/oh-my-zsh.sh

if [ -f ~/.aliases ]; then
. ~/.aliases 
fi
eval $(thefuck --alias FUCK)

Megarac SP Gui / IPMI

In meinem NAS nutze ich seit vielen Jahren als Motherboard ein ASRock C2550D4I mit einer recht stromsparsamen on-Board CPU und einer BMC/IPMI Schnittstelle, welche Fernwartung über einen separaten LAN Port möglich macht.

BMC = Baseboard Management Controllers
IPMI = Intelligence Platform Management Interface

Bei einem BMC Update hat sich leider die WebGui verabschiedet und ich musste mir die Sache auf der Konsole anschauen. Dafür habe ich IPMITOOL installiert und verwendet. Dabei stellte sich heraus, dass lediglich die Netzwerkeinstellungen verloren gegangen sind.

Hier einige hilfreiche Befehle im Umgang mit dem IPMITOOL, welche mir geholfen haben. Über diesen Weg lässt sich ebenfalls das Passwort des Admin Users zurücksetzen.

# install 
sudo apt install ipmitool

# display sensor & network settings
sudo ipmitool sensor
sudo ipmitool lan print 1

#set network settings
sudo ipmitool lan set 1 ipsrc static
sudo ipmitool lan set 1 ipaddr 192.168.178.3
sudo ipmitool lan set 1 defgw ipaddr 192.168.178.1


# Reset password
# https://support.oneidentity.com/de-de/kb/261220/reset-the-bmc-ipmi-password
sudo ipmitool user list 1
ID  Name	     Callin  Link Auth	IPMI Msg   Channel Priv Limit
1                    false   false      true       ADMINISTRATOR
2   admin            true    true       true       ADMINISTRATOR
3                    true    false      false      NO ACCESS
4                    true    false      false      NO ACCESS
5                    true    false      false      NO ACCESS
6                    true    false      false      NO ACCESS
7                    true    false      false      NO ACCESS
8                    true    false      false      NO ACCESS
9                    true    false      false      NO ACCESS
10                   true    false      false      NO ACCESS
sudo ipmitool user set password 2
Password for user 2: 
Password for user 2: 
Set User Password command successful (user 2)


# IPMI reseten
# https://www.thomas-krenn.com/de/wiki/IPMI_BMC_reset_bei_IPMI_Problemen
sudo ipmitool mc reset cold
# or remote with
ipmitool -I lanplus -H ip_address -U admin -a bmc reset cold

# Wenn das nicht hilft, ggf. hier schauen:
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000CrKRCA0

[Software] Save battery power on laptops

With TLP I was able to extend the battery life of my ThinkPad E595 significantly.

“TLP is a feature-rich command line utility for Linux, saving laptop battery power without the need to delve deeper into technical details.”
https://linrunner.de/tlp/

If you prefer tools with UI, check TLPUI: https://github.com/d4nj1/TLPUI
There is also a repository for it:

sudo add-apt-repository ppa:linuxuprising/apps
sudo apt update
sudo apt install tlpui

When using a ThinkPad, there are specific kernel modules that can be installed.
https://linrunner.de/tlp/installation/ubuntu.html#thinkpads-only

Check with tlp-stat -b

Install with:

sudo apt install acpi-call-dkms tp-smapi-dkms

Another tool to monitor your power usage is PowerTOP:

“PowerTOP is a Linux tool to diagnose issues with power consumption and power management.”
https://01.org/powertop/

[Proxmox] Installing Cockpit with ZFS Manager extension

The Cockpit ZFS Manager requires Cockpit version 201 or above. In the Debian Buster repository there’s only cockpit version 188, so you have to use the buster backports repository, which contains cockpit version 223.

# install cockpit
echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/buster-backport.list
apt update
apt-get -t buster-backports install cockpit
# add ZFS manager
git clone https://github.com/optimans/cockpit-zfs-manager.git
cp -r cockpit-zfs-manager/zfs /usr/share/cockpit
# start cockpit
systemctl start cockpit.service
systemctl enable cockpit.service
systemctl status cockpit.service

Now browse to https://ip-address-of-machine:9090 and login.