0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu 26.04 server basic setting note

0
Last updated at Posted at 2026-08-11

1.Basic config

Change to root
sudo su
cd ~

Setting vimrc can use mouse copy&paste
vim /usr/share/vim/vim91/defaults.vim

if has('mouse')
  if &term =~ 'xterm'
    set mouse=v # a to v
  else
    set mouse=v #nvi to v
  endif
endif

set pastetoggle=<F12> #new add

Setting root password
passwd

Updating apt
apt update

Setting timezone and locale
timedatectl set-timezone Asia/<City>

apt install language-pack-zh-hant fonts-noto-cjk fontconfig
fc-cache -f -v
locale-gen zh_TW.UTF-8
update-locale LANG=zh_TW.UTF-8
localectl status
Localhost tty can only show ASCII

2.OpenSSH & ufw config

Change OpenSSH-server port
echo 'Port 60022' >> /etc/sshd_config
Allow root login
echo 'PermitRootlogin yes' >> /etc/sshd_config

systemctl daemon-reload
systemctl restart sshd
systemctl status sshd

Modify ufw OpenSSH rule
#Allow localnet to access any port
ufw allow from <localnet>/24 comment 'localnet'
#Modify OpenSSHd port
sed -i 's/=22/=60022/' /etc/ufw/applications.d/openssh-server
ufw app update OpenSSH
ufw app info OpenSSH
ufw allow OpenSSH
ufw enable
ufw status verbose
systemctl enable ufw

Installing fail2ban to protect ssh-login
apt install fail2ban -y

vim /etc/fail2ban/jail.local

[DEFAULT]
bantime  = 1d
findtime = 10m
maxretry = 3
ignoreip = 127.0.0.1/8 ::1 <localnet>/24 // localhost and locannet

banaction = ufw
banaction_allports = ufw

systemctl restart fail2ban
systemctl status fail2ban
fail2ban-client status
fail2ban-client status sshd

3.Setting ip and Wake-on-Lan with networkd

cd /etc/systemd/network/
ls

Disabled dhcpd
sed -i '/DHCP=yes/ s/yes/no/' zzzz-dracut-default.network

Ckecking network config
vim 10-<if_name>.network

[Match]
Name=<if_name>

[Network]
Address=<host_ip/netmask>
Gateway=<gateway_ip>
DNS=1.1.1.1

Checking Wake-on-Lan is d(disabled) or g(enabled)
ethtool <if_name> | grep Wake

Enabled Wake-on-Lan
vim 10-<if_name>.link

[Match]
MACAddress=<Mac address>

[Link]
WakeOnLan=magic

Restarting network and checking status
systemctl restart systemd-networkd
systemctl status systemd-networkd
ip addr
ethtool <if_name> | grep Wake

4.Installing and setting xfce4

Install xfce4、firefox、font and input
apt install xfce4 xfce4-goodies xfce4-powermanager firefox \
ttf-mscorefonts-installer fcitx5 fcitx5-chewing fcitx5-chinese-addons
To choice lightdm instead of gdm3 let AnyDesk can login

Deleting Wayland sessions
ls /usr/share/wayland-sessions/
rm /usr/share/wayland-sessions/*

Starting xfce4 desktop
systemctl enable lightdm
system start lightdm

Switching with <ctrl>+<alt>+<number1~6> to login user account from Desktop
Switching terminal to xfce4-terminal in Setup - Setup manager - Default application - Utility

If xfce4 desktop hang while operating
systemctl restart lightdm

Login from xfce4, open application - setting - accessibility - mouse, uncheck 'use mouse simulate'

5.Installing and setting AnyDesk

Open firefox to anydesk.com and downloading anydesk_<ver>_amd64.deb
sudo dpkg -i anydesk_<ver>_amd64.deb

Open Anydesk form desktop and setting unattended access password

Connecting from other client anydesk with ID number
AnyDesk Can't login with root

6.Updating、rebooting and cleaning system

System upgrade and reboot
apt upgrade

reboot

Login with root or sudo in tty/shell
Removing needless pkg
apt autoremove

Cleaning apt downloaded files in /var/cache/apt/
apt clean

Checking snap pkg and deleting older version files
snap list --all
snap remove <older_ver_pkg>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?