Operations 5 min read

Comprehensive Nginx Command Guide (2026 Edition)

This article provides a detailed reference of essential Nginx commands—including startup, shutdown, reload, configuration checks, process signaling, debugging, and monitoring—explaining their effects, typical use cases, and the underlying behavior of master and worker processes.

Architect Chen
Architect Chen
Architect Chen
Comprehensive Nginx Command Guide (2026 Edition)

Basic Control Commands (Must‑Know)

1️⃣ Start Nginx nginx By default reads /etc/nginx/nginx.conf, starts a master process and forks multiple worker processes to handle requests.

2️⃣ Start with a Specific Config File nginx -c /path/to/nginx.conf Useful for multi‑instance deployments or switching configurations in test environments.

3️⃣ Start with a Specific Working Directory nginx -p /usr/local/nginx/ Changing the working directory affects log, temporary, and cache paths.

4️⃣ Fast Stop nginx -s stop Immediately kills worker processes; requests may be lost.

5️⃣ Graceful Stop (Recommended) nginx -s quit Stops accepting new requests, lets existing ones finish, then shuts down workers.

6️⃣ Reload Configuration (Core Frequent Operation) nginx -s reload The master reads the new config, spawns new workers, and old workers exit after completing their current requests.

7️⃣ Restart (Not Recommended) nginx -s stop && nginx May cause a brief interruption.

Configuration Check Commands (Prevent Accidents)

8️⃣ Syntax Check nginx -t Outputs "syntax is ok" and "test is successful" when the configuration is valid.

9️⃣ Check a Specific Config File

nginx -t -c /etc/nginx/nginx.conf

Process and Signal Control (Advanced)

11️⃣ Smooth Upgrade (USR2) kill -USR2 `cat /var/run/nginx.pid` Starts a new Nginx binary while the old one continues handling requests.

12️⃣ Graceful Shutdown of Old Workers kill -WINCH `cat /var/run/nginx.pid` Signals old workers to finish current connections before exiting.

13️⃣ Force Kill kill -9 <pid> Immediately terminates the process; use only when Nginx is stuck.

14️⃣ Reopen Logs nginx -s reopen Commonly used after log rotation.

Debug and Run‑Mode Commands

15️⃣ Run in Foreground (Debug) nginx -g "daemon off;" Typical for Docker containers or local debugging.

16️⃣ Override Global Directives

nginx -g "worker_processes 4;"

Status and Monitoring Commands

17️⃣ View Processes ps -ef | grep nginx Shows master and worker processes.

18️⃣ Check Port Usage netstat -ntlp | grep 80 or ss -ntlp | grep nginx 19️⃣ Tail Real‑time Access Log tail -f /var/log/nginx/access.log Provides live request logs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ConfigurationLinuxNginxCommand LineProcess ControlServer Management
Architect Chen
Written by

Architect Chen

Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.