Code to ensure script runner is root user
Hi,
I just need a code fragment with checks if the user is the root user. Basically I need to ensure it was run as "sudo myscript" rather then just "myscript" I found Code:
if [ "$USER" != "root" ]; then Any help will be appreciated. |
You can use "id" program, like that:
Code:
if [ $(id -ur) != 0 ]; then |
Why not just set the execute permissions so that only root can run the script?
|
All times are GMT -5. The time now is 06:44 PM. |