Ubuntu Server Initial Configuration
•
linux ubuntu system-administration
Change Hostname
Set a descriptive hostname:
sudo hostnamectl set-hostname myserver
Verify:
hostnamectl
Configure Timezone
List available timezones:
timedatectl list-timezones | grep Europe
Set your timezone:
sudo timedatectl set-timezone Europe/Madrid
Verify:
timedatectl
Enable Automatic Security Updates
Configure unattended upgrades:
sudo dpkg-reconfigure unattended-upgrades
Select Yes to enable automatic security updates.
Set Default Editor
Choose your preferred editor:
sudo update-alternatives --config editor
Enable Root Access Without Password
Warning: Only do this on secure, isolated systems.
Edit sudoers file:
sudo visudo
Add this line:
yourusername ALL=(ALL) NOPASSWD: ALL
Or for a group:
%sudo ALL=(ALL) NOPASSWD: ALL
Disable Root SSH Login
Edit SSH config:
sudo nano /etc/ssh/sshd_config
Set:
PermitRootLogin no
PasswordAuthentication no
Restart SSH:
sudo systemctl restart sshd
Set Up Swap
For servers with limited RAM:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Make permanent:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab