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

[Software] Using pdfunite to merge PDF documents

First install pdfunite:

sudo apt update 
sudo apt install poppler-utils

Syntax:

pdfunite source1.pdf source2.pdf merged_output.pdf

If a pdf file is located in a different folder, you have to add the path like this: $home/Downloads/source1.pdf
If you want to merge all pdf’s of the current folder you cant type:

pdfunite *.pdf merged_output.pdf

An alternative with GUI is PDF Arranger.

[Terminal] Shorcut overview

Further shortcuts:

Ctrl-LCleans the screen
Ctrl-YPastes back the stuff erased by Ctrl-K or Ctrl-U
Ctrl-CAborts a application
Ctrl-ZSuspend a application. Resume it again by fg (resume in foreground) and bg (resume in background).
Use jobs if you have multiple suspended applications and use fg %# (where # is the job number) to get it back on screen or end it with kill %#.
Ctrl-Dis same as typing exit
Pos1like Ctrl-A
Endlike Ctrl-E
Ctrl-RSearch terminal history
Ctrl-GExit searching terminal history

Some of the shortcuts are also recognized by other applications, like Ctrl-U on Ubuntu’s graphical login screen.

[Shell] Delete a folder and its content

If you downloaded a series there are often folders for each episode. Each episode folder often includes another folder called “Sample” with a short demo video file.

Series -> Season 01 -> Episode 01 -> Sample -> sample.mkv

To get rid of these you can use the “find” and “rm” command. To remove each sample folder with its content you have to use the remove command with an “-r”.

find -name "Sample" -exec rm -r "{}" \;

[Shell] SSH Passwordless Login Using SSH Keygen

Generate key, copy key to server and finally ssh passwordless into your server.

ssh-kegen -t rsa
ssh-copy-id root@ip
ssh root@ip

View your generated key with:

cat /home/user/.ssh/id_rsa           #local
cat /home/user/.ssh/authorized_keys  #server

To disable password authentication permanently you have to edit the ssh config. Be sure to first backup before editing. Now just set PasswordAuthentication to “no” in your config and restart the ssh daemon.

cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
nano /etc/ssh/sshd_config
service ssh restart

[Shell] zsh-autosuggestions

Simple plugin to get autosuggestions from your history while typing in your Zsh shell. If you are using Oh My Zsh, the installtion is done in 3 steps. Look here.
Just grab the plugin:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Add it in your ~/.zshrc (zsh config):

plugins=(zsh-autosuggestions)

And restart the terminal. Done.

[Mint] Install PyWal on Linux Mint 19.2 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 favourite programs.”
For the installation look at Github. In my case I had to run the following command:

sudo apt purge python3-pip && sudo apt install --install-recommends python3-pip && pip3 install pywal

To get an overview of your PyWal installation run:

pip3 show pywal

Test it with:

wal -v

If it returns “zsh: command not found: pywal” you have to add the PIP install directory to your path

export PATH="${PATH}:${HOME}/.local/bin/"

To use PyWal, just run it with wal -i and the path to an image.

wal -i /path/to/image.jpg

[Shell] Zsh + Oh My Zsh + Powerlevel10k

Install Zsh (Shell)
https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH

sudo apt install zsh
chsh -s $(which zsh)

Logout and login back again to use your new default shell.

echo $SHELL

Expected result: /bin/zsh


Install Oh My Zsh (Zsh framework with tools and themes)
https://github.com/robbyrussell/oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

In addition I installed the Powerline Fonts:

apt-get install fonts-powerline

Restart your terminal to launch the Oh My Zsh configuration.
After the installation and configuration I usually add “neofetch | lolcat” at the end of my zsh config: ~/.zshrc


Install Powerlevel10K (Powerlevel10k is a theme for ZSH)
https://github.com/romkatv/powerlevel10k#oh-my-zsh

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Set ZSH_THEME=powerlevel10k/powerlevel10k in your ~/.zshrc.

I also installed the patched Meslo Nerd Font and set it as terminal font. Else some icons will not be displayed in Powerlevel10k.
Restart your terminal and go through the configuration steps. The result will look similar to this:

Or like this:

Next you could install a Zsh plugin like: https://nocin.eu/shell-zsh-autosuggestions/

Or check the OMZ Cheatsheet: https://github.com/ohmyzsh/ohmyzsh/wiki/Cheatsheet

[Terminal] Neofetch + lolcat

1. Install neofetch.

sudo apt install neofetch

2. Install lolcat.

# When installing with "apt install lolcat", you will get version: lolcat 42.0.99
# To get the current version use:
sudo apt remove lolcat -y
wget https://github.com/busyloop/lolcat/archive/master.zip
unzip master.zip
rm master.zip
cd lolcat-master/bin
sudo gem install lolcat

3. Append the following line at the end of your ~/.bashrc (or at the beginning, if you are using zsh: ~/.zshrc) file, to get the neofetch output on every terminal run.

neofetch | lolcat

If you want to change the config of neofetch, you’ll find it here:

~/.config/neofetch/config.conf

[Shell] Replace pattern

How to replace a specific pattern in a file or folder name. In my case I needed to correct the season on each file of a series from “S08” to “S09”:

for f in *; do mv "$f" "$(echo "$f" | sed s/S08/S09/)"; done      

If you want to replace a pattern recursive, use the command “find”:

find . -name '*' -exec bash -c 'echo mv $0 ${0/S08/S09}' {} \;    // with echo for testrun