Install Ubuntu Server

UBUNTU SERVER

  • Prefer older LTS (as more tested & pkgs supported)

  • Only command line by default, must install GUI separately

  • Download Link

  • Add GUI

  • Partition SetUp

    • Along with root (prefer SSD), swap, boot, home - var can also partitioned (so that logs doesn't take up normal space)
    • Advantages of using LVM instead Physical partitions link //snapshots

20.04 IMAGES & Partition

  • Language

001

  • Keyboard

002

  • Network connection
    • choose network (no image as testing on machine without internet)

004

005

  • Choose custom storage layout

006

  • Consider 500GB hard disk laptop example.
    • All space made as available by deleting existing partitions.
    • Consider below sample with no allocation of drives

010

  • Create a volume group 011

  • Select entire disk partition for that group 012

013

  • Create logical volume in that group 014

  • Specify root logical volume for OS & softwares storage

    • choose ext4 (linux format)
    • mount to / 015
  • Specify swap volume for extra RAM shortage space

    • typically 2*RAM size
    • Format - swap

016

  • Similarly create my-boot volume

    • typically 1 GB as per initial partition suggestion link
    • choose ext4 (linux format)
    • Mount it to /boot
  • Create my-home volume

    • choose remaining space
    • choose ext4 (linux format)
    • Mount it to /home 017
  • Final volume look 018

  • On GPT disks as mentioned in Partition SetUp link, we have to choose a boot disk. Current laptop has EFI partition.

    • Just choose the remaining specific partition & click on 'use as boot device'
    • For other styles, check Partition SetUp link

019 020

  • click done 021 022

  • profile setup (same user name & password are later used for login)

023

  • Choose SSH access

024

  • Click Reboot now

025

  • Remove your pen drive/ CD & hit enter (else re-initiates installation after restart)

026

  • Login With user name & pass 027

Image references

01

02

03

04

05

06

07

08

09

10

11

12

13

14

15

16

17

18

19

20

21

22

DNS server

  • to properly add DNS server don't change /etc/resolve.conf directly
  • ref
//install package
sudo apt update
sudo apt install resolvconf
  • open file "/etc/resolvconf/resolv.conf.d/head", add following
# Make edits to /etc/resolvconf/resolv.conf.d/head.
nameserver 8.8.4.4
nameserver 8.8.8.8
  • restart service
sudo service resolvconf restart

Ethernet Issue

(If internet not auto detected) network-configuration

  • add nameserver in '/etc/resolv.conf' file
//example
nameserver 192.*.*.*
nameserver 8.8.8.8 //google DNS server
nameserver 127.*.*.*
  • Configure ethernet in /etc/network/interfaces or /etc/netplan

  • In '/etc/netplan' following content

01-netcfg.yaml
  • In '/etc/netplan/01-netcfg.yaml' following content
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses: [ 10.10.*.*/* ]
gateway4: 10.10.*.*

Note : Check 'ip a' to find ethernets or 'sudo lshw -class network' for detailed ethernet

Sample dynamic ip addressing

'/etc/netplan/99_config.yaml' file

network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: true

later

sudo netplan apply

Sample static ip

'/etc/netplan/99_config.yaml' file

network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- 10.10.10.2/24
gateway4: 10.10.10.1
nameservers:
search: [mydomain, otherdomain]
addresses: [10.10.10.1, 1.1.1.1]

later

sudo netplan apply

Sample static ip 2

'/etc/netplan/99_config.yaml' file

network:
version: 2
renderer: networkd
ethernets:
enp0s8: //check by "ip a"
addresses: [192.168.56.101/24]
dhcp4: false

later

sudo netplan apply

Change default ports

Note : openssh-server/ openssh-client package must be installed

/etc/ssh
//open port
sudo ufw allow {port}/tcp
//edit file
sudo vi /etc/ssh/sshd_config
//add following line
Port {port}
//restart ssh service
sudo systemctl restart sshd
//To verify that SSH daemon is listening on the new port
ss -an | grep {port}
// to connect from client
ssh -p {port} {username}@{remote_host_or_ip}
  • to Disable password based SSH, check command-security.md

Create system restore points