Tag Archives: tip

Useful aptitude commands

A simple list of installed packages

max@wonko:~$ aptitude search '~i' -F '%p'

Search for installed packages from the testing repo

max@wonko:~$ aptitude versions '~i ~Atesting' --group-by=none

Finding why a package is installed

I found fonts-font-awesome in my headless server, but there’s a reason

max@wonko:~$ aptitude why fonts-font-awesome
i   owncloud Depends fonts-font-awesome

Select packages that were removed but not purged

max@wonko:~$ aptitude search '~c'

Search in the package description

max@wonko:~$ aptitude search '~d"web browser"'

Upgradable packages

max@wonko:~$ aptitude search '~U'

Restore an etc configuration file from the original maintainer version on Debian

There are events that can not be stopped, for example when you delete a file by mistake under /etc.

Debian provides an elegant way to restore files of the maintainer’s version without touching your existing configuration.

Practical scenario

Let’s say I’ve removed the file /etc/apache2/sites-available/000-default.conf, here’s the procedure to recover it:

  • find the deb package containing the file
    # dpkg -S /etc/apache2/sites-available/000-default.conf
    
  • reinstall the package with a specific option
    # apt-get install --reinstall -o Dpkg::Options::="--force-confmiss" apache2
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 5 not upgraded.
    Need to get 86,7 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    Get:1 http://archive.ubuntu.com/ubuntu/ saucy-updates/main apache2 amd64 2.4.6-2ubuntu2.1 [86,7 kB]
    Fetched 86,7 kB in 0s (264 kB/s)
    (Reading database ... 245864 files and directories currently installed.)
    Preparing to replace apache2 2.4.6-2ubuntu2.1 (using .../apache2_2.4.6-2ubuntu2.1_amd64.deb) ...
    Unpacking replacement apache2 ...
    Processing triggers for man-db ...
    Processing triggers for ufw ...
    Processing triggers for ureadahead ...
    ureadahead will be reprofiled on next reboot
    Setting up apache2 (2.4.6-2ubuntu2.1) ...
    
    Configuration file `/etc/apache2/sites-available/000-default.conf', does not exist on system.
    Installing new config file as you requested.
     * Restarting web server apache2
       ...done.
    

That’s all.

Practical scenario #2

There’s another interesting case when this procedure comes handy: if you changed a default etc file and you want to restore it. In that case you can simply delete it and use the same apt-get command:

# apt-get install --reinstall -o Dpkg::Options::="--force-confmiss" <package name>

References

Meet the “It’s All Text!” Firefox extension

Yes, I’m a vim addicted. I mean vim the text editor. I’m so addicted to it that I tend to use vim’s shortcuts even in LibreOffice documents, thunderbird e-mails, web forms etc. with awful results.

Then I found It’s All Text, a Firefox extension which saved my web experience when editing long textareas.

It’s really simple: it puts an overlay “edit” button beside each textarea which is visible only when overing it. When you click it, your preferred editor will come up filled of the text of the textarea. Now you can make your edits, close it and boom, the text is in the textarea.

Wonderful.

For me it’s a productivity boost.

I use it everywhere, like now, I’m writing this blog post in my preferred editor.

The nerd tip

There a deeper tip I use: I’m opening vim from a gnome-terminal.

I created a bash script under my $HOME/bin directory with this name editor-for-it-s-all-text.sh and which content is

#!/bin/bash
/usr/bin/gnome-terminal --full-screen -e "vim '$1'"

Then I configured “It’s All Text” to use that editor and now I use my beloved vim in a full screen terminal window.

Awesome.