Welcome to Part 2! Now that we have a clean Headless Ubuntu server installation running, it’s time to configure it for real-world server use.
In this part, we’ll walk through essential post-installation tweaks to refine and secure your system, including root account configuration, console font adjustments, repository cleanup, SSH security, firewall setup, and power management.
Part 2: Headless Ubuntu Server: Post-Installation & Configuration
4. Post-Installation Configuration
Log in locally using the user account created during installation. Since Ubuntu defaults to using sudo, you will prefix administrative commands with sudo.
Setting a Password for the Root User (Enabling Root Account if Needed)
By default, Ubuntu locks the root account password for security, relying entirely on sudo for standard administrative tasks. If your workflow requires an enabled root account, you can set a password for it.
Set a password for the root account:
sudo passwd root
You will be prompted to enter your current user password, then enter and confirm the new password for root.
Test switching to the root user:
su -
Enter the new root password. If successful, your prompt will change to #. Type exit to return to your regular user shell.
Note: You can use:
sudo -i
to switch to the root account even if the root account is disabled.
Console Font Adjustment (Optional)
If you want to make the console font larger and easier to read on a physical display:
sudo dpkg-reconfigure console-setup
Select UTF-8, keep the default font set (Guess optimal character set), choose a font style, and select a larger size.
Disable Installation USB/CD Repository (If Needed)
To prevent apt from prompting for installation media when installing software, you may need to disable the installation USB/CD repository.
For Modern Ubuntu Releases (DEB822 Format)
Edit the Ubuntu sources file:
sudo nano /etc/apt/sources.list.d/ubuntu.sources
Look for any block starting with Types: deb that references cdrom: or media paths, and comment out those lines by adding # at the beginning.
# Types: deb # URIs: cdrom:[Ubuntu-Server 26.04 LTS _Resolute Raccoon_ - Release amd64 (20260423)]/ # Suites: resolute # Components: main restricted
For Traditional sources.list Format
Edit the traditional sources file:
sudo nano /etc/apt/sources.list
Find any line starting with deb cdrom:[Ubuntu...] and comment it out by placing a # at the very beginning.
Save and exit: Control + O, Enter, then Control + X (or Control + X, Y, then Enter).
Then update your package cache:
sudo apt update
Managing Sudo Privileges for Additional Users
The user account created during Ubuntu setup is automatically granted sudo rights. You do not need to configure anything for your primary account.
However, if you create additional regular users in the future and want to grant them sudo access, follow these steps.
Create the new user:
sudo adduser newusername
Add the user to the sudo group:
sudo usermod -aG sudo newusername
Verify group membership:
groups newusername
Configure SSH Security
OpenSSH Server is usually installed during setup. If you missed it, install it now:
sudo apt install openssh-server
Start SSH service:
sudo systemctl start ssh
Enable SSH at boot:
sudo systemctl enable ssh
To secure your SSH service, open the configuration file:
sudo nano /etc/ssh/sshd_config
Adjust the following settings as needed:
Change Default Port (Optional): Change Port 22 to a custom non-standard port, for example, Port 2222.
Disable Direct Root Login (Recommended):
PermitRootLogin no
Enable Direct Root Login (If Required):
PermitRootLogin yes
Note: prohibit-password allows root login via SSH key pairs while blocking password-based root logins.
Note: If a setting line is commented out with a #, remove the # to activate it.
Save and exit (Control + X, Y, then Enter), then restart the SSH service:
sudo systemctl restart ssh
Set Up Basic UFW Firewall
Ubuntu comes with UFW (Uncomplicated Firewall) pre-installed. Lock down unnecessary incoming connections:
sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow ssh sudo ufw enable sudo ufw status
Or, if the SSH port was changed:
sudo ufw allow 2222/tcp
Power Management (Ignore Lid Close & Display Timeout)
If running Ubuntu Server on a laptop, closing the lid will put the machine to sleep by default, and the screen may stay powered on indefinitely.
1. Ignore Lid Close (Laptops Only)
Edit the systemd logind configuration:
sudo nano /etc/systemd/logind.conf
Uncomment (remove #) or add the following lines:
HandleLidSwitch=ignore HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore
Save, exit, and apply changes:
sudo systemctl restart systemd-logind
2. Configure GRUB to Turn Off Display (Screen Blanking)
Force the physical console display to power down after a set period of inactivity, for example, 180 seconds = 3 minutes:
sudo nano /etc/default/grub
Find the line starting with:
GRUB_CMDLINE_LINUX_DEFAULT
Add consoleblank=180 inside the quotes:
GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=180"
Save and exit. Update GRUB and reboot:
sudo update-grub sudo reboot
5. Remote Access & Server Management
Disconnect any external keyboard and monitor. Your headless Ubuntu server now only requires power and an Ethernet connection.
Connect to the Server via SSH
From another machine on the same local network (Windows Terminal, PowerShell, or macOS/Linux Terminal) type:
ssh username@server-ip-address
ssh root@server-ip-addressExample:
ssh asm@192.168.1.155If you changed the SSH port:
ssh -p <port> username@server-ip-address
ssh -p <port> root@server-ip-addressExample:
ssh -p 2222 asm@192.168.1.155Enter your password.
Note: Use your regular user account or root account to access the server via SSH, depending on your configuration and needs.
Essential Server Maintenance Commands
Update System Packages and Clean Up Unused Packages
sudo apt update sudo apt upgrade sudo apt autoremove
Check System Uptime & Load
uptime
Check Memory (RAM) Usage
free -h
Check Disk Space & Drives
df -h lsblk
Check IP Address
ip a
Monitor Real-Time Resources
htop
top
Press q to exit.
Manage Background Services
Start, Stop, Restart, Reload a service:
sudo systemctl start <service_name>
sudo systemctl stop <service_name>
sudo systemctl restart <service_name>
sudo systemctl reload <service_name>Enable, Disable a service to start at boot:
sudo systemctl enable <service_name>
sudo systemctl disable <service_name>Service Status, currently running, starts at boot, failed to start:
sudo systemctl status <service_name>
sudo systemctl is-active <service_name>
sudo systemctl is-enabled <service_name>
sudo systemctl is-failed <service_name>
Check Active Listening Ports
ss -tulpn
Reboot Server
sudo reboot
Shutdown Server
sudo shutdown -h now
Your headless Ubuntu Server is now secure, optimized, and fully accessible over your local network!
You can disconnect your external monitor and keyboard if using a desktop and manage everything remotely via SSH.
.webp)