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.

terminal cheatsheet

Basic command line programs for every day use.
cmdDescription
cdchange directory
lslist directory content
pwdprint working directory
mvmove/rename file
cpcopy file
manshows the manual of a program
lpsend file to the local printer
clearclears the terminal screen
fgreturns to a program running in the background
sudoexecute command as priviledged user
~shortcut for the home directory

gnome programs

Default GNOME applications.

GNOME is the default desktop environment on many Linux distributions.
It comes with a set of pre-installed software, most of which use an alias when presented in the launcher or the GUI.
The following list presents their actual names and are used to run them from the terminal.

evincedocument viewer
eogimage viewer (Eye of GNOME)
nautilusfile manager

terminal shortcuts

Shortcuts to navigate the command line.

These shortcuts work in Bash.

Tabautocompletes directory and filenames
Altmodifier to jump to next space
Ctrl+Caborts programs by sending the SIGINT signal
Ctrl+Zsends SIGSTP to move the terminal above the currently running program
Ctrl+Lclears the terminal screen
Ctrl+Dlog out of the terminal and close it
Ctrl+Amove the cursor to the start of the line
Ctrl+Emove the cursor to the end of the line
Ctrl+Uclear the line towards the beginning
Ctrl+Kclear the line towards the end

rsync

Battle tested file synchronisation.

rsync stands for remote sync and is a remote and local file synchronisation program.

Usage

rsync $source $destination

Options

a - archive/preserve permissions/recurse
v - verbose output (doesn't work with --info=progress2)
t - preserve modification time
u - update (skip files newer on the receiver)
P - show file progress
n - dry run
h - human readable file sizes
z - compression during transfer

Examples

rsync -a --exclude={'file.txt','dir1','dir2/*'}

Excludes file.txt, dir1 and the content of dir2.

tarballs

A container archive.

A .tar.gz file is a container archive. It can bundle multiple files into one. To compress the package content, an additional programm such as gzip is needed.

tar xvzf file.tar.gz

Options

x - tells tar to extract the files
v - verbose (outputs process information to the command line)
z - tells tar to uncompress the files
f - tells tar that a file name is provided

linux helpers

Various commands.

Install .deb files

sudo dpkg --install packagename.deb

Print from command line

lp filename

Restoring deleted files

trash-restore filename

Combine two pdfs to one

pdfunite file01.pdf file02.pdf output.pdf

Downloading a video in best quality

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

stardict

A command line dictionary.

I use sdcv (StarDict Console Version) as my regular dictionary.

The following dictionaries are currently installed, stored at /usr/share/stardict/dic/

American_Heritage_Dictionary_4th_Ed-2.4.2
Cambridge_Advanced_Learners_Dictionary_3th_Ed-2.4.2
dictd_www.dict.org_gcide-2.4.2
duden-2.4.2
freedict-deu-eng-2.4.2
freedict-eng-deu-2.4.2
Oxford_Advanced_Learner_s_Dictionary-2.4.2
Soule_s_Dictionary_of_English_Synonyms-2.4.2
Urban_Dictionary_P1-2.4.2
Urban_Dictionary_P2-2.4.2

I added these aliases to my .bashrc:

alias dict='sdcv --color --use-dict=GermanEnglish --use-dict=EnglishGerman'
alias define='sdcv --color --use-dict=AmericanHeritageDictionary --use-dict=CambridgeDictionary'
alias definiere='sdcv --color --use-dict=Duden'
alias synonym='sdcv --color --use-dict=Synonyms'
alias urban='sdcv --color --use-dict=UrbanDictionaryP1 --use-dict=UrbanDictionaryP2'

For some dictionaries, their .ifo file needs to be edited as the bookname value must not contain any spaces.

Usage

dict wordtranslates a word from German to English or vice versa
define wordlooks up a word in English dictionaries
definiere wordlooks up a word in German dictionaries
synonym wordlooks up a word in the english synonym dictionary
urban wordlooks up a word in the Urban dictionary

cmus

A command line music player.

Control

x - play
c - pause
v - stop
z - previous track
b - next track
u - update cache

Search

/ - search
n - search next
N - search previous

Toggles

M - toggle play library/playlist
s - toggle shuffle
o - toggle shuffle album
r - toggle repeat
^R- toggle repeat current

Playlist Editing

y - copy selected tracks to playlist
p - move track down
P - move track up
D - remove track

Commands

Press : to enter commands.

win-sel-cur - jump to currently playing track
add - add file/dir
clear - remove all tracks from view
pl-create - creates a new playlist
pl-rename - renames the selected playlist
unmark - clear track selection

Configuration

To switch the default active/inactive row highlighting, set these options

set color_win_inactive_sel_fg=default
set color_win_inactive_sel_bg=blue
set color_win_sel_bg=white
set color_win_sel_fg=black
set color_win_cur_sel_fg=blue
set color_win_cur_sel_bg=white

launcher

How to add any file to the application launcher.

Create a desktop file at ~/.local/share/applications and and add application information such as application path, icon path, etcetera.

Example

[Desktop Entry]
Type=Application
Name=Ripcord
Comment=Ripcord Chat Client
Exec=/home/rostiger/bin/Ripcord.AppImage
Icon=/home/rostiger/bin/Ripcord.png
Terminal=false
Categories=Communication

imagemagick

Commmonly used imagemagick commands.

ImageMagick is an open source tool for editing and converting raster images created in 1987 by John Cristy.

I use ImageMagick on the command line for quick image edits such as cropping, resizing or rotating. It is also used in the batchVariants script that prepares the images for this website.

Use convert to create a new output file or mogrify to overwrite the input file.

Rotating

mogrify -rotate "90" file.jpg

Rotates an image by 90 degrees clockwise.

Cropping

convert -crop 640x480+50+100 +repage input.jpg output.jpg

Crops the image at X:50 Y:100 to a size of W: 640 H:480.
+repage will prevent export of the cropped area.

convert -crop 3:2+50+100 +repage input.jpg output.jpg

Crops the image at X:50 Y:100 to a ratio of W: 3 H:2

convert -crop 3:2+50+100 +repage input.jpg output.jpg

Crops the image at X:50 Y:100 to a ratio of W: 3 H:2

Resizing

mogrify -geometry 50% file.jpg

Resizes the image down by half.

mogrify -geometry 1024x file.jpg

Resizes the image to a width of 1024px.

mogrify -geometry x800 file.jpg

Resizes the image to a height of 800px.

mogrify -geometry 800x800 file.jpg

Resizes the image to 800px at the longer side.

mogrify -density 72 -units pixelsperinch file.jpg

Changes the DPI of the image to 72.

Dithering

convert input.jpg -dither FloydSteinberg -colors 8 output.jpg

Dithers the image with 8 colors.

convert input.jpg -dither FloydSteinberg -remap colortable.gif output.jpg

Dithers the image using a colortable.

Tiling

montage * output.jpg

Tiles all images in folder.

montage * output.jpg -background "#000000"

Sets the background color the black.

PDF conversion

convert file.pdf -flatten output.jpg

Converts a pdf to.jpg

Image Sequencing

convert -delay 200 -loop 0 *.jpg output.gif

Creates an infinitely looping GIF with 2 seconds delay between each frame.

Information

identify file.jpg

Displays information on the file such as width and height.

Offline Documentation

To make the documentation available offline, install the imagemagick-6-doc package.

pass

A command line password manager.

Pass lets you encrypt text files containing any type of data you wish, most commonly user credentials.

Using pass with an existing database can be tricky. To fix the initialisation error, transfer ~/.gnupg from your old device to the new one.

Fix the permission warning gpg: WARNING: unsafe permissions on homedir '/home/rostiger/.gnupg' by setting the folder permission to 700:

sudo chmod 700 .gnupg/

Set all files inside the folder to 600 using:

sudo chmod 600 *

Now set the permissions for pubring.kbx and private-keys-v1/:

drwx------  private-keys-v1.d/ (Create and Delete Files)
-rw-rw-r-- pubring.kbx (Read & Write for Owner and Group, Read for Others)

resilio sync

Peer to peer file syncing

Resilio Sync can share and sync files directly between peers.

To run sync under the current user enter

systemctl --user enable resilio-sync
systemctl --user start resilio-sync

The webinterface will be available at

https://127.0.0.1:8888

gemini

A simple protocol for serving content over the internet.Modern web browsers are complex beasts. In fact, they are so complex that one can create a fully functional virtual machine inside one and run another operating system! The software stack towers ever higher, and hardware needs to be ever more powerful and complicated to run it well. If one seeks to just read text and view images, this is absurd overkill.

Gemini is a small internet alternative to HTTP and HTML. It specifies a Markdown inspired format allowing basic plain text document markup.

Registering the Gemini mime type

To open gemtext files and let browsers like Firefox recognize a Gemini link they need to be registered with GNOME by adding it to the mime database.

Create a file at /usr/share/mime/packages/ called gemini.xml and add the following content:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="text/gemini">
    <comment>Gemtext</comment>
    <glob pattern="*.gmi"/>
  </mime-type>
</mime-info>

Update the mime database with

sudo update-mime-database /usr/share/mime

Add the line MimeType=x-scheme-handler/gemini;text/gemini; to the .desktop file of the client.

Run update-desktop-database ~/.local/share/applications to update the desktop database and add your client to the list of applications that can open gemtext files.

incoming(2) | trabant | gnome programs