Skip to content

Basics

GNU/Linux basics

Useful commands

Find duplicated lines and count how many times they appear in a file

sort <file> | uniq -c

Get command output or default value if emtpy

echo | sed 's/^$/default value/'

Get the cursor position

Useful for recording part of the screen with (ffmpeg)[ffmpeg].

watch -n 0.1 xdotool getmouselocation

Generate a random string

Generate a random string to use for secrets or passwords:

head /dev/urandom | tr -dc A-Za-z0-9 | head -c10