is it possible to to have a sudo command executed with the admin password?
sudo apt-get update -password is 'root'
this is to put a command into an application on the startup of Ubuntu which needs root access
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
If you want a particilar process to be run at startup as root then I'd suggest that you wrap it in a systemd/init.d script. For systemd something like this would probably work:
[Unit] Description=Some command [Service] User=root Type=oneshot ExecStart=/usr/bin/whateverprogram and associated arguments [Install] WantedBy=multi-user.target
Although in the above example I believe the User directive is superfluous.
Alternatively, without implementing some secrets management tool (see hashicorps vault, ansible has a similar feature etc) you're pretty much stuck with two options:
Create a /etc/sudoers.d/somefile with an entry to all a program to be run with elevated privileges without the password. Ie.
ALL ALL=/usr/bin/theprogramtorun NOPASSWD
Or you if you dont care in the slightest about the security of the system and your user is a sudoer you could try scripting up something like:
echo "thisisaterribleidea" | sudo -S /usr/bin/command
To pass the password in cleartext over the commandline