Skip to content
Innovialabs

Essential Linux Commands for Server Administration

Basics4 min

In short

Day-to-day server work needs only a couple dozen commands: ls, df, du for files, ps, top, systemctl for processes, ss, curl for network, journalctl, tail for logs, apt or dnf for packages, and adduser, chmod for permissions.

Which commands you need first

You do not need hundreds of commands to run a server confidently. A core set grouped by task is enough: files and disk, processes and services, networking, logs, packages, users and permissions. That set is below, with examples you can run as is. They assume a systemd-based distribution (Ubuntu, Debian, the RHEL family).

Files and disk

CommandWhat it does
ls -lahList files with permissions, sizes and hidden files
cd, pwdChange directory, print the current one
cp -r, mv, rm -rCopy, move, delete
find / -name "*.log"Find files by name
df -hFree space per disk
du -sh /var/*Size of each directory

A classic situation is "the disk is full". The sequence:

df -h                          # which partition is full
sudo du -sh /var/* | sort -h   # what takes the most space inside

Be careful with rm -rf: there is no trash and no confirmation. Check the path with ls before deleting.

Processes and services

  • top or htop shows CPU and memory load in real time.
  • ps aux | grep nginx finds a process by name.
  • kill PID stops a process gracefully; kill -9 PID forces it, only when the normal signal fails.
  • systemctl status nginx shows service state.
  • systemctl restart nginx restarts; reload rereads config without stopping, if the service supports it.
  • systemctl enable nginx starts the service at boot.
  • free -h and uptime show memory and load average.

Networking

ip a                           # interface IP addresses
ss -tulpn                      # listening ports and their processes
curl -I https://example.com    # response headers of a site
ping -c 4 8.8.8.8              # basic connectivity
dig example.com                # DNS records for a domain

ss -tulpn is the key command when a service "does not respond": you immediately see whether it runs and on which port. The older netstat is often not installed by default anymore.

On Ubuntu the firewall is usually managed with ufw: sudo ufw status, sudo ufw allow 443/tcp. Always allow SSH before enabling the firewall, or you will lock yourself out.

Logs

  • journalctl -u nginx -n 100 shows the last 100 lines of a service log.
  • journalctl -u nginx -f follows the log in real time.
  • journalctl --since "1 hour ago" shows events from the last hour.
  • tail -f /var/log/nginx/error.log follows logs written to files.
  • grep -i "error" /var/log/syslog searches by text.
  • less file pages through large files, with search on /.

Rule of thumb: for any problem, read the logs first, restart second.

Packages

TaskDebian/UbuntuRHEL/Rocky/Alma
Refresh package listsudo apt updatesudo dnf check-update
Upgrade the systemsudo apt upgradesudo dnf upgrade
Install a packagesudo apt install nginxsudo dnf install nginx
Remove a packagesudo apt remove nginxsudo dnf remove nginx

Update regularly, but on production do it after testing and with a rollback plan.

Users and permissions

sudo adduser deploy                    # create a user (Debian/Ubuntu)
sudo usermod -aG sudo deploy           # grant sudo rights
sudo chown -R deploy:deploy /srv/app   # change owner
chmod 640 config.env                   # owner reads/writes, group reads
id deploy                              # user's groups

chmod permissions are three digits: owner, group, others. 4 is read, 2 is write, 1 is execute. Never use chmod 777: it opens the file to everyone.

Common mistakes

  • Working as root all the time. Use a regular user with sudo.
  • Rebooting instead of diagnosing. The problem comes back, and you lose useful state.
  • Editing config without validating it. nginx has nginx -t, and many other services offer similar checks.
  • Ignoring disk space. A partition filled with logs breaks databases and applications.

FAQ

Knowing the basics helps because it is available almost everywhere. To start, nano is fine: it is simpler and often installed by default.

We can help with this

If you'd rather get the result than figure it all out yourself — this is what we do every day.

Discuss a project

Read next

Have an idea or a task? Tell us about it

We'll reply within one business day and propose a solution. The consultation is free.