How to create a screen and execute a sudo command
I need a script to create a screen session and run a command inside, then detach and proceed with other screens. So I need something like screen -S vault -d -m $HOME/vault/v.sh
. However, v.sh
requires sudo privileges. What are my options?
- Leave it like that and run the whole script as
sudo
. Problem: the other scripts/sessions will also run assudo
, which is undesirable. - Insert
sudo
at the start:sudo screen -S vault -d -m $HOME/vault/v.sh
. - Insert it before calling
v.sh
:screen -S vault -d -m "sudo $HOME/vault/v.sh"
What is the best option?
ubuntu bash sudo gnu-screen
add a comment |
I need a script to create a screen session and run a command inside, then detach and proceed with other screens. So I need something like screen -S vault -d -m $HOME/vault/v.sh
. However, v.sh
requires sudo privileges. What are my options?
- Leave it like that and run the whole script as
sudo
. Problem: the other scripts/sessions will also run assudo
, which is undesirable. - Insert
sudo
at the start:sudo screen -S vault -d -m $HOME/vault/v.sh
. - Insert it before calling
v.sh
:screen -S vault -d -m "sudo $HOME/vault/v.sh"
What is the best option?
ubuntu bash sudo gnu-screen
1
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40
add a comment |
I need a script to create a screen session and run a command inside, then detach and proceed with other screens. So I need something like screen -S vault -d -m $HOME/vault/v.sh
. However, v.sh
requires sudo privileges. What are my options?
- Leave it like that and run the whole script as
sudo
. Problem: the other scripts/sessions will also run assudo
, which is undesirable. - Insert
sudo
at the start:sudo screen -S vault -d -m $HOME/vault/v.sh
. - Insert it before calling
v.sh
:screen -S vault -d -m "sudo $HOME/vault/v.sh"
What is the best option?
ubuntu bash sudo gnu-screen
I need a script to create a screen session and run a command inside, then detach and proceed with other screens. So I need something like screen -S vault -d -m $HOME/vault/v.sh
. However, v.sh
requires sudo privileges. What are my options?
- Leave it like that and run the whole script as
sudo
. Problem: the other scripts/sessions will also run assudo
, which is undesirable. - Insert
sudo
at the start:sudo screen -S vault -d -m $HOME/vault/v.sh
. - Insert it before calling
v.sh
:screen -S vault -d -m "sudo $HOME/vault/v.sh"
What is the best option?
ubuntu bash sudo gnu-screen
ubuntu bash sudo gnu-screen
asked Jan 17 at 10:16
uluulu
1063
1063
1
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40
add a comment |
1
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40
1
1
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40
add a comment |
1 Answer
1
active
oldest
votes
One option you haven't listed is that if v.sh itself requires sudo privs, put that in the shebang line at the top of the script:
$ head -1 $HOME/vault/v.sh
#!/usr/bin/sudo /bin/sh
This method has the slight advantage that your master script doesn't require any knowledge of which scripts require sudo and which don't.
The problem with puttingsudo
inv.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.
– ulu
Jan 24 at 9:43
One way to get around that is to edit yoursudoers
file to allow your account to run the script without entering a password. A line in your sudoers file likeulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.
– Jim L.
Jan 25 at 21:39
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395311%2fhow-to-create-a-screen-and-execute-a-sudo-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One option you haven't listed is that if v.sh itself requires sudo privs, put that in the shebang line at the top of the script:
$ head -1 $HOME/vault/v.sh
#!/usr/bin/sudo /bin/sh
This method has the slight advantage that your master script doesn't require any knowledge of which scripts require sudo and which don't.
The problem with puttingsudo
inv.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.
– ulu
Jan 24 at 9:43
One way to get around that is to edit yoursudoers
file to allow your account to run the script without entering a password. A line in your sudoers file likeulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.
– Jim L.
Jan 25 at 21:39
add a comment |
One option you haven't listed is that if v.sh itself requires sudo privs, put that in the shebang line at the top of the script:
$ head -1 $HOME/vault/v.sh
#!/usr/bin/sudo /bin/sh
This method has the slight advantage that your master script doesn't require any knowledge of which scripts require sudo and which don't.
The problem with puttingsudo
inv.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.
– ulu
Jan 24 at 9:43
One way to get around that is to edit yoursudoers
file to allow your account to run the script without entering a password. A line in your sudoers file likeulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.
– Jim L.
Jan 25 at 21:39
add a comment |
One option you haven't listed is that if v.sh itself requires sudo privs, put that in the shebang line at the top of the script:
$ head -1 $HOME/vault/v.sh
#!/usr/bin/sudo /bin/sh
This method has the slight advantage that your master script doesn't require any knowledge of which scripts require sudo and which don't.
One option you haven't listed is that if v.sh itself requires sudo privs, put that in the shebang line at the top of the script:
$ head -1 $HOME/vault/v.sh
#!/usr/bin/sudo /bin/sh
This method has the slight advantage that your master script doesn't require any knowledge of which scripts require sudo and which don't.
edited Jan 18 at 19:27
answered Jan 18 at 18:57
Jim L.Jim L.
42117
42117
The problem with puttingsudo
inv.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.
– ulu
Jan 24 at 9:43
One way to get around that is to edit yoursudoers
file to allow your account to run the script without entering a password. A line in your sudoers file likeulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.
– Jim L.
Jan 25 at 21:39
add a comment |
The problem with puttingsudo
inv.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.
– ulu
Jan 24 at 9:43
One way to get around that is to edit yoursudoers
file to allow your account to run the script without entering a password. A line in your sudoers file likeulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.
– Jim L.
Jan 25 at 21:39
The problem with putting
sudo
in v.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.– ulu
Jan 24 at 9:43
The problem with putting
sudo
in v.sh
is that it requires entering the password inside the screen. SO I have to manually go to the screen and enter it, which I'm trying to avoid.– ulu
Jan 24 at 9:43
One way to get around that is to edit your
sudoers
file to allow your account to run the script without entering a password. A line in your sudoers file like ulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.– Jim L.
Jan 25 at 21:39
One way to get around that is to edit your
sudoers
file to allow your account to run the script without entering a password. A line in your sudoers file like ulu ALL=(root) NOPASSWD: /bin/bash /home/ulu/vault/v.sh
might be what you need.– Jim L.
Jan 25 at 21:39
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395311%2fhow-to-create-a-screen-and-execute-a-sudo-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It depends on what you want to achieve. It's someone you have to make your mind up about. it looks like you know how to solve your problem. You even list some of the pro and con arguments.
– Seth
Jan 17 at 10:49
Well, I'm still a noob here, being a long time Windows user. So I definitely don't know what I'm doing.
– ulu
Jan 24 at 9:40