Debian is one the most widespread Linux worldwide; today, we gathered some new valuable tips about it.
1)Install:
In your computer, installed software will display the following text:
apt list --installed
dpkg-query -l
2)See Contents of a .deb file:
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]
3)add-apt-repository:
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]
4)Repos:
Ensure dpkg-dev
is installed:
apt-get install dpkg-dev
5)Create
Local
To create a local repo:
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
Proper
To create an appropriate repo:
dpkg-scanpackages -m -a [arch] [dir] | gzip > [dir]/Packages.gz
Example
#!/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
6)trust a repo:
To trust a repo, /etc/apt/sources.list
:
deb [ trusted=yes ] http://ftp.us.debian.org/debian/ jessie main contrib non-free
7)Upgrade Stretch to Buster
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
8)Creating a rootfs
To create a rootfs of Debian, perform the following
apt-get install -y qemu-user-static debootstrap binfmt-support qemu-system-arm
targetdir=rootfs
distro=buster
mkdir $targetdir
debootstrap --arch=armhf --foreign $distro $targetdir
cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
cp /etc/resolv.conf $targetdir/etc
chroot $targetdir
distro=buster
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-src http://ftp.debian.org/debian $distro main contrib non-free
deb http://ftp.debian.org/debian $distro-updates main contrib non-free
deb-src http://ftp.debian.org/debian $distro-updates main contrib non-free
deb http://security.debian.org/debian-security $distro/updates main contrib non-free
deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free
EOT
apt-get update -y
apt-get install -y dialog locales lsb-release nis ntp ntpdate openssh-server rsync sshfs vim
dpkg-reconfigure locales
passwd
9)chroot
ping: Address family not supported by protocol
apt-get remove -y inetutils-ping
apt-get install -y inetutils-ping
10)dnsmasq
- Don’t use a dnsmasq lease file:
/etc/default/dnsmasq
:DNSMASQ_OPTS="--leasefile-ro"
- Leases stored in
/var/lib/misc/dnsmasq.leases
11)Quickies
- Configure
- locale:
dpkg-reconfigure locales
- Time zone:
dpkg-reconfigure tzdata
- locale:
- Install LXDE:
apt-get install task-lxde-desktop
12)RPM to Deb
To convert an rpm to a deb file, execute: alien --scripts [rpm file]
Example: alien --scripts bluejeans-1.37.22.x86_64.rpm
13)Generate Seed Files
Once a machine/VM is set up, 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
14)Setup a Bridge
Directions
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, it would be best if you 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
Enable wake-on-lan
Ensure you install ethtool
: apt install ethtool
auto [bridge name]
# Bridge setup
iface [bridge name] inet dhcp
bridge_ports [ethernet]
/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
/sbin/ethtool -s enp1s0 wol g
15 )tftpd-hPa
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 -۴
represents “use IPv4.”
All of the command we showed you on the list above is based on Debian, but here we gathered some specific order for Linux, which can come in handy when you face a problem working with Linux.
16)Add user/Addgroup
The adduser and addgroup commands let you add a new user and group to a system, respectively. Here’s an example for adduser:
$ sudo adduser testuser
Adding user `testuser' ...
Adding new group `testuser' (1003) ...
Adding new user `testuser' (1003) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
17)Cal/Local
The cal and local commands display a calendar in the output; both will show you the calendar, but there’s a slight difference, offering you the calendar differently from the other.
$ cal
March 2017
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
$ ncal
March 2017
Su 5 12 19 26
Mo 6 13 20 27
Tu 7 14 21 28
We 1 8 15 22 29
Th 2 9 16 23 30
Fr 3 10 17 24 31
Sa 4 11 18 25