I installed Zentyal 4.0 and looking its scripts how it is functioning.
I saw a perl function to run the shell commands in machine like below
//Ebox::Sudo:root
...
/usr/bin/sudo -p sudo: {commands to perform}
Can anyone explain what it is meant sudo in the shell?
Thanks
This answer gives you an answer to both the
sudoand-p sudo:in your command.sudoitself is a privilege command allowing users to execute commands, if allowed in thesudoersfile, which generally is not allowed by normal users.The sudoers file can determine exactly which commands a user is allowed to run. Typically these commands can be run by either setting up the sudoers file by either prompting for the user password each time a command is being run, or by adding the NOPASSWD option which allows a user to run sudo commands without having to retype their password.
Example: a normal user cannot run dmidecode as you will get a access denied.
but if allowed in the sudoers file, you can allow the user to run the command as a super user.
Here is an example of a sudoers file entry allowing user to only run some
dmidecodeandsarusing sudo, without prompting for password.for the
-p sudo:part.The
-p(prompt) option allows you to override the default password prompt and use a custom one. The following percent (‘%’) escapes are supported by the sudoers.In other words in this case it will replace the default prompt for sudo password with the
sudo:text.So as an example, running a command like
df -hbut when running with
-pTIP! whenever you need to edit a sudoers file, you need to ensure you never do
vi sudoersas it will change file ownership. Always edit a sudoers file by running thevisudocommand asroot.