Home

Linux tips on command line

Updated December 13, 2009


I have been using Linux since 1999 and I have tried quite a few things. Sometimes I had questions I thought almost everybody new to Linux would be asking, yet answers turned out to be hard to find.

Here are some tips that I think could be useful, mainly (but maybe not only) to beginners.


Using GPG to password encrypt your personal files


Have a self-updating photo album with ImageMagick and PHP


Using DAR for your backups


Easily poll several mailboxes


Auxiliary bash functions


Using GPG to password encrypt your personal files


Type 'gpg --version' on the command line to check if you have GnuPG installed on your system. If you only get a message similar to:

bash: gpg: command not found
then you may click here to download GnuPG - The GNU Privacy Guard.

Encode script

Usage: gpgenc [-rhv] [-p password] [entryfile1] [entryfile2...]
 -k                 use asymetric coding to self
 -p password        give password on command line
 -r                 recurse into subdirs
 -l                 log password in system log - use with extreme care
 -v                 verbose, more comments displayed
 -h                 this help

 Encodes files and directories given as arguments using gpg symetric encoding.
 Files to encode must not begin with _
 A '_' character is prepended to the encoded file's name.
 Without args, encodes all non crypted files in current directory.

Decode script

Usage: gpgdec [-rlshv] [-p password] [entryfile1] [entryfile2...]
 -p password        give password on command line
 -r                 recurse into subdirs
 -l                 log password in system log - use with extreme care
 -s                 success : return at first failed decoding
 -v                 verbose, more comments displayed
 -h                 this help
 Decodes files and directories given as arguments using gpg symetric decoding.
 Encoded files must begin with _
 The initial '_' character is trimmed from the encoded file's name.
 Without args, decodes all crypted files in current directory.

Have a self-updating photo album with ImageMagick and PHP


If you have a web page were you display and share photographs, you don't need to bother editing it. PHP and ImageMagick will do that for you.

Type 'mogrify -version' on the command line to check if you have ImageMagick installed on your system. If you only get a message similar to:

bash: mogrify: command not found
then you should click here to download ImageMagick in order to convert, edit, and compose images.

Safely scale your pictures without overwriting the originals

Usage: mogscale [-hatv] [-l ratio] [-s ratio] [-d targetdir] file1 [file2 ...]
 -a              add slinks to thumbnails and source pictures in the current directory
 -l factor       enlarge the picture by factor x prepending lx_ to the new file
 -s factor       shrink the picture by factor x prepending sx_ to the new file
 -q factor       quality factor, for jpg
 -t              test, do no file operation
 -v              verbose, more comments displayed
 -d directory    all scaled files will go to directory. Default is the source file's directory.

Once you have run mogscale, upload the following files on the same directory than the images ( php server required for your website of course).

Don't forget to edit the two last files to reflect your specific data (see comments within those files)

Your page will display a small image linking to the full sized photograph


Using DAR for your backups


In construction

get Dar at dar's home page


Easily poll several mail boxes on the command line.


In construction

Use fetchmail to poll all your mailboxes and download your messages.