How do I know if a script is running as root?

Đạt Michio

New member
How do I know if a script is running as root?
Answer
If your script is always to be run by root, simply set the rights accordingly ( 0500 ). There is a simple check for a user being root.
The [[ stuff ]] syntax is the standard way of running a check in bash. This also assumes that you want to exit with a 1 if you fail.
 

Tìm kiếm

Back
Top