Archive

Archive for April, 2010

Using The Debian Alternatives System

April 28th, 2010 No comments

debianThere are several cases where two packages provide two different versions of a program, both of which provide the same core functionality. Users might prefer one over another out of habit, or because the user interface of one package is somehow more pleasing than the interface of another. Other users on the same system might make a different choice.

For example, there might exist two different versions of newsreaders on a system. Which program is invoked is determined by a link pointing from a file with the virtual package name /etc/alternatives/vim to the selected file, e.g., /usr/bin/vim.gtk.

The Debian system has mechanism to install somewhat overlapping programs peacefully using update-alternatives(8). The Perl script update-alternatives provides a way of ensuring that all the files associated with a specified package are selected as a system default.

For example, you can make the vi command select to run vim while installing both vim and nvi packages.

The Debian alternatives system keeps its selection as symlinks in “/etc/alternatives/“. The selection process uses corresponding file in “/var/lib/dpkg/alternatives/“. The “/etc/alternatives” defines default applications for the Debian system – such as, the default application to handle editor, to browse the web etc.

For example, to check what executables provide `vim’, run:

$ sudo update-alternatives --display vim
vim - status is auto.
link currently points to /usr/bin/vim.gtk
/usr/bin/vim.tiny - priority 10
/usr/bin/vim.basic - priority 30
/usr/bin/vim.gtk - priority 50
Current `best' version is /usr/bin/vim.gtk.

or use the ls command

$ ls -l $(type -p vim)
lrwxrwxrwx 1 root root 21 2008-09-27 13:10 /usr/bin/vim -> /etc/alternatives/vim
$ ls -l /etc/alternatives/vim
lrwxrwxrwx 1 root root 16 2010-01-23 14:06 /etc/alternatives/vim -> /usr/bin/vim.gtk

If you want to change it, run:

$ sudo update-alternatives --config vim
There are 3 alternatives which provide `vim'.
  Selection    Alternative
-----------------------------------------------
          1    /usr/bin/vim.tiny
          2    /usr/bin/vim.basic
*+        3    /usr/bin/vim.gtk
 
Press enter to keep the default[*], or type selection number:

And follow the instructions on the screen (basically, press the number next to the entry you’d like better).

To change the default web browser run:

$ sudo update-alternatives --config x-www-browser
There are 3 alternatives which provide `x-www-browser'.
  Selection    Alternative
-----------------------------------------------
*         1    /usr/bin/iceweasel
 +        2    /usr/bin/epiphany-gecko
          3    /usr/bin/google-chrome
 
Press enter to keep the default[*], or type selection number:

To change the default editor run:

$ sudo update-alternatives --config editor

There is also a GTK program for doing this named galternatives.

Install galternatives:

$ sudo apt-get install galternatives

galternative

Automatic download and upgrade of packages In Debian/Ubuntu

April 28th, 2010 No comments

debianThe apt package comes with its own cron script “/etc/cron.daily/apt” to support the automatic download of packages. This script can be enhanced to perform the automatic upgrade of packages by installing the unattended-upgrades package. These can be customized by parameters in “/etc/apt/apt.conf.d/02backup” and “/etc/apt/apt.conf.d/50unattended-upgrades” as described in “/usr/share/doc/unattended-upgrades/README”.

The unattended-upgrades package is mainly intended for the security upgrade for the stable system. If the risk of breaking an existing stable system by the automatic upgrade is smaller than that of the system broken by the intruder using its security hole which has been closed by the security update, you should consider using this automatic upgrade with configuration parameters as the following.

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "1";

If you are running an unstable system, you do not want to use the automatic upgrade since it certainly breaks system some day. Even for such unstable case, you may still want to download packages in advance to save time for the interactive upgrade with configuration parameters as the following.

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "0";
Categories: DEBIAN/UBUNTU, HOW-TOS Tags: ,