Nov 102011
 

I’ve recently discovered another useful package  for GNU/Linux, Littleutils.

The littleutils include a duplicate file finder (repeats), image optimizers (opt-jpg opt-png opt-gif recomp-jpg), file rename tools (lowercase uppercase), archive recompressors (to-bzip to-7zip to-lzma), a tempfile utility (tempname), all are small programs that do just 1 thing, in a perfect Unix style, so don’t expect anything too complex but these small gems can save you some time to do specific jobs.



Installation

The software is not available as package in some of the distro that i use (Debian, Ubuntu and CentOS), so this is a small list of operations that you can follow to build it from sources:

Installing littleutils: Ubuntu 11.04 (32-bit)

These instructions were tested with littleutils 1.0.24 and Ubuntu 11.04 (32-bit, desktop edition).

  1. Download the latest version of littleutils to your Download directory
  2. Open a terminal window (Applications -> Accessories -> Terminal)
  3. Move the download to a better location: sudo mv ~/Downloads/littleutils-1.0.24.tar.bz2 /usr/local/src/
  4. Use the root user account: sudo su
  5. Install dependencies: apt-get install gifsicle pngcrush lzip libpng12-0 libpng12-dev libjpeg-progs p7zip-full
  6. Uncompress littleutils: cd /usr/local/src && tar jxvf littleutils-1.0.24.tar.bz2 && cd littleutils-1.0.24
  7. Configure and install littleutils: ./configure && make && make install && make install-extra

Installing littleutils: CentOS 6.0 (32-bit)

These instructions were tested with littleutils 1.0.24 and CentOS 6.0 (32-bit, “Basic server” configuration).

  1. Log in as the root user.
  2. Enable the rpmforge repository: cd /usr/local/src/ && wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm && rpm -i rpmforge-release-0.5.2-2.el6.rf.i686.rpm
  3. Install dependencies: yum install gcc libpng libpng-devel gifsicle pngcrush p7zip lzip
  4. Download the latest version of littleutils: cd /usr/local/src; wget http://downloads.sourceforge.net/project/littleutils/littleutils/1.0.24/littleutils-1.0.24.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flittleutils%2F
  5. Uncompress littleutils: tar jxvf littleutils-1.0.24.tar.bz2 && cd littleutils-1.0.24
  6. Configure and install littleutils: ./configure && make && make install && make install-extra
Thanks to the author of CW image optimizer for this.

Using the utility

This is an overview of the small utility that you’ll get with this package.

filedate
filedate – print the modification times of the specified files

Example:

[root@linuxaria.com]# filedate /etc/ssh/*
/etc/ssh/moduli	2011-07-28 09:22:36
/etc/ssh/ssh_config	2011-07-28 09:22:36
/etc/ssh/sshd_config	2011-07-28 09:22:36
/etc/ssh/ssh_host_dsa_key	2011-10-26 03:18:28
/etc/ssh/ssh_host_dsa_key.pub	2011-10-26 03:18:28
/etc/ssh/ssh_host_key	2011-10-26 03:18:37
/etc/ssh/ssh_host_key.pub	2011-10-26 03:18:37
/etc/ssh/ssh_host_rsa_key	2011-10-26 03:18:28
/etc/ssh/ssh_host_rsa_key.pub	2011-10-26 03:18:28

filehash
filehash prints out various hashes (MD5, SHA1, SHA224, SHA256, SHA384, and/or SHA512) digests and (optionally) file sizes for the specified files.

Main options:

-1     Include the MD5 hash (128 bits) as part of the filehash output.
-2     Include the SHA1 hash (160 bits) as part of the filehash output.
-3     Include the SHA224 hash as part of the filehash output.
-4     Include the SHA256 hash as part of the filehash output.
-5     Include the SHA384 hash as part of the filehash output.
-6     Include the SHA512 hash as part of the filehash output.
-s     Include the filesize as part of the filehash output.

Example

[root@linuxaria.com]# filehash -s /etc/ssh/* 
/etc/ssh/moduli	125811	1c19eb605280ac13c556cc5b5960c10ca28a86e056c5dc10bae3e549de60c5e4
/etc/ssh/ssh_config	2117	1b0b70a71eeb7b0ae623f64b7f186471db2ff58544df5689772ef834c560ecb1
/etc/ssh/sshd_config	4108	1c081b298fcd03f37ea2b34b087e0d8d425ed1c00bb73f0106f5af23cbea29eb
/etc/ssh/ssh_host_dsa_key	668	57e9478137eba29b10b33b5e42280488f1b19640f9bcd4fb93a75a87582d5d7f
/etc/ssh/ssh_host_dsa_key.pub	611	02d524058d37405910ea90e106ad2f69320cfc6fc5c5761842f801eac52aa564
/etc/ssh/ssh_host_key	963	2b66ae9a07dd1b152ed82398dbe83a033b1e62aec1dbc63c641b0b8cc73b4ee6
/etc/ssh/ssh_host_key.pub	627	467bbbf0b2cddaffb8dca25cff0453618968eb1f164395b2be7e88a1cb1298e5
/etc/ssh/ssh_host_rsa_key	1675	832d4e537c1a05dc47316870340e9e1ef50e853d2874389c30a47f1420c054e4
/etc/ssh/ssh_host_rsa_key.pub	403	0bc05af3c11a683926a24a7b7c0afe723d1e8db8bc44d3c202bfbc2cd8b5fe3a

