Useful Linux Commands

From Drake Panzer

Some useful commands.

Convert all .ppt files in the current directory to PDF's

libreoffice --headless --invisible --convert-to pdf *.ppt

Run command every N seconds

watch -n[seconds] [command]

View File Size

ls -l --block-size=[G/M]

Connect to SFTP server through intermediate SSH server

sftp -J [email protected] [email protected]

Old Way

  1. Create a ssh tunnel:

ssh [email protected] -L 2000:final:22 -N

  1. Connect to the local ssh tunnel with sftp:

sftp -P 2000 [email protected]

Fix Corrupt JPGs

mogrify -set comment 'Extraneous bytes removed' *.jpg

You can do *.png too.

Combine all text files in a directory

cat *.txt > merged.txt

Download YouTube Video/Playlist

youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' "[video, playlist URL]"

7zip Max Compession

7z a -t7z -m0=lzma2 -mx=9 -aoa -mfb=64 -md=32m -ms=on folder.7z folder/

Update all python3 pip packages

pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U

Generate Thumbnails in Gnome Files

Use Thumbgen.

Install pre-requisites: sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0

Install Thumbgen: pip install thumbgen

thumbgen -w 4 -r -d .