Archive

Posts Tagged ‘DEBIAN/UBUNTU’

Recording and copying system configuration in Debian/Ubuntu

July 9th, 2010 1 comment

debianYou can make a local copy of the package and debconf selection states using dpkg and debconf-get-selections command. The debconf-get-selections command output the content of current debconf database.

You will require the “debconf-utils” packages to do that.

Install debconf-utils:

$ sudo aptitude install debconf-utils
$ sudo dpkg --get-selections '*' > selection.dpkg
$ sudo debconf-get-selections    > selection.debconf

Here, “*” makes “selection.dpkg” to include package entries for “purge” too.

You can transfer these 2 files to another computer, and install there with the following.

$ sudo dselect update
$ sudo debconf-set-selections < myselection.debconf
$ sudo dpkg --set-selections  < myselection.dpkg
$ sudo apt-get -u dselect-upgrade    # or dselect install

If you are thinking about managing many servers in a cluster with practically the same configuration, you should consider to use specialized package such as fai to manage the whole system.

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

Basic Package Management Operations Using Aptitude

March 24th, 2010 2 comments

debianaptitude is a featureful package manager for Debian GNU/Linux systems, based on the renowned apt package management infrastructure. aptitude provides the functionality of dselect and apt-get, as well as many additional features not found in either program.

For the package management operation which involves package installation or updates package metadata, you need to have root privilege.

Here are basic package management operations with commandline using aptitude(8).

Working With aptitude

Update package archive metadata.

aptitude update

Install candidate version of “foo” package with its dependencies.

aptitude install foo

Install candidate version of installed packages without removing any other packages.

aptitude upgrade

Install candidate version of installed packages while removing other packages if needed.

aptitude dist-upgrade

The difference between “safe-upgrade”/”upgrade” and “full-upgrade”/”dist-upgrade” only appears when new versions of packages stand in different dependency relationships from old versions of those packages. The “aptitude safe-upgrade” command does not install new packages nor remove installed packages.

Remove “foo” package while leaving its configuration files.

aptitude remove foo

Remove “foo” package and its configuration files.

aptitude purge foo

Clear out the local repository of retrieved package files completely.

aptitude clean

Clear out the local repository of retrieved package files for outdated packages.

aptitude autoclean

Display detailed information about “foo” package.

aptitude show foo

Search packages which match ‘regex’.

aptitude search <regex>

Explain the reason why ‘regex’ matching packages should be installed.

aptitude why <regex>

Explain the reason why ‘regex’ matching packages can not be installed.

aptitude why-not <regex>

Notable command options for aptitude

-s simulate the result of the command
-d download only but no install/upgrade
-D show brief explanations before the automatic installations and removals

List of the aptitude regex formula

~n match on package name
~d match on description
~t match on task name
~G match on debtag
~m match on maintainer
~s match on package section
~V match on package version
~A{sarge,etch,sid} match archive
~O{debian,…} match origin
~p{extra,important,optional,required,standard} match priority
~E match essential packages
~v match virtual packages
~N match new packages
~a{install,upgrade,downgrade,remove,purge,hold,keep} match with pending action
~i match installed packages
~M match installed packages with A-mark (auto installed package)
~i!~M match installed packages without A-mark (administrator selected package)
~U match installed and upgradable packages
~c match removed but not purged packages
~g match removed, purged or can-be-removed packages
~b match packages with broken relation
~B match packages with broken depends/predepends/conflict
~D[:] match packages from which relation is defined to package
~DB[:] match packages from which broken relation is defined to package
~R[:] match packages to which the package defines relation
~RB[:] match packages to which the package defines broken relation
~R~i match packages to which some other installed packages depend on
!~R~i match packages to which no other installed packages depend on
~R~i|~Rrecommends:~i match packages to which some other installed packages depend or recommend on
~S filter match package with filtered version
~T match all packages (true)
~F match no packages (false)