If you are a user on your system that has sudo
privileges to run commands as root
, just pre-pend sudo
to the command.
system("sudo yum install some-package");
If you want anybody to be able to do it, then you have to be administrator on your system, change the owner of the file to be root
, and modify the permissions of your executable to run as root
. By doing so, you do not need to modify your system()
command string with sudo
.
chmod +s my_program
chown root my_program
Realize that doing this may open you up to security problems, unless you have proven that your program has no security issues.
The file-system may be such to disallow you from setting the setuid
bit on your program. If you need more information along these lines, you should consult SuperUser.