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

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 two aliases to my .bashrc:

alias dict='sdcv --color'
alias synonym='sdcv --color --use-dict Synonyms'
dict wordlooks up a word in all available dictionaries
synonym wordlooks up a word in the english synonym 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.

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

Rotating

mogrify -rotate "90" file.png

Rotates an image by 90 degrees clockwise.

Cropping

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

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.png output.png

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

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

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

Resizing

mogrify -geometry 50% file.png

Resizes the image down by half.

mogrify -geometry 1024x file.png

Resizes the image to a width of 1024px.

mogrify -geometry x800 file.png

Resizes the image to a height of 800px.

mogrify -geometry 800x800 file.png

Resizes the image to 800px at the longer side.

mogrify -density 72 -units pixelsperinch file.png

Changes the DPI of the image to 72.

Dithering

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

Dithers the image with 8 colors.

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

Dithers the image using a colortable.

Tiling

montage * output.png

Tiles all images in folder.

montage * output.png -background "#000000"

Sets the background color the black.

PDF conversion

convert file.pdf -flatten output.png

Converts a pdf to.png

Image Sequencing

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

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

Information

identify file.png

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)

incoming(1) | gnome programs