Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Useful Web Server Commands for Beginners

If you manage a Linux server, a few commands help a lot. This guide lists the most useful ones and what they do. It needs root access, which VPS and dedicated server plans normally have.

Web Hosting2 min read

What is a command?

A command is a line of text you type to tell the server what to do. You type it in a terminal, a text window connected to the server. You usually connect with SSH, a safe way to open that window from your own computer.

Warning: Commands act at once and often have no undo. Back up before changing or deleting anything.

Looking around

pwd

Shows which folder you are in.

ls -la

Lists files and folders, including hidden ones.

cd /var/www

Moves into the folder /var/www.

Reading files

cat file.txt

Prints the file on screen.

tail -n 50 /var/log/messages

Shows the last 50 lines of a log file. Log file names differ by system.

Checking the server's health

df -h

Shows how much disk space is used and free.

free -m

Shows memory use in megabytes.

top

Shows which programs use the most power. Press q to leave.

uptime

Shows how long the server has been running and how busy it is.

Controlling the web server

On many systems, a service manager called systemd controls programs. The web server name may be httpd (Apache on CentOS-style systems), apache2 (Debian and Ubuntu) or nginx.

systemctl status nginx

Shows if the web server is running.

systemctl restart nginx

Stops and starts it again. Visitors may see a short break.

systemctl enable nginx

Makes it start by itself after a reboot.

Testing and searching

nginx -t

Checks the Nginx settings for mistakes before you restart. Apache has a similar one: apachectl configtest.

curl -I https://example.com

Shows the reply headers from your site. This helps you see the status code.

grep "error" file.log

Finds lines that contain the word "error".

ss -tulpn

Lists open ports and which program uses each.

Tip: Always test the settings before you restart the web server. A small typo can take your site down.

Quick recap

  • Commands are typed in a terminal, usually over SSH.
  • df, free, top and uptime check server health.
  • systemctl starts, stops and checks the web server.
  • Test settings before restarting.
  • Back up before big changes.