Keep repeating a command until it fails

That may be useful to make some kind of stress testing or to “ensure” the command is doing right.

Pretty simple:

$ while ./command; do true; done

Autenticación básica en IceGrid

— [ edit | raw ]

Esta receta muestra cómo proporciona, de una forma sencilla, un mecanismo de autenticación a IceGrid.

Fixing damaged /var/lib/dpkg/available

Sometimes the file /var/lib/dpkg/available is corrupted. When you use the package managing tools you get messages similar to these:

dpkg: warning: parsing file '/var/lib/dpkg/available' near line 1128 package 'dash':
 missing description
dpkg: warning: parsing file '/var/lib/dpkg/available' near line 2687 package 'login':
 missing description

Usually this is not a big issue but it may be annoying. To fix it, just execute next commands:

# mv /var/lib/dpkg/available /root/
# touch /var/lib/dpkg/available
# sh -c 'for i in /var/lib/apt/lists/*_Packages; do dpkg --merge-avail "$i"; done'

Seen at http://askubuntu.com/questions/109994/dpkg-error-parsing-file-var-lib-dpkg-status-near-line-6449

Reading a properties file with augeas

augeas is a command line generic tool to manage configuration text files. augeas comes with many “lenses”. The lenses are files that specify rules to read and write each kind of file. This is a very good to for scripting or automatic configuration management (like puppet does).

Fine-grain sudo

sudo lets a user run commands as she was a different user (usually root). The common configuration of sudo requests your password before run the command. As that is annoying, you may be tempted to write something like this in your /etc/sudoers:

john   ALL = ALL, NOPASSWD: APT

But this may be a big security issue…

git: removing files from history

That deletes the given files from all the changesets along all the repository history, as they never were commited.

It is not a very friendly command (it’s the git style!), but at least it can be done.

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' --prune-empty --tag-name-filter cat -- --all
$ rm -rf .git/refs/original
$ git reflog expire --expire=now --all
$ git gc --prune=now
$ git gc --aggressive --prune=now
$ git push --force

Far as I know this is not possible with mercurial

References

  • http://stackoverflow.com/questions/5563564/remove-files-from-git-repo-completely
  • https://help.github.com/articles/remove-sensitive-data

Compacting .vmdk virtual disk with VirtualBox

VirtualBox is able to compact (reduce the size) .vdi images, but it is not possible with .vmdk disk images. So…

Debian apt pinning

Configuración mínima para apt-pinning

Changing primary monitor

When you have a dual head display one of them is the “primary monitor”. Usually, window manager put special panels or content in that monitor (gnome-shell).

To see which are your connected monitors (and their names) run:

$ xrandr | grep connected
DVI-I-0 disconnected (normal left inverted right x axis y axis)
VGA-0 disconnected (normal left inverted right x axis y axis)
DVI-I-1 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 530mm x 300mm
HDMI-0 connected 1920x1200+1920+0 (normal left inverted right x axis y axis) 530mm x 300mm

In this case my primary monitor is DVI-I-1. To change to the other available monitor, run:

$ xrandr --output HDMI-0 --primary

Cheers

VirtualBox: import/export and cloning machines

VirtualBox supports the OVF (Open Virtualization Format) and the OVA package (an single archive format).