The principle of an example is to help the understanding, not to be excuse to simplify the answer of the general problem. My script has a lot of commands (with some cd to root-access-only config files), and the solution can't be "Well, just do it directly with apt-get". So as root, do passwd test-account and set a password. adduser knows the -p option to set a password, tho its use is not recommended. use sudo it focused primarily on user specifications in the sudoers file. Your system's policy could be, that a password is required. I want to insist on the fact that this "apt-get update" was just an example FAR from whhat my script actually is. It allows a system administrator to distribute root system tasks without dis. This post is then for helping people having this problem and searching for the same solution (I didn't find a good post on it), and perhaps have better solutions coming from you guys. But I am not truly satisfied of this solution, particularly by the fact that I have to use 2 scripts for every command. So, ok, I create another script script2.sh as following : script2.sh It allows users to check whether a file has new data or to read error messages. Well, so I say to myself "Ok, that means that if I have a file refered in sudoers as I did, it will work without prompt only if I call him with sudo, what is not what I want". If you try to run sudo in the Linux command line without authenticating. (I think I didn't fully understand the difference)īut this doesn't solve my problem if I don't use sudo to execute this script : #. Then I added to my sudoers file (at the end to override everything else) : user ALL=(ALL:ALL) NOPASSWD:/path/to/script.shīy the way, I also tried the line : user ALL=(ALL) NOPASSWD:/path/to/script.sh Of course, if I execute this script, I get a prompt asking me for a password. And of course, because youre using sudo youll be prompted for your password. Here, were going run the whoami command as the user mary. I saw as the only solution to put sudo INSIDE script.sh. To use sudo to run a command as another user, we need to use the. For some reason I need, as user, to run without sudo a script script.sh which needs root privileges to work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |