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

chmod

Permission control on who can access files, search directories and run scripts.

cmus

A command line music player.

feh

Simple image viewer

ffmpeg

Commonly used commands to edit videos.

firefox

A complex beast.

gemini

A simple protocol for serving content over the internet.

git

Notes on the version control system

imagemagick

Commmonly used imagemagick commands.

launcher

How to add any file to the application launcher.

neomutt

A command line based e-mail client

micro

A terminal based text editor.

mime

Handling mime types.

pass

A command line password manager.

resilio sync

Peer to peer file syncing

rsync

Battle tested file synchronisation.

stardict

A command line dictionary.

tarballs

A container archive.

w3m

Notes on the command line browser.

incoming(1) | software