Handy Linux Commands

By , 31 July 2008

Handy Linux Commands

Images

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 *

Audio

Fix Canon WAV files:

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

Video

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

Filesystem

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}

Web

Download a website for offline reading:

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

Programming

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

Bash

While loop:

#!/bin/sh
i=0
while [ x -lt 5 ]
do
        # do something
        i=`expr $i + 1`
done

 

Handy Linux Commands

About Roger Keays

Handy Linux Commands

I guess I'd call myself a problem solver. Either that, or I'm some sort of organic machine designed to convert oxygen into carbon dioxide. You could go either way on that. I'm into languages and stuff. I wrote a book. It's okay, I guess. What else? I like reading, swimming, eating, and playing music. Satisfied? Sheesh.

Leave a Comment

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