Linux VPS

First steps on Linux

Update the system, create your own user and turn on a firewall. Commands differ slightly between distribution families.

Last updated

Update the system

Ubuntu and Debian:

apt update && apt upgrade -y

AlmaLinux, Rocky Linux, CentOS Stream, Fedora, Oracle Linux:

dnf upgrade -y

openSUSE:

zypper refresh && zypper update -y

Reboot if the kernel was updated: reboot, then reconnect after a minute.

Change the root password

passwd

Create your own user

Working as root all the time is risky. Create a user with admin rights (replace alex with your name).

Ubuntu and Debian:

apt install -y sudo
adduser alex
usermod -aG sudo alex

AlmaLinux, Rocky Linux and other Red Hat–style systems:

adduser alex
passwd alex
usermod -aG wheel alex

Then log in as that user with ssh alex@your-server-ip and use sudo for admin commands.

Turn on a firewall

Always allow SSH first, or you’ll lock yourself out.

Ubuntu and Debian (ufw):

apt install -y ufw
ufw allow OpenSSH
ufw enable

AlmaLinux, Rocky Linux and Fedora (firewalld):

dnf install -y firewalld
systemctl enable --now firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload

Open more ports only when you need them, for example ufw allow 80,443/tcp for a website.

Next

Set up SSH keys, then read Securing your server.