User Tools

Site Tools


distros:ubuntu_server

Information

  • Ubuntu Server 1)
  • 18.04.3 LTS

Known Issues

  • None

Download

Installation Notes

  • :!: Either use the Alternate or Network installer images to avoid cloud-init stuff
  • During installation, allow network autoconfig to occur, and then go back once prompted for a hostname; this will allow setting a static IPv4 address and custom DNS settings

Repositories

Additional Ubuntu

sudo add-apt-repository 'universe'
sudo add-apt-repository 'multiverse'
sudo add-apt-repository 'restricted'

Software

Update

System

sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean && sync

Snaps

sudo snap refresh

General

sudo apt install lm-sensors

Keybase

wget -O '/tmp/keybase_amd64.deb' 'https://prerelease.keybase.io/keybase_amd64.deb' && sudo dpkg --install '/tmp/keybase_amd64.deb' && sudo apt install -f && rm '/tmp/keybase_amd64.deb' && sync && run_keybase

Settings

Secure Shell

Sensors

Detect

sudo sensors-detect --auto

Watch

sudo watch -n0.1 sensors

Uncomplicated Firewall

  • Allows SSH
sudo ufw reset && sudo ufw default deny && sudo ufw logging off && sudo ufw allow 'ssh' && sudo ufw enable && sudo systemctl enable 'ufw'

Automatic Updates

Config

  • Should keep old config files in-case updated package changes their config (needs tested)
sudo -e '/etc/apt/apt.conf.d/99auto-update-custom'
Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}

Service

sudo -e '/etc/systemd/system/ubuntu-up.service'
[Service]
Type=oneshot
ExecStartPre='/usr/bin/apt' clean
ExecStart='/usr/bin/apt' update
ExecStart='/usr/bin/apt' full-upgrade -y
ExecStart='/usr/bin/apt' autoremove -y
ExecStartPost='/bin/sync'
ExecStartPost='/bin/systemctl' reboot

Timer

  • 06:10 Kraityn
  • 06:20 Alira
  • 06:30 Oak
  • 06:40 Hatebeat
sudo -e '/etc/systemd/system/ubuntu-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'ubuntu-up.timer' --now
[Unit]
Description=Software Package Maintenance and Updater
After=network-online.target
Wants=network-online.target

[Timer]
OnCalendar=*-*-* 06:10:00
Persistent=true

[Install]
WantedBy=timers.target

External Backup

fstab

  • Expects a drive of some kind with a XFS partition at /dev/sdb1
sudo mkdir -p '/mnt/USB' && sudo -e '/etc/fstab'
# USB
/dev/sdb1 /mnt/USB xfs rw,relatime,attr2,inode64,noquota 0 2
sudo mount '/dev/sdb1'

Service

  • TODO: Ubuntu paths
sudo -e '/etc/systemd/system/backup-external.service' && sudo sed -i 's/CHANGEME/'$USER'/g' '/etc/systemd/system/backup-external.service'
[Service]
Type=oneshot
ExecStartPre='/usr/bin/sync'
ExecStart='/usr/bin/rsync' -r '/home/CHANGEME/backups' '/mnt/USB' --verbose --ignore-existing
ExecStartPost='/usr/bin/sync'

Timer

sudo -e '/etc/systemd/system/backup-external.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'backup-external.timer' --now
[Unit]
Description=Backup Backups to External Device

[Timer]
OnCalendar=*-*-* 07:00:00
Persistent=true

[Install]
WantedBy=timers.target

Notable Folders and Commands

fstrim

sudo fstrim -v --all

Show CPU Frequency

grep 'MHz' '/proc/cpuinfo'
watch -n 0.1 grep \'cpu MHz\' '/proc/cpuinfo'

Partition Information

df -hT

Hyper-threading Information

grep -e "processor" -e "core id" -e "^$" /proc/cpuinfo

Optimal GCC compiler flags

gcc -v -E -x c -march=native -mtune=native - < /dev/null 2>&1 | grep cc1 | perl -pe 's/ -mno-\S+//g; s/^.* - //g;'

Privacy

Clear Terminal History

history -cw

Create 7z Password Archive

  • Change x in x.7z to the desired archive name
  • Change CHANGEME in -pCHANGEME to the desired password
7za a 'x.7z' -p'CHANGEME'
distros/ubuntu_server.txt · Last modified: 2019/10/23 16:05 by Sean Rhone