linux

Notes on the unix based operating system.

Linux is free as in freedom.

It offers users the freedom to use, adapt and develop the system in any way they please.

Freedom is a double sided sword.

While there is a plethora of tools and options to choose from, there are just as many inconsistencies between them.

Prepare for cuts.

To adapt Linux to your needs, stay willing to spend time with your operating system, stay curious, educate yourself and stay stubborn enough to persist. It gets easier over time.

I'm currently running Ubuntu on my workstation Trabant.

raspi

Notes on the raspberry pi.

ubuntu

A flavor for Linux

When I switched to Linux in spring 2020 I tested an array of different Linux distributions on my 2021 Macbook. The only one I could get to run reliably was Ubuntu.

Today I'm running on a ThinkPad - see Trabant - but I've stuck with Ubuntu. I use Regolith, a pre-configured conglomerate of desktop tools built on top of GNOME and i3. It focuses on keyboard driven terminal use but is versatile enough to handle most of my needs.

For a list of tools that I use, see software.

terminal

Navigating the terminal

I use the gnome-terminal on my main workstation.

Cheatsheet

Basic command line programs for every day use.

cmd Description
cd change directory
ls list directory content
pwd print working directory
mv move/rename file
cp copy file
man shows the manual of a program
lp send file to the local printer
clear clears the terminal screen
fg returns to a program running in the background
sudo execute command as priviledged user
sudo !! execute previous command as priviledged user
~ shortcut for the home directory

Shortcuts

These shortcuts work in Bash.

Tab autocompletes directory and filenames
Alt modifier to jump to next space
Ctrl+C aborts programs by sending the SIGINT signal
Ctrl+Z sends SIGSTP to move the terminal above the currently running program
Ctrl+L clears the terminal screen
Ctrl+D log out of the terminal and close it
Ctrl+A move the cursor to the start of the line
Ctrl+E move the cursor to the end of the line
Ctrl+U clear the line towards the beginning
Ctrl+K clear the line towards the end
Ctrl+W delete last word
Ctrl+K delete the rest of the line after the cursor

Miscellaneous

Toggle the closing confirmation dialog:

gsettings set org.gnome.Terminal.Legacy.Settings confirm-close true/false

To check the setting, use:

gsettings get org.gnome.Terminal.Legacy.Settings confirm-close

utilities

Various commands.
trash-restore filename

Restoring deleted files

pdfunite file01.pdf file02.pdf output.pdf

Combine two pdfs to one

youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' video_URL

Downloading a video in best quality

youtube-dl -x --audio-format mp3 video_URL

Download audio only

command | more

Paging long-scrolling output

sed -i "s/$OLD/$NEW/g" *.txt

Replace string in multiple files

whereis applicationname

Find the location of an application

for file in *; do mv "$file" echo $file | tr ' ' '_' | tr '[:upper:]' '[:lower:]' ; done

Change all filenames to lowercase and replace all spaces with underscores in a directory:

xclip -selection clipboard -t image/png -i example.png

Copy an image to the clipboard

date --date='TZ="Continent/City" localTZTime Date/Day'

Print local time of a date and time in a different timezone

tzselect

Find the available timezones

for f in *.zip; do unzip "$f" -d "${f%.zip}"; done

Extract all .zip files in folder creating a new director with the name of the file for each

Debian Packages

Install .deb files

sudo dpkg --install packagename.deb

List installed dpkg packages sorted by size

dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'

Clearing System Logs

journalctl --disk-usage
journalctl --rotate
sudo journalctl --vacuum-files=5

Set SystemMaxUse=100M in /etc/systemd/journald.conf to limit maximum journaling space.

Use systemctl daemon-reload to update.

For printing commands, see printer.

incoming(2) | trabant | ubuntu