Various commands.

Most commands use placeholder path and file names. When using the commands replace them with the actual file paths, user and servernames.

Disk Space

 df -h

Lists all partitions and their disk usage

 du -hs directoryname/

Returns the total size of everything inside directoryname

 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 -f ba --extract-audio --audio-format mp3 --audio-quality 160K -o "%(title)s.%(ext)s" --yes-playlist 

Downloads a playlist as mp3

Download Website

 wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://website.com

Downloads a complete copy of a website

 wget -p -k https://website.com/page.html

Downloads a single page of a website.s

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

Fonts

Place font files in /.fonts/ or in /.local/fonts/ and reload the font cache.

 fc-cache -fv

Fonts can also be placed in subdirectories for better organisation.

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

Mounting a remote filesystem with SSHFS

 sshfs -o allow_other,default_permissions servername:remote/directory/path local/directory/path

Option allow_other only allowed if user_allow_other is set in /etc/fuse.conf

 sudo fusermount3 -u /local/directory

Unmounts the directory

To permanently mount a remote directory, add the following line to /etc/fstab:

 servername:remote/directory/path /local/directory/path fuse.sshfs noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/username/.ssh/id_rsa,allow_other,default_permissions 0 0

Rendering a PDF with form fields with ghostscript

 gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

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.

Web Browser

Navigating the web..

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.

incoming(1) | software