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