Handy Linux Command Lines Reference

This is a collection of handy commands for Linux in one page for easy reference. This is a placeholder as more information about Linux will be coming to this web address.

Optimally zip-compress a file

This helps to save bandwidth when sharing your materials online. This produces the best zip files, but if you know the recipient has 7-Zip, you can usually make even smaller archives by using the 7z format instead of zip.

7z -mm=Deflate -mfb=258 -mpass=15 -r a myarchive.zip myfile.txt

Static compression for web server

You can pre-compress files for sending by your web server like this.

gzip -9fk *.js *.css *.htm*

Requires gzip_static on; in location / {} in your /etc/nginx/sites-available/default

Create a symbolic link

ln -s filename.ext linkname

Disable inertial scrolling with Synaptic

Very annoying when the mouse pretends you're scrolling when you're not.

synclient CoastingSpeed=0

Find a filename containing "butt" on removable media

This is not case sensitive.

find /media/ -iname "*butt*"

Find a filename containing "butt" anywhere in the computer

Not case sensitive. Errors are discarded.

find / -iname "*butt*" 2> /dev/null

Download all pictures on a page

wget -nd -H -p -A jpg,jpeg,png,gif,webp -e robots=off https://web.site/page

Page-pic-snarfing for fun and profit.

Show metadata of JPEG images in folder

See if privacy is compromised by photos shared.

gm identify -verbose *.jp*g

Close GIMP in one step LOL

pkill gimp*

Could result in corruption somewhere, but the thing is too annoying.

Close file-roller in one step

killall file-roller

Lately, I just use Alt-F4 twice to avoid having to use the mouse to click two buttons to close the damned thing.

Copy only files that are not the same

rsync -cav /source/folder/ /destination/folder/

Show differences between two files

ignores whitespace

diff -b file1.txt file2.txt

Extract a scene from a video

Extracts a scene starting at 1:05:30 and running for 18 seconds.

ffmpeg -ss 1:05:30 -i MyVid.mts -t 00:00:18 -vcodec copy -acodec copy MyScene.mts

Show information about a file

file MySong.mp3

Show information about an image file

identify favicon.ico

Show more information about a media file

ffprobe -hide_banner MySong.mp3

Show peak and mean volume of audio file

ffmpeg -i MySong.mp3 -af volumedetect -vn -f null - 2>&1 | grep "volume:"

Normalize volume & trim silence from start & end

Doing these in one step can save time and help avoid loss of quality. Adjust the values for start_silence to leave a bit of silence at the beginning and end of the audio file.

Freeze firefox temporarily

The window will not behave normally while frozen.

killall -STOP firefox

Unfreeze firefox

killall -CONT firefox

Reduce priority of firefox

renice 10 $(pgrep firefox)

Optimally recompress a PNG file

pngcrush -brute -reduce in.png out.png

Create a preview image of a PDF

pdftocairo -png -singlefile -scale-to-x 400 MyDocument.pdf

Show environment variables

printenv

Show status of all services

service --status-all

Show open ports

netstat -np


©2021-2025 Ron Spain