Back to commands

Hosting Operations

Read-only

Test Nginx Before Reload

You changed an Nginx config and need to validate syntax before reloading the service.

Command

nginx -t

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not treat a syntax pass as proof the upstream app or DNS is correct.

Expected output

A syntax-ok message or a line number for the config error.

System impact

Read-only. Nothing changes. Nginx parses configuration and reports whether reload is safe.

Recovery / rollback: no state is changed.

When to use it

Use this before any Nginx reload or deploy involving server blocks.

When not to use it

Do not treat a syntax pass as proof the upstream app or DNS is correct.

next steps

Related commands

Hosting Operations Can be slow

Find the Nginx Default Server

The wrong site answered because it was the fallback.

grep -RIn 'default_server' /etc/nginx/conf.d /etc/nginx/sites-enabled 2>/dev/null
Hosting Operations Can be slow

List Nginx Listen Directives

The site was configured, but the port was not.

grep -RInE '^[[:space:]]*listen[[:space:]]' /etc/nginx/conf.d /etc/nginx/sites-enabled 2>/dev/null
Hosting Operations Can be slow

Show Nginx Include Lines

The config was valid; it just was not included.

grep -RInE '^[[:space:]]*include[[:space:]]' /etc/nginx/nginx.conf /etc/nginx/conf.d /etc/nginx/sites-enabled 2>/dev/null
Hosting Operations Read-only

Show Enabled Nginx Sites

The config existed, but it was not enabled.

ls -l /etc/nginx/sites-enabled/
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • LFCS style performance-task practice

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.