Sunday, March 16, 2025

How to Use nginx -vt Instead of /sbin/nginx -vt

1️⃣ Method 1: Add /sbin to $PATH (Temporary)
🔹 For the current session only

export PATH=$PATH:/sbin

✅ Now you can run:

nginx -vt

⚠️ This change will be lost after closing the terminal.
2️⃣ Method 2: Permanently Add /sbin to $PATH
🔹 For all future sessions

Modify ~/.bashrc or ~/.profile (Debian typically uses ~/.profile):

echo 'export PATH=$PATH:/sbin' >> ~/.profile

Then apply the changes:

source ~/.profile

✅ Now nginx -vt will work every time you open a terminal.

📌 This applies to the current user only. To apply it system-wide, modify /etc/profile.
3️⃣ Method 3: Create a Symbolic Link (Recommended)
🔹 The simplest and most effective method

sudo ln -s /sbin/nginx /usr/local/bin/nginx

✅ Now you can run nginx -vt from anywhere:

nginx -vt

📌 Summary
Nginx Path Summary

📌 Summary

Method Persistent? Use Case Notes
Method 1: export PATH=$PATH:/sbin ❌ No (Only for current session) Temporary fix
Method 2: Edit ~/.profile ✅ Yes (For current user) User-specific solution
Method 3: ln -s /sbin/nginx /usr/local/bin/nginx ✅ Yes (For all users) Best and simplest solution

Add comment

Fill out the form below to add your own comments