Skip to content

Instantly share code, notes, and snippets.

@kaipm
Last active May 10, 2022 17:09
Show Gist options
  • Save kaipm/09b2601dc6f281ecc89c474a4d7fa861 to your computer and use it in GitHub Desktop.
Save kaipm/09b2601dc6f281ecc89c474a4d7fa861 to your computer and use it in GitHub Desktop.
Ubuntu Linux cheat sheet

SSH

Login via ssh username@server-or-ip. Copy files via SSH with the command scp source destination. You can use user@server:path for remote sources or destinations.

Host name

Set the desired host name via hostnamectl set-hostname abc

  • /etc/hosts usually has the entry 127.0.1.1 hostname, change this accordingly
  • For saltstack minions, also update /etc/salt/minion_id
  • If you change a master to something other than salt, be sure to update /etc/salt/minion on all minions

Zero-Conf Network

Install DNS multicast name resolution: sudo apt-get install avahi-daemon Note: to reach servers, append .local to server name

Network and DNS configuration

Ubuntu uses netplan to configure network interfaces. Edit /etc/netplan/01-netcfg.yaml or /etc/netplan/00-installer-config.yaml. Under ethernets add the device with its address. Here is an example configuration for a VBox machine with two network adapters:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      addresses:
      - 192.168.0.20/24
      nameservers:
        search: [ mydomain.com ]
        addresses:
        - 192.168.0.1
        - 192.168.0.2
    enp0s8:
      dhcp4: yes

After changing the configuration, use netplan apply.

Flushing DNS cache

systemd-resolve --flush-caches On newer Ubuntu servers (e.g. 22.04 LTS) it is resolvectl flush-caches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment