Update
Update package list
apt update
Upgrade packages
apt upgrade -y
Upgrade and remove if necessary
apt full-upgrade -y
Auto updates
Install needed packages.
apt install -y unattended-upgrades apt-listchanges
Configure updates. By default only security updates are enabled.
vim /etc/apt/apt.conf.d/50unattended-upgrades
---
Unattended-Upgrade::Allowed-Origins {
[...]
"origin=Debian,codename=${distro_codename}-updates";
[...]
}
Enable the timer.
systemctl enable --now apt-daily-upgrade.timer
Check if a reboot is needed.
cat /var/run/reboot-required
---
*** System restart required ***
````
Or use it with a script.
[ -f /var/run/reboot-required ] && reboot
---
# Clean
Remove unused packages
apt autoremove -y
Clean
apt clean
# Repositories
## Manually
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu focal main" | tee -a /etc/apt/sources.list.d/ansible.list
## With `apt-add-repository`
apt install software-properties-common apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
## Download gpg keys
gpg --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
---
# Network
## Edit the config
/etc/network/interfaces
source /etc/network/interfaces.d/*
auto lo iface lo inet loopback
The primary network interface
allow-hotplug enp1s0 iface enp1s0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 1.1.1.1 8.8.8.8 9.9.9.9 pre-up echo "nameserver 1.1.1.1\nnameserver 8.8.8.8\nnameserver 9.9.9.9" > /etc/resolv.conf
## Restart
systemctl restart networking
ifup enp1s0
systemctl restart ifup@enp1s0
---
# Add user
groupadd --gid 1000 --system user useradd --comment "user" --home-dir /var/lib/user --gid 1000 --create-home --system --shell /bin/false --uid 1000 user ```
Info
apt
is meant for interactive use, and should not be used in scripts. In scripts one should useapt-get
, which has a stable output better suitable for parsing.