UnderHost
Knowledgebase Docs

Linux server basics: packages, services, logs, users and updates

The everyday tasks of running a Linux VPS or dedicated server: install software with dnf or apt, manage services with systemd, read logs, add sudo users, apply updates and check disk, memory and load.

On this page

A Cloud VPS or dedicated server gives you full root access, so day-to-day care is in your hands: installing software, keeping it updated, restarting services and reading logs when something goes wrong. This guide covers those tasks. For moving around files and folders, see Linux command line basics first.

Know your Linux family

Most commands are the same everywhere. The main difference is the package manager:

FamilyExamplesPackage managerFirewall tool
Red Hat familyAlmaLinux, Rocky Linux, CloudLinuxdnffirewalld
Debian familyDebian, Ubuntuaptufw (Ubuntu), nftables
terminal
cat /etc/os-release     # which distribution and version
uname -r                # running kernel
hostnamectl             # hostname, OS and kernel together

Where things live

PathWhat is there
/etcConfiguration files, for example /etc/ssh/sshd_config
/var/logLog files
/var/wwwWebsites, on servers without a control panel
/homeUser folders; on cPanel servers, each account's files
/rootThe root user's home folder
/tmpTemporary files, cleared on reboot on many systems

Install and update software

AlmaLinux, Rocky Linux, CloudLinux
dnf check-update          # list available updates
dnf upgrade -y            # install all updates
dnf install -y htop       # install a package
dnf remove htop           # remove a package
dnf search nginx          # find a package
Debian, Ubuntu
apt update                # refresh the package list
apt upgrade -y            # install all updates
apt install -y htop       # install a package
apt remove htop           # remove a package
apt search nginx          # find a package
Servers with cPanel/WHM

On a cPanel server, update cPanel and its software (EasyApache, PHP) through WHM or /scripts/upcp, and the operating system with dnf. Do not remove cPanel's packages with the package manager.

Start, stop and enable services

Services such as the web server, database and SSH are managed by systemd:

terminal
systemctl status nginx        # is it running? recent log lines
systemctl restart nginx       # stop and start
systemctl reload nginx        # re-read config without dropping connections
systemctl enable --now nginx  # start now and at every boot
systemctl disable nginx       # do not start at boot
systemctl --failed            # list services that failed

Check a configuration before restarting: nginx -t, apachectl configtest, sshd -t. A typo then shows up as an error, not as a website that is down.

Read the logs

terminal
journalctl -u nginx --since "1 hour ago"   # one service
journalctl -p err -b                       # errors since the last boot
journalctl -f                              # follow new messages live

tail -f /var/log/nginx/error.log           # follow a log file
grep -i "error" /var/log/messages | tail   # AlmaLinux, Rocky Linux
grep -i "error" /var/log/syslog | tail     # Debian, Ubuntu
ProblemLook in
Website errors (500, 502)Web server error log, PHP error log
Login attempts/var/log/secure (Red Hat family), /var/log/auth.log (Debian family)
Service will not startsystemctl status name, then journalctl -u name
Server rebooted or frozejournalctl -b -1 (the previous boot), last reboot

Users and sudo

Work as a normal user and use sudo for admin commands. Mistakes are less costly, and logs show who ran what.

as root
adduser alex && usermod -aG sudo alex                    # Debian, Ubuntu
useradd -m alex && passwd alex && usermod -aG wheel alex  # Red Hat family

sudo -l          # (as alex) check what you may run
id alex          # user and groups

Give each person their own SSH key. See Manage SSH keys on your VPS.

Check disk, memory and load

terminal
df -h                               # free disk space per filesystem
du -xh / --max-depth=1 | sort -h    # which top folders use the space
free -h                             # memory and swap
uptime                              # load average for 1, 5 and 15 minutes
top                                 # live processes (or htop)
ss -tulpn                           # which services listen on which ports

A full disk is one of the most common reasons sites and databases stop. Logs and old backups are the usual causes. The load average is high when it stays above the number of CPU cores (nproc).

A weekly routine

  • Install updates, and reboot when a kernel update needs it. See kernel updates.
  • Check df -h and systemctl --failed.
  • Look at recent errors with journalctl -p err --since "7 days ago".
  • Make sure the last backup finished, and test a restore now and then.
  • Review who can log in: users, sudo group and SSH keys.

If you would rather not run these tasks yourself, UnderHost offers server management.

FAQ

It depends on the operating system. AlmaLinux, Rocky Linux and CloudLinux use dnf. Debian and Ubuntu use apt. Run cat /etc/os-release to check.
Only for some updates, mainly the kernel. Most services restart themselves or need a systemctl restart. On Debian and Ubuntu, the file /var/run/reboot-required appears when a reboot is needed; on the Red Hat family, dnf needs-restarting -r tells you.
It works, but one wrong command can damage the system. Use a normal user with sudo for everyday work, and log in with SSH keys.

Related: Linux command line basics | Manage SSH keys on your VPS | SSH hardening | Kernel updates

Was this article helpful?

Need a server with this OS?

Deploy Linux or Windows workloads on an UnderHost Cloud VPS or dedicated server with the operating system that fits your stack.

Related articles

Back to Operating Systems