Tips and Tricks for Debian.
Installed packages can be listed as follows:
apt list --installed
dpkg-query -l
To see the contents of a .deb file, perform the following:
apt-get update && apt-get install apt-file
apt-file update
apt-file list [deb file]
To install add-apt-repository, perform the following:
apt update
apt -y install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates
add-apt-repository ppa:PPA Name]
apt update
apt install [package]
Ensure dpkg-dev
is installed:
apt-get install dpkg-dev
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
dpkg-scanpackages -m -a [arch] [dir] | gzip > [dir]/Packages.gz
#!/bin/bash
cd /opt/shared/repo/apt
echo
for arch in i386 amd64 mips armel armhf
do
printf "%-10s" "${arch}:"
dpkg-scanpackages -m -a ${arch} pool | gzip > dists/buster/main/binary-${arch}/Packages.gz
done
echo
To trust a repo, /etc/apt/sources.list
:
deb [ trusted=yes ] http://ftp.us.debian.org/debian/ jessie main contrib non-free
To upgrade from Stretch to Buster, perform the following:
- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
- grep -rl stretch /etc/apt/ | sudo xargs sed -i 's/stretch/buster/g'
- apt update -y && apt dist-upgrade -y
- reboot
To create a rootfs of Debian perform the following (note you may want to ignore the pgp check using debootstrap --no-check-gpg --arch=$arch --foreign $distro $targetdir
vs debootstrap --arch=$arch --foreign $distro $targetdir
below):
apt-get install -y qemu-user-static debootstrap binfmt-support qemu-system-arm
distro=bookworm
arch=armhf
targetdir="${distro}_${arch}"
mkdir $targetdir
debootstrap --arch=$arch --foreign $distro $targetdir
cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
cp /etc/resolv.conf $targetdir/etc
chroot $targetdir
distro=bookworm
export LANG=C
/debootstrap/debootstrap --second-stage
cat <<EOT > /etc/apt/sources.list
deb http://ftp.debian.org/debian $distro main contrib non-free
deb http://ftp.debian.org/debian $distro-updates main contrib non-free
EOT
apt-get update -y
apt-get upgrade -y
apt-get install -y dialog locales lsb-release ntp ntpdate openssh-server rsync sshfs vim htop wget curl screen
dpkg-reconfigure locales
dpkg-reconfigure tzdata
passwd
apt-get remove -y inetutils-ping
apt-get install -y inetutils-ping
- Don't use a dnsmasq lease file:
/etc/default/dnsmasq
:DNSMASQ_OPTS="--leasefile-ro"
- Leases stored in
/var/lib/misc/dnsmasq.leases
- Configure
- locale:
dpkg-reconfigure locales
- time zone:
dpkg-reconfigure tzdata
dpkg --configure -a
- locale:
- Nic:
inet 169.254.244.144/16 brd 169.254.255.255 scope global enp1s0
/etc/networks
: rmlink-local 169.254.0.0
- Install LXDE:
apt-get install task-lxde-desktop
- Import Key
gpg --keyserver keyring.debian.org --recv-keys [key]
gpg --recv-keys [key]
gpg -a --export [key] | sudo apt-key add -
To convert an rpm to a deb file, execute: alien --scripts [rpm file]
Example: alien --scripts bluejeans-1.37.22.x86_64.rpm
Once a machine/VM is setup, you can generate a seed file containing the setup (be sure to install debconf-utils
):
- Settings from installation:
debconf-get-selections --installer
- Current settings:
debconf-get-selections
apt-get install aptitude network-manager -y
aptitude install bridge-utils
systemctl enable NetworkManager
- The file
/etc/network/interfaces.d/[bridge name]
should resemble:
auto [bridge name]
# Bridge setup
iface [bridge name] inet dhcp
bridge_ports [ethernet]
As an example a bridge named bridge0
and ethernet enp1s0
:
auto bridge0
iface bridge0 inet dhcp
bridge_ports enp1s0
Additionally you must also modify your /etc/network/interfaces
to be:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
Ensure you install ethtool
: apt install ethtool
auto [bridge name]
# Bridge setup
iface [bridge name] inet dhcp
bridge_ports [ethernet]
/usr/sbin/ethtool -s [ethernet] wol g
As an example a bridge named bridge0
and ethernet enp1s0
:
auto bridge0
iface bridge0 inet dhcp
bridge_ports enp1s0
/usr/sbin/ethtool -s enp1s0 wol g
If not running IPv6, /etc/default/tftpd-hpa
should resemble:
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure -4"
The -4
represents "use IPv4."
- The domainname:
/etc/defaultdomain
/etc/default/ddclient
run_dhclient="false"
run_ipup="false"
run_daemon="true"
daemon_interval="300"