Debian notes: doing things the "Debian Way"
I used Redhat and other RPM-based linux distros for years. When
I started using Debian, I began maintaining this set of notes
reminding me of some of the different ways Debian has of doing things.
In many cases, I've listed the comparable Debian and Redhat commands.
See also the Debian
Reference Card.
mandb -c does what makewhatis does in other distros
and other Unices -- builds the whatis/apropos databases.
It's part of the man-db package.
Package management
Updating and installing packages
- apt-get update
- Run this after changing /etc/apt/sources.list or /etc/apt/preferences.
(this debianhelp.org page
is helpful); run it periodically anyway, to make sure your source
list is up-to-date.
- apt-get dist-upgrade
- Get all software updates available for this distro.
(apt-get upgrade and apt-get -f dist-upgrade are other options;
see this blog
post for some of the differences.)
- apt-get install packagename
- installs a new package: rpm -i package.rpm
- apt-get autoclean
- Run this periodically to clean out .deb archives from packages
which are no longer installed on the system. You can regain lots of
disk space that way. If you're really desperate for disk space,
apt-get clean is more radical, and will remove .deb files
even for packages currently installed. But most of the time you
probably don't need the .debs any more, so it might be worth it
if you're strapped for megabytes.
Querying packages not yet installed
- apt-cache search string
- Searches for string in the list of known packages: like using rpmfind.
- dpkg -l package-name-pattern
- List packages matching pattern: rpm -q pattern or rpm -qa | grep pattern.
- apt-file search filename
- Search for a package (need not be installed) containing files
including the string. apt-file is a package of its own, which you
may have to apt-get install first, then run apt-file update.
If apt-file search filename shows you too much, try
apt-file search filename | grep -w filename (which shows you
only the files that contain filename as a whole word) or variants like
apt-file search filename | grep /bin/ only files located in
directories like /bin or /usr/bin, useful if you're looking for a
particular executable).
- apt-cache showpkg pkgs...
- Show information about packages.
- apt-cache dumpavail
- Prints out an available list.
- apt-cache show pkgs...
- Displays package records, even uninstalled ones,
similar to dpkg --print-avail.
Like rpm -q packagename.
- apt-cache depends <package>
- Show what <package> depends on.
- apt-cache rdepends <package>
- Show what other packages depend on <package>.
- grep-excuses <package>
- Show why package, in unstable, isn't in testing yet.
- apt-cache pkgnames
- Fast listing of every package in the system.
Querying currently installed packages
- dpkg -S file
- Which installed package owns the file? Like rpm -qf file.
- dpkg -L package
- List files in the package. Like rpm -ql package.
- apt-cache policy pkg
- Show which repository pkg came from, if you have
multiple ones in sources.list.
- apt-cache show <package> | grep ^Source
- Find the source package which produces this binary package.
If it returns nothing, then the source package name is the
same as the binary package name.
The APT
HOWTO has instructions on "pinning" and other details of
maintaining a mixed debian system (e.g. stable but using some
packages from unstable). It also shows how to pin a package so
it will not be upgraded (for instance, if you've made local
changes).
deborphan and debfoster are great for finding orphaned
and unneeded packages which can be removed.
You can pull from a different repository by editing /etc/apt/sources.list
to replace "stable" with "unstable" (or whatever) then doing apt-get update.
That gets old, though, so here's a better way:
pinning.
Here's a sample unstable preferences file.
Boot time services
- update-rc.d svc defaults
- Enable service at boot time. chkconfig svc on
- update-rc.d svc stop 0 1 2 3 4 5 6
- Disable scv at boot time. This puts "K" links in all relevant
runlevels, so theoretically apt-get will know to keep the
service disabled, and won't re-enable it.
At least in theory. In practice there's something wrong
with the command and I haven't figured out how to make it
work. Adding "." at the end doesn't work either.
- update-rc.d -f svc remove
- Disable service at boot time. chkconfig svc off
This is simpler than the preceeding line, but less permanent;
services will come back on an apt-get install or dist-upgrade.
-f means force removal of the /etc/rc.? scripts while
leaving the basic script in /etc/init.d (so you can run the
service by hand if you choose).
--purge means remove the script from init.d.
If you want to remove a service so that it never starts unless
asked, and never comes back in a dist-upgrade ... I still
don't know. Apparently the only way is to go to each directory
named /etc/rc?.d in turn, and then rename Snnservicename
to Knnservicename (which you can't easily do as a script
or alias because of the nns being variable).
It's unbelievable that debian has no easier way to do this.
Oh, well.
- update-rc.d svc start 20 2 3 4 5 . stop 20 0 1 6
- Enable service at boot time in the given runlevels, like
chkconfig svc --levels 2345 on
- For listing active services, I wrote a shell script:
lsconfig
- What services are currently enabled? chkconfig --list
Quick tips:
apt history: what's been recently installed?
There's no real or supported way to see your recent apt history,
unfortunately. But if you sort /var/cache/apt/archives by create
date, e.g. ls -ltc /var/cache/apt/archives | more
you can get a list of packages in reverse order of when they were
downloaded. Also, sometimes you can get useful apt install
information from /var/log/apt/term.log.
Neither one helps in finding out what you've removed recently, though.
Printing
I could never get my Epson printer to work through normal cups
configuration. But a new (late 2004) package called
printconf auto-detects it and does the necessary magic.
If you're having problems with Debian CUPS, try printconf.
If printing from mozilla doesn't work, persistently gets the page
size wrong (e.g. keeps going back to A4 even though your system
page size is us-letter), or prints pages twice as big as they should
be (so you only see the top left quarter of the page and your
printer dies horribly trying to print a 16" wide page), try
stopping Xprt -- /etc/init.d/xprt stop -- and see
if that helps. If so, since the next dist-upgrade will turn it
back on again, I recommend just removing Xprt:
apt-get --purge remove xprt xprt-common xprt-xprintorg
Apt-get will tell you it's going to remove "x-window-system".
Don't panic! That's just a meta-package; removing it will not
remove your X server or libraries.
Speeding up USB init during boot
Debian seems to take a lot longer to get through USB during boot than
Redhat on my Vaio. That turns out to be hotplug running usb.agent
for the devices it finds (basically, I think, the hub and the empty
memory stick reader). You can drastically speed up boot by editing
/etc/hotplug/usb.rc and adding an ampersand (&) after the line
that runs /etc/hotplug/usb.agent inside the loop in usb_boot_events().
Linux Links
Shallow Sky home
...Akkana