Ask Your Question

sudo inside a script [closed]

asked 2014-10-22 14:38:27 -0500

bboran gravatar image

i have a file that is running at startup. there is a command inside that script file which needs to be run with sudo. how can i do this? command is;

/opt/flexnetserver/lmgrd -z -c lic.dat

what happens if i put sudo in front of this command? how its going to take admin rights without entering a password. i am a little bit confused. thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by randomuser
close date 2014-10-22 19:22:30.688343


This is the same problem you are trying to address in . @bboran, if you ask a question and find an answer inadequate, please communicate the problem in that question rather than opening a new one.

randomuser gravatar imagerandomuser ( 2014-10-22 19:22:19 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2014-10-22 14:54:47 -0500

rsc gravatar image

This depends on your sudo configuration in "/etc/sudoers". Note that this file should be edited only using "visudo" (or a similar tool) but not directly using another editor (even that is technically possible). If you append something like


into that file, a user named "username" can run any command after sudo without being asked to type any password. For your specific case it could be:

Cmnd_Alias NETFLEX = /opt/flexnetserver/lmgrd

Please keep in mind that above example is untested and might need some adjustions for your specific case.

edit flag offensive delete link more


tried it didnt work. also tried user ALL=(ALL) NOPASSWD: /opt/flexnetserver/lmgrd -z -c lic.dat it didnt work too. how can i check if my file starts at startup? also my file only contains the command inside it. is this the correct form of using a .sh file?

bboran gravatar imagebboran ( 2014-10-22 15:45:49 -0500 )edit

What did you try exactly? Actually something like


has to work.

Regarding your second question: Please let us keep that question in where it belongs to.

rsc gravatar imagersc ( 2014-10-23 01:19:38 -0500 )edit

answered 2014-10-22 14:48:12 -0500

skytux gravatar image

It is possible to run a command with sudo without password. I think there is enough documentation on internet about this.

Please, Google it :-)



edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-10-22 14:38:27 -0500

Seen: 233 times

Last updated: Oct 22 '14