filemode
filemode prints out the file access permissions of the specified files.

Example

[root@linuxaria.com]# filemode /etc/ssh/*
/etc/ssh/moduli	0600
/etc/ssh/ssh_config	0644
/etc/ssh/sshd_config	0600
/etc/ssh/ssh_host_dsa_key	0600
/etc/ssh/ssh_host_dsa_key.pub	0644
/etc/ssh/ssh_host_key	0600
/etc/ssh/ssh_host_key.pub	0644
/etc/ssh/ssh_host_rsa_key	0600
/etc/ssh/ssh_host_rsa_key.pub	0644

filenode
filenode prints out the inode numbers of the specified files.

[root@linuxaria.com]# filenode /etc/ssh/*
/etc/ssh/moduli	28489
/etc/ssh/ssh_config	28612
/etc/ssh/sshd_config	28607
/etc/ssh/ssh_host_dsa_key	29013
/etc/ssh/ssh_host_dsa_key.pub	29014
/etc/ssh/ssh_host_key	29025
/etc/ssh/ssh_host_key.pub	29026
/etc/ssh/ssh_host_rsa_key	29011
/etc/ssh/ssh_host_rsa_key.pub	29012

fileown
fileown prints out (by default) the owner and/or (optionally) the group of the specified files.

[root@linuxaria.com]# fileown /etc/ssh/sshd_config 
root

filesize
filesize prints out the file size of the specified files in bytes.

[root@linuxaria.com]# filesize /etc/ssh/sshd_config 
4108

lowercase
lowercase renames files to all lowercase filenames. If a filespec containing path information is send to lowercase, only the filename portion itself will be renamed.

Example:

[root@linuxaria.com]# touch TEst
[root@linuxaria.com]# lowercase TEst 
TEst moved to test

uppercase
This is the opposite of lowercase, uppercase renames files to all uppercase filenames. If a filespec containing path information is send to uppercase, only the filename portion itself will be renamed.

randomize
randomize prints out the lines of one or more files in random order. If no file is specified, lines are taken from stdin.

Recompressors

Littleutils includes 5 programs that can be used to convert from an archive format to another, the base is the same from all, they converts .Z, .gz, and .bz2 files to a different archive format, the one that you see in the name of the command.

They are: to-7zip, to-bzip, to-lzip, to-lzma, to-xz

Example

[root@linuxaria.com]# tar -zcvf myssh.tar.gz /etc/ssh
/etc/ssh/
/etc/ssh/ssh_config
/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/sshd_config
/etc/ssh/moduli
/etc/ssh/ssh_host_key
/etc/ssh/ssh_host_key.pub
/etc/ssh/ssh_host_dsa_key.pub
 
[root@linuxaria.com]# to-xz myssh.tar.gz
myssh.tar.gz... done
 
[root@linuxaria.com]# to-bzip myssh.tar.gz 
myssh.tar.gz... done (warning: new file is not smaller)
 
[root@linuxaria.com]# ls -l myssh.tar.*
 
-rw-r--r-- 1 root root 18273 Nov 10 19:11 myssh.tar.bz2
-rw-r--r-- 1 root root 14161 Nov 10 19:09 myssh.tar.gz
-rw-r--r-- 1 root root 11864 Nov 10 19:10 myssh.tar.xz

Image Optimization

There is another big group of utility in this package, 3 programs that can optimizes your images: opt-gif, opt-jpg and opt-png.

opt-gif losslessly optimizes GIF images by removing unused palette entires. This is accomplished using the gifsicle, filesize, and tempname utilities.

opt-jpg losslessly optimizes JPEG images. This is accomplished using a combination of the filesize, jpegtran, and tempname utilities

opt-png losslessly optimizes PNG images by removing unused palette entries and/or optimizing the filtering algorithm. This is accomplished using a combination of the filesize, pngcrush, pngrecolor, pngstrip, and tempname utilities.

With these utility you can save from 5% to 15% of the size of your images.

And if you use WordPress as CMS i suggest to check the plugin CW Image Optimizer.
The CW Image Optimizer is a WordPress plugin that will automatically and losslessly optimize your images as you upload them to your blog. It can also optimize the images that you have already uploaded in the past.

Conclusions

In this article I’ve show some of the 31 small utility that are included in this package, a lot of these results can be achieved by others commands and or combinations, but i like specific commands to do just a small thing, they are a good addition in any Linux user arsenal.

Popular Posts:

flattr this!

  2 Responses to “Littleutils, a Great collection of small utility”

  1. Very nice find. It’s in my toolbox now.

  2. Great Utilities…
    Will definitely try this…

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>