John Siu Blog

Tech - Business Tool, Personal Toys

Ubuntu Commands

☰ Table of Content

Misc. Ubuntu commands.

Remove Pre-installed

If you don’t know what they are …

1
apt purge cloud-* snapd whoopsie* unattended-upgrades ubuntu-advantage-tools

If not using LVM, LXC/LXD

1
apt purge lvm2 lxd lxcfs

If completely rely on journald.

1
apt purge rsyslog libestr0 libfastjson4

Get Version

1
lsb_release -r

Change Timezone

1
dpkg-reconfigure tzdata

systemd-resolver

Ubuntu/Systemd use systemd-resolver for dns lookup and /etc/resolve.conf no longer show the actual upstream dns. Use following to check and change.

Show DNS Settings

1
resolvectl

Change DNS

1
2
resolvectl dns <interface> <dns1> <dns2> ...
resolvectl dns enp0s2 8.8.8.8 8.8.4.4 1.1.1.1

Change Search Domain

1
2
resolvectl domain <interface> <domain>
resolvectl domain enp0s2 johnsiu.com

Disable CPU mitigations

Do this at your own risk.

/etc/default/grub

1
GRUB_CMDLINE_LINUX_DEFAULT="noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off mitigations=off"

Update GRUB

1
2
3
update-grub
grub-install <boot disk>
grub-install /dev/sda

Update Initramfs

This is needed if module used during boot is changed.

1
update-initramfs -u

Ubuntu Release Upgrade

1
2
apt install update-manager-core
do-release-upgrade -d

Netplan

Apply netplan changes. Will not apply if there is syntax error in configuration files:

1
netplan apply

Try, will apply and auto revert:

1
netplan try

Purge Uninstalled Packages

1
apt-get purge $(dpkg -l | grep '^rc' | awk '{print $2}')

APT Cache

On apt cache server:

1
apt install apt-cacher-ng

On other server:

1
echo 'Acquire::http::Proxy "http://<cache-server>:3142";' > /etc/apt/apt.conf.d/00proxy

John Siu

Update: 2020-08-12
comments powered by Disqus