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.

I switched to a P50 ThinkPad - see rosinante - 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.

In 2023 I finally found someone who could fix my Macbook and I've been using it for communications and on the go - see trabant.

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

terminal

Navigating the terminal

I use the gnome-terminal on trabant and rosinante.

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.

Disk Space

df -h

Lists all partitions and their disk usage

du -hs directoryname/

Returns the total size of everything inside directoryname

sudo du -cha -d 1 /directoryname | sort -nr | head -20

Lists the size of all subdirectories of directoryname

Download Videos / Music

yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' 

Downloading a video in best quality

yt-dlp -x --audio-format mp3 

Download audio only

yt-dlp --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist 

Downloads a playlist as mp3

String Manipulations

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

Replace string in multiple files

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

cat filename | grep -C 3 searchterm

Display's the content of a file searching for searchterm and displaying 3 lines of context before and after a match.

Time

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

Miscellaneous

command | more

Paging long-scrolling output

whereis applicationname

Find the location of an application

trash-restore filename

Restoring deleted files

pdfunite file01.pdf file02.pdf output.pdf

Combine two pdfs to one

unzip /*.zip

Unzip all archived files inside directory

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

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}'

Updating python packages

python3 -m pip install  --upgrade 

or

pip3 install  --upgrade

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.

Add an even in khal

khal new -a "Calendar Name" 240227 17:00 18:00 Event Description

incoming(4) | trabant | trabant | rosinante | ubuntu