I think, therefore I blog

Handy Linux Commands

By , 31 July 2008

Handy Linux Commands


Resize images:

$ mogrify -resize 50% *

Replace/attach image colour profile:

$ mogrify -profile ~/etc/argb.icc *

Lossless jpeg rotation based on EXIF data:

$ exifautotran *

Set the modification date of a photo based on EXIF data:

$ jhead -ft *


Fix Canon WAV files:

$ ffmpeg -acodec copy -i file.wav file2.wav


Capture from video in (ffmpeg):

$ ffmpeg -ac 2 -ar 48000 -f oss -i /dev/dsp -s 720x576 -r 25 -f video4linux2 -i /dev/video0 -y -ac 1 -ab 192k -qscale 4 out.avi

Capture from video in (mencode):

$ mencoder tv:// -tv driver=v4l2:width=720:height=576:normid=4:input=0:fps=25:forceaudio:adevice=/dev/dsp:audiorate=48000 -oac mp3lame -lameopts br=224:mode=3 -ovc lavc -lavcopts vcodec=mpeg4:vqscale=4 -endpos 1:05:00 -o out.avi

Convert mjpeg to mpeg4:

$ ffmpeg -i file.avi -r 27 -qscale 6 -ab 128K -vcodec mpeg4 file.b.avi

Convert directory of mjpegs to mpeg2 and retain creation dates:

$ for i in *.avi; do ffmpeg -i $i -r 27 -ab 128K -sameq -vcodec mpeg2video ${i:0:${#i}-4}.mpg; touch -r $i ${i:0:${#i}-4}.mpg; done;

Convert ogg vorbis to flash video (requires mp3 support):

$ ffmpeg -i file.ogv -sameq file.flv


Loop over a list of files which contain spaces:

$ ls -1 | while read x; do echo $x; done

Convert absolute symlinks to relative ones (must be run twice):

$ symlinks -c -s .
$ symlinks -c -s .

Sync home dir with external hard drive:

$ rsync --delete --exclude ".*" --exclude Bureau --exclude tmp \
        -av /home/roger/ /media/disk

Convert DOS text file to UNIX:

$ apt-get install tofrodos
$ dos2unix {file}


Download a website for offline reading:

$ wget -E -p -r -l inf -np -k http://www.example.com


Edit a log message:

$ svn propedit svn:log svn+ssh://svn.ninthavenue.com.au/blah -r11 --revprop

Import an upstream release (e.g. fckeditor):

~/fckeditor $ svn import svn+ssh://svn.ninthavenue.com.au/apps/fckeditor/tags/2.6.0

Merge custom changes into new upstream release:

~ $ svn co svn+ssh://svn.ninthavenue.com.au/apps/fckeditor/branches/2.6.0-webcore fckeditor
~ $ cd fckeditor
~/fckeditor $ svn merge svn+ssh://svn.ninthavenue.com.au/apps/fckeditor/tags/2.5.1 svn+ssh://svn.ninthavenue.com.au/apps/fckeditor/branches/2.5.1-ninthavenue

Install / add a jar file into maven:

mvn install:install-file -Dfile=jboss-el-2.0.1.jar -DartifactId=jboss-el -DgroupId=org.jboss.el -Dverion=2.0.1 -Dpackaging=jar


While loop:

while [ x -lt 5 ]
        # do something
        i=`expr $i + 1`


Handy Linux Commands

About Roger Keays

Handy Linux Commands

Roger Keays is an artist, an engineer, and a student of life. Since he left Australia in 2009, he has been living as a digital nomad in over 40 different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, and finding good food. Click here to subscribe to his weekly blog, or stalk him on Facebook and Twitter.

Leave a Comment

Please visit https://RogerKeays.com/handy-linux-commands to add your comments.

Join Over 1000 Subscribers

I write every Sunday about travel, psychology, and technology. Thousands of people just like you have already subscribed—and for good reason. It'll change your life. And it's free :)

Read a Good Book

“A spellbinding true story of love, passion and adventure. One can’t help but be swept away by 100% Love Guaranteed.” —Dr Tammie Matson, author of Elephant Dance.

Chat For A While

Your Vote Matters

Which animal will take over when humans go extinct?