Debian Tips

Changing the Hostname

Basically /etc/hostname must contain only the host name, not the fully qualified domain name.

How the domain name is determined varies according to your setup (getting it either from a DNS service or from /etc/hosts). See man hostname for details, but often it'll be read from /etc/hosts which has an entry that includes the fully qualified domain name, either for or for the static IP address if you have one. It seems to need to be the first entry for the particular IP address, e.g.

$ head -n 2 /etc/hosts www localhost localhost.localdomain

or if only local interface, (but not very sure about this) or what to do if using DHCP:

$ head -n 1 /etc/hosts www localhost localhost.localdomain

Debian determines the fully qualified host name during boot by running /etc/init.d/ so after making the changes:

# /etc/init.d/ start

Note: stop does nothing in the script

To check that all is correct:

$ hostname

$ hostname --fqdn

See also

Package Management

Specifying the interface and priority

Run the following to change either the interface you wish to use during package installs or the level of configuration questions you are prompted for.

  • dpkg-reconfigure debconf

The defaults are usually 'Dialog' and 'medium'


Extract from

The following command will reinstall all packages on your system:

COLUMNS=200 dpkg -l | awk '/^ii/ {print $2}' | xargs apt-get --reinstall install

Reboot Required Notifications

Install the update-notifier-common package.

The presence of the file /var/lib/update-notifier/updates-available indicates that updates are available.

The presence of the file /var/run/reboot-required indicates the system needs rebooting after an update.

Running /usr/lib/update-notifier/apt-check --human-readable outputs a summary of the number of packages that can be updated.

Running /usr/lib/update-notifier/update-motd-reboot-required indicates whether a reboot is required.

Package Versions

  • apt-show-versions | grep /testing

Package Priority

The following shows which package the apt mechanism is choosing

  • apt-cache policy mypackage

To show the priority of each source

  • apt-cache policy

For example:

cat /etc/apt/sources.list

deb stable/updates main contrib non-free
deb sarge main contrib non-free
deb sarge/non-US main contrib non-free
deb etch main
deb sarge/volatile main contrib non-free

cat /etc/apt/apt.conf

    Default-Release "stable";
    Clean-Installed "false";
        List-Cleanup "true";

Note: the 'Default-Release' statement gives that source a priority of '990'

$ cat /etc/apt/preferences
Package: *
Pin: release,a=sarge,l=debian-volatile
Pin-Priority: 999

Package: *
Pin: release a=testing,o=Debian
Pin-Priority: -10

Pinning a Specific Version

$cat /etc/apt/preferences
Package: linux-image-2.6.32-5-686
Pin: version 2.6.32-39squeeze1
Pin-Priority: 990

Use a Pin-Priority of 1000 to stop a version being replaced. Use 1001 to force a downgrade of a package (see Downgrading below.

To revert to an older version of an installed package, it may be necessary to uninstall the package and install the older package using dpkg, before the pin-priority is properly displayed by apt-cache policy e.g.

$ cat /etc/apt/preferences.d/01_firefox
Package: firefox
Pin: version 46.0.1-1~bpo80+1
Pin-Priority: 990

Package: firefox-l10n-en-gb
Pin: version 46.0.1-1~bpo80+1
Pin-Priority: 990

$ apt-cache policy firefox
  Installed: 47.0-1~bpo80+1
  Candidate: 47.0-1~bpo80+1
  Package pin: (not found)
  Version table:
 *** 47.0-1~bpo80+1 990
        500 jessie-backports/firefox-release i386 Packages
        100 /var/lib/dpkg/status

$ sudo apt-get remove firefox

$ cd /var/cache/apt/archive
$ sudo dpkg -i firefox_46.0.1-1~bpo80+1_i386.deb firefox-l10n-en-gb_46.0.1-1~bpo80+1_all.deb 

$ apt-cache policy firefox firefox-l10n-en-gb
  Installed: 46.0.1-1~bpo80+1
  Candidate: 46.0.1-1~bpo80+1
  Package pin: 46.0.1-1~bpo80+1
  Version table:
     47.0-1~bpo80+1 990
        500 jessie-backports/firefox-release i386 Packages
 *** 46.0.1-1~bpo80+1 990
        100 /var/lib/dpkg/status
  Installed: 46.0.1-1~bpo80+1
  Candidate: 46.0.1-1~bpo80+1
  Package pin: 46.0.1-1~bpo80+1
  Version table:
     47.0-1~bpo80+1 990
        500 jessie-backports/firefox-release i386 Packages
 *** 46.0.1-1~bpo80+1 990
        100 /var/lib/dpkg/status

See also How to keep specific versions of packages installed (complex)


To downgrade from testing to stable

Set up your /etc/apt/preferences as follows:

    Package: *
    Pin: release a=stable
    Pin-Priority: 1001

    Package: *
    Pin: release a=testing
    Pin-Priority: 60

    Package: *
    Pin: release a=unstable
    Pin-Priority: 50

You also might need to temporarily remove APT::Default-Release "stable" from /etc/apt/apt.conf as it seems to prevent downgrading

Then run

# apt-get --dry-run dist-upgrade

Remove the --dry-run option once it all looks OK.


$ apt-show-versions | grep /testing

To find any remaining packages. Some packages are risky to downgrade, e.g. libc6, so don't worry if not absolutely everything downgrades. For further hints on removing packages that fail to downgrade:

See also Downgrading report from testing to stable

-- Frank Dean - 16 Mar 2007

To downgrade a specific package version:

    Package: openssl
    Pin: version 0.9.8o-4squeeze13
    Pin-Priority: 1001

    Package: libssl0.9.8
    Pin: version 0.9.8o-4squeeze13
    Pin-Priority: 1001

-- Frank Dean - 15 Feb 2013

Removing packages with broken scripts

The install/remove scripts are all under /var/lib/dpkg/info/ named by their package.

If you can't fix the script, you can have it ignore errors by removing the '-e' flag to #!/bin/sh or comment out the 'set -e' line in the script.


-- Frank Dean - 20 Mar 2007

List of removed packages with configuration files

Use the grep-status tool from the dctrl-tools package:

$ grep-status -n -sPackage -FStatus config-files

-- Frank Dean - 19 Mar 2011


Updating packages from ISO CD/DVD image

  1. Create an entry in /etc/fstab to mount the ISO image as a loop device:

    # cat << EOF >>/etc/fstab
    /tmp/debian-6.0.3-i386-DVD-1.iso /media/apt iso9660 ro,loop=/dev/loop0,noauto 0 0

    Note: The mount point must be /media/apt as apt-cdrom in Debian 6.0 (Squeeze) seems to ignore any other, even when using the -d paramater or specifying Acquire::cdrom::mount "/mnt/iso" etc. However, with Debian 5.0 (Lenny) it is sufficient to simply use apt-cdrom -d=/media/apt add

  2. Mount the ISO image

    # mount /media/apt
  3. Edit /etc/apt/sources.list and add an entry for the ISO file

    deb file:///media/apt squeeze main contrib
  4. Update the package list

    # apt-get update

Sometimes it is necessary to start with a fresh CD list. If so, delete /var/lib/apt/cdroms.list.


Disabling Beeps

Disabling Beep on Shutdown

Debian 6.0 (Squeeze) has introduced an annoying beep from the PC Speaker on shutdown. Debian 7.0 (Wheezy) has included another module that also needs disabling (snd_pcsp). All PC Speaker noise can be disabled by removing the modules from the kernel.

$ sudo modprobe -r pcspkr
$ sudo modprobe -r snd_pcsp

Adding it to the module blacklist stops it being reloaded in the future. Append the following to /etc/modprobe.d/blacklist.conf

# Stop annoying beep on shutdown by disabling pc speaker
blacklist pcspkr
blacklist snd_pcsp

-- Frank Dean - 27 Feb 2011

Disable Beep in Firefox

  1. Enter about:config in Firefox address bar
  2. Search for accessibility.typeaheadfind.enablesound
  3. Set the value to false
  4. Restart Firefox


-- Frank Dean - 9 Jan 2016

Disable Beep in Emacs

Add (setq visible-bell 1) to your .emacs file.


-- Frank Dean - 9 Jan 2016

Disable Beep in X11

e.g. xpdf beeps if you try to page beyond the last page

    $ xset b off


False reports of LKM Trojan

Producing and using website statistics

Automount with Gnome

Make sure Gnome is set to automount devices. Desktop | Preferences | Removable Drives and Media

Add your user name to the plugdev group

  • grep plugdev /etc/group
  • sudo adduser me plugdev

Logout and log back in and automounting should be working!

System Services

The default Debian run-level is 2. To change the default run-level, edit the initdefault entry in the /etc/inittab file. E.g. To change to run-level 3, set initdefault as follows:


See RunLevel in the Debian Wiki for more information.

Changing Default Services

Debian 6.0 (Squeeze) introduced a new method of starting services. See LSBInitScripts DependencyBasedBoot.

Legacy support remains for the old style of booting. The insserv utility issues a warning where the default start and stop values specified in the /etc/init.d/xxxx script are inconsistent with the legacy method of creating symbolic links in /etc/rc.x directories. Install the sysv-rc-conf package and run the sysv-rc-conf command-line utility as root to change the legacy symbolic links. Then run insserv again to check that the links are consistent. E.g.

$ sudoedit /etc/init.d/apache2
$ sudo sysv-rc-conf
$ sudo insserve apache2

Debian 8 (Jessie) introduced using systemd for starting and managing services.

  • Default systemd init is defined as a symbolic link usually at either /lib/systemd/system/default or /etc/systemd/system/default the latter taking precedence.

Boot command line

To see how the system was booted:

    $ cat /proc/cmdline

Update Alternatives

Debian uses a system to set a system wide default for some programs. Note that some desktop managers may have their own way of settings these interactively via the menu. Additionally, some applications may set their own defaults when they launch other applications. E.g. ClawsMail.

To see the various alternatives:

    $ sudo update-alternatives --get-selections

Change an alternative interactively with:

    $ sudo update-alternatives --config x-www-browser

To set a specific alternative, typically used from a script:

    $ sudo update-alternatives --set x-www-browser /usr/bin/iceweasel

To see all the possible targets for a link group:

    $ sudo update-alternatives --list editor

To see the current state of an alternative:

    $ sudo update-alternatives --display editor

To return the behaviour to automatic selection:

    $ sudo update-alternatives --auto editor

Default Editor

Administrators who wish to change the default editor for all users will have to update the alternatives system using:

Adminstrator can update the default editor with:

     # update-alternatives --config editor

Users should define the EDITOR environment variable by including the following lines in their profile:

     export EDITOR
     alias editor=$EDITOR

Deafult Web Browser

Use update-alternatives to change the default web browser.

    $ sudo update-alternatives --set x-www-browser /usr/bin/iceweasel

If you're using Gnome:

    $ sudo update-alternatives --set gnome-www-browser /usr/bin/iceweasel

Installing and building from source packages

$ apt-get source foo
$ : Check for build dependencies
$ sudo apt-get build-dep foo

Use '--download-only' for the apt-get source command if you do not want the download to be unpacked.

To build, download the .dsc, .tar.gz and .diff.gz source files.

If they need extracting into a package subdirectory:

$ dpkg-source -x foo_version-revision.dsc

To compile the binary:

$ cd foo_version-revision
$ dpkg-buildpackage -rfakeroot -b

Add '-tc' to the dpkg-buildpackage command to clear the directory tree after the build completes, i.e.

$ cd foo_version-revision
$ dpkg-buildpackage -rfakeroot -b -tc

The deb package will be created in the directory above the build directory.

If can then be installed with:

# dpkg -i ../foo_version-revision_arch.deb

Extracting Debian Binary Package

$ dpkg-deb -x mypackage.deb target_dir

Fixing mpg123

Running mpg123 under Debian 5 (Lenny) results in the following error:

[module.c:110] error: Failed to open module alsa: file not found

See Bug #561857

Fix by running with a specified library path:

$ LD_LIBRARY_PATH=/usr/lib/mpg123 mpg123 myfile.mp3

or use mp3blaster instead ;-)

-- Frank Dean - 3 Apr 2010


In Debian 6.0 (Squeeze), disabling 'wireless' in the network manager is forgotten when resuming from sleep, etc.

The simplest solution is to disable wireless using vendor specific methods, where possible. E.g. Lenovo T500 ThinkPad by pressing Fn-F5 combination until wireless indicator LED is extinguished.

-- Frank Dean - 10 Mar 2010

Wi-Fi Dropouts

Debian 6.0 (Squeeze) may frequently drop Wi-Fi connections with dmesg showing errors similar to deauthenticated from xx:xx:xx:xx:xx:xx: (Reason: 2). It seems disabling power management with sudo iwconfig <iface> power off fixes the issue.

-- Frank Dean - 21 Jul 2011

Flash Player

Install the flashplugin-nonfree package.

$ sudo update-flashplugin-nonfree --install --verbose

See also

Upgrading Flash Player

    $ sudo update-flashplugin-nonfree --install

Flash NPAPI Development for Linux Discontinued

Adobe announced in February 2012 that it will discontinue development of Flash Player for Linux, except for the Chrome browser. Security support for the version 11.2 will be provided for 5 years from its release.


Chinese etc.

Install the following fonts:

xfonts-intl-chinese xfonts-intl-chinese-big xfonts-intl-japanese \ xfonts-intl-japanese-big xfonts-intl-asian xfonts-intl-arabic \ xfonts-intl-european ttf-arphic-bkai00mp ttf-arphic-bsmi00lp \ ttf-arphic-gbsn00lp ttf-arphic-gkai00mp ttf-arphic-ukai ttf-arphic-uming

I'm not sure these are all needed, but installing these packages worked for me.

-- Frank Dean - 30 Mar 2011

Video Drivers

Installing from within Windows

There is a utility called win32-loader.exe that provides the facility to download Debian installers and seamlessly reboot into them.


-- Frank Dean - 10 Jan 2012


When using ssh-add and you get an error like:

Could not open a connection to your authentication agent.

Run the following command so that the current shell knows where to find ssh-agent

eval "$(ssh-agent)"

-- Frank Dean - 27 Feb 2014

-- Frank Dean - 15 Dec 2004

Related Topics: AptitudeTips, CreatingRescuePartition, GnomeTips, JigdoTips, LinuxHintsAndTips, LxdeTips, OpenLDAP, SystemVStartupScripts, UbuntuTips