How can i verify if a user is root in a java application?
Thanks
Process p = Runtime.getRuntime().exec("id -u")
Keep in mind that the "root" user on a system may not be called root
(although it's rare to change it), and it's also possible to alias it to another username. If the current user is root-like, the output will be 0
.
Easy. Just use
System.getProperty("user.name")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With