Skip to content

Latest commit

 

History

History
317 lines (209 loc) · 8.07 KB

debian.md

File metadata and controls

317 lines (209 loc) · 8.07 KB

Debian

https://www.debian.org/

The legendary, mature widely used stable Linux distribution with the best most reliable tenure.

Key Points

Philosophical thoroughbred open-source has stood the test of time. It's the open source purist's choice.

Debian has won the Linux distro wars along with its derivative Ubuntu due to Redhat killing its original open source Redhat and later community effort derivative CentOS in order to try to force people to pay for Redhat Enterprise Linux. In reality, all this has done is cause Redhat to become a legacy Linux distribution.

If you could save only one Linux distribution to remain in existence, or bet the future on, it would be Debian.

Package Management

Debian packages are deb format files.

dpkg installs / uninstalls a single deb package. It tracks the installed packages in the /var/lib/dpkg/ directory and can query the list of installed packages or specific details on a single installed package.

apt* programs search and download deb packages from online repositories (or local media) and get dkg to install them.

apt-get vs apt vs aptitude

  • apt-get - the original package management program

    • apt-cache searches the package lists downloaded by apt-get
  • apt - newer wrapper command to apt-get with a subset of the functionality but different output format

  • aptitude - newest with different output again but unlike apt-get and apt needs to be installed. Not sure why anybody cares to use this longer command, it's not like we get paid by the keystroke...

All three work in a similar way, so where you see apt-get you can substitute for apt or aptitude if you want to see a different output format.

If in doubt, just stick to apt-get and apt-cache for everything for simplicity.

Get the latest package lists

Any one of these commands:

apt-get update
apt update
aptitude update

Quiet:

apt-get update -qq

Package Search

Any one of these commands:

apt-cache search "$term"

apt gives a fancier colourised multi-line output for each package found, but I prefer the simpler concise single line format of apt-get which is easier to grep:

apt search "$term"

aptitude uses a different but single line format:

aptitude search "$term"

Install

apt-get install "$package"
apt install "$package"
aptitude install "$package"

Auto-accept installing without confirmation prompt:

apt-get install -y "$package"

Add -q or -qq for quiet modes:

apt-get install -q "$package"

Quiet and doesn't prompt:

apt-get install -qq "$package"

Show version that would be installed:

apt list "$package"

Show details on a package without it having to be installed first like with dpkg:

apt show "$package"
apt-cache showpkg "$package"
aptitude show "$package"

Show version, repo and debian pinning priority:

apt-cache policy "$package"

Show version and repo in one line concise format without repo pinning priority:

apt-cache madison "$package"

Which package would provide a given file - apt-file

apt-file is an optional program, so you have to install it first:

apt-get install -y apt-file

Then download the package list information it needs to search package contents and not just name / version / description:

apt-file update

Now use it to search for which package would provide file mysql_config:

apt-file search mysql_config

List a package's contents without having to install it first:

apt-file list "$package"

Local Package Information - dpkg

List installed packages:

dpkg -l

List contents of installed package:

dpkg -L "$package"

Which installed package owns /usr/bin/mysql_config:

dpkg -S /usr/bin/mysql_config

What depends on a package:

apt-cache rdepends --installed "$package"

Print package info:

dpkg -p "$package"
dpkg -s "$package"

Check for broken package(s)

dpkg -C ["$package"]
debconf-get-selections --installer

Sync and manage local deb repositories

reprepro

Docker

Debian is an excellent choice for a base docker image from which to derive and is used by many docker images in the world, including several of my own at HariSekhon/Dockerfiles.

While not as lean as Alpine, it is full-featured and more compatible.

Readme Card

Debian Preseeding - Automated Installations

Debian can be installed using Preseeding for fully automated hands-off installations:

https://wiki.debian.org/DebianInstaller/Preseed

Boot command to start installer with a preseed.cfg text config file which can be bundled into an installation medium such as a DVD iso or served by a web server on the local network.

This is called by adding the following kernel arguments in the installation grub bootloader:

auto=true url=http://192.168.1.2:8080/preseed.cfg hostname=debian domain=local

If you just want to start a quick webserver from your local directory, you can do this which starts a local webserver on port 8080:

warning this will share out your entire $PWD local directory contents without authentication so copy to an empty /tmp directory and share that so nothing else is exposed:

mkdir -p -v /tmp/serve-preseed &&
cp -v preseed.cfg /tmp/serve-preseed/ &&
cd /tmp/serve-preseed &&

python -m SimpleHTTPServer

Preseed Template

HariSekhon/Templates - preseed.cfg

Readme Card

HashiCorp Packer + Preseed Config

Packer builds fully automated Virtual Machine golden templates from which to clone virtual machines by booting the Debian installer medium with Debian Preseed template.

Real-world Preseed config used by Packer build:

HariSekhon/Packer-templates - installers/preseed.cfg

HariSekhon/Packer-templates - debian-x86_64.vbox.pkr.hcl

Readme Card

Debian Change Log tool

debchange
dch

--increment adds a new entry and drops you in to editor, with a username + timestamp footer eg:

dch -i -c hadoop.log

Ported from private Knowledge Base page 2010+ - not sure why so late given usage from 2002 - young guys don't know the value of documentation