How to run a .sh file in terminal on login
so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications. This didn't work. I tried editing the .desktop file for the startup application to set Terminal=true. This made it open temporarily but shut it down.
I tried editing .bashrc by adding the command bash /path/to/my/file.sh and it had the same effect. This seems like it should be really simple to do, even in linux, but I have tried lots of ways and had no success. I am on Ubuntu 14.something.
login startup .desktop .sh
add a comment |
so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications. This didn't work. I tried editing the .desktop file for the startup application to set Terminal=true. This made it open temporarily but shut it down.
I tried editing .bashrc by adding the command bash /path/to/my/file.sh and it had the same effect. This seems like it should be really simple to do, even in linux, but I have tried lots of ways and had no success. I am on Ubuntu 14.something.
login startup .desktop .sh
1
All of those methods should have worked (well, the.bashrc
one is only on opening a Terminal;.profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with#!/bin/bash
?
– saiarcot895
Jul 3 '14 at 16:41
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
You would be able to find out what filetype it is set to by typing inls -la
– ryekayo
Jul 3 '14 at 16:49
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53
add a comment |
so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications. This didn't work. I tried editing the .desktop file for the startup application to set Terminal=true. This made it open temporarily but shut it down.
I tried editing .bashrc by adding the command bash /path/to/my/file.sh and it had the same effect. This seems like it should be really simple to do, even in linux, but I have tried lots of ways and had no success. I am on Ubuntu 14.something.
login startup .desktop .sh
so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications. This didn't work. I tried editing the .desktop file for the startup application to set Terminal=true. This made it open temporarily but shut it down.
I tried editing .bashrc by adding the command bash /path/to/my/file.sh and it had the same effect. This seems like it should be really simple to do, even in linux, but I have tried lots of ways and had no success. I am on Ubuntu 14.something.
login startup .desktop .sh
login startup .desktop .sh
asked Jul 3 '14 at 16:38
user2662920user2662920
612
612
1
All of those methods should have worked (well, the.bashrc
one is only on opening a Terminal;.profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with#!/bin/bash
?
– saiarcot895
Jul 3 '14 at 16:41
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
You would be able to find out what filetype it is set to by typing inls -la
– ryekayo
Jul 3 '14 at 16:49
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53
add a comment |
1
All of those methods should have worked (well, the.bashrc
one is only on opening a Terminal;.profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with#!/bin/bash
?
– saiarcot895
Jul 3 '14 at 16:41
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
You would be able to find out what filetype it is set to by typing inls -la
– ryekayo
Jul 3 '14 at 16:49
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53
1
1
All of those methods should have worked (well, the
.bashrc
one is only on opening a Terminal; .profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with #!/bin/bash
?– saiarcot895
Jul 3 '14 at 16:41
All of those methods should have worked (well, the
.bashrc
one is only on opening a Terminal; .profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with #!/bin/bash
?– saiarcot895
Jul 3 '14 at 16:41
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
You would be able to find out what filetype it is set to by typing in
ls -la
– ryekayo
Jul 3 '14 at 16:49
You would be able to find out what filetype it is set to by typing in
ls -la
– ryekayo
Jul 3 '14 at 16:49
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53
add a comment |
2 Answers
2
active
oldest
votes
When you set Terminal=true
in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:
- open a terminal window, choose Profile Preferences
- choose "Title & Command" (at least that is what it is in Dutch, the second tab)
- in the section "when the command has finished" choose "keep terminal window open"
And of course, like you did, in the desktop file, set Terminal=true
add a comment |
Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."
Suppose path of your file is /home/foster/Desktop/script.sh
First make it executable by :
$ chmod +x /home/foster/Desktop/script.sh
Now just Add path of the script to file "/etc/rc.local" :
sh /home/foster/Desktop/script.sh
exit 0
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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%2faskubuntu.com%2fquestions%2f491313%2fhow-to-run-a-sh-file-in-terminal-on-login%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you set Terminal=true
in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:
- open a terminal window, choose Profile Preferences
- choose "Title & Command" (at least that is what it is in Dutch, the second tab)
- in the section "when the command has finished" choose "keep terminal window open"
And of course, like you did, in the desktop file, set Terminal=true
add a comment |
When you set Terminal=true
in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:
- open a terminal window, choose Profile Preferences
- choose "Title & Command" (at least that is what it is in Dutch, the second tab)
- in the section "when the command has finished" choose "keep terminal window open"
And of course, like you did, in the desktop file, set Terminal=true
add a comment |
When you set Terminal=true
in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:
- open a terminal window, choose Profile Preferences
- choose "Title & Command" (at least that is what it is in Dutch, the second tab)
- in the section "when the command has finished" choose "keep terminal window open"
And of course, like you did, in the desktop file, set Terminal=true
When you set Terminal=true
in the desktop file, the terminal window by default closes after the "the job has finished". An easy solution is to change your (terminal-) profile settings:
- open a terminal window, choose Profile Preferences
- choose "Title & Command" (at least that is what it is in Dutch, the second tab)
- in the section "when the command has finished" choose "keep terminal window open"
And of course, like you did, in the desktop file, set Terminal=true
answered Jul 3 '14 at 17:12
Jacob VlijmJacob Vlijm
64.5k9127223
64.5k9127223
add a comment |
add a comment |
Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."
Suppose path of your file is /home/foster/Desktop/script.sh
First make it executable by :
$ chmod +x /home/foster/Desktop/script.sh
Now just Add path of the script to file "/etc/rc.local" :
sh /home/foster/Desktop/script.sh
exit 0
add a comment |
Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."
Suppose path of your file is /home/foster/Desktop/script.sh
First make it executable by :
$ chmod +x /home/foster/Desktop/script.sh
Now just Add path of the script to file "/etc/rc.local" :
sh /home/foster/Desktop/script.sh
exit 0
add a comment |
Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."
Suppose path of your file is /home/foster/Desktop/script.sh
First make it executable by :
$ chmod +x /home/foster/Desktop/script.sh
Now just Add path of the script to file "/etc/rc.local" :
sh /home/foster/Desktop/script.sh
exit 0
Solution for Question --> "so I have a simple sh file I want to run whenever someone logs in. I tried adding it to startup applications."
Suppose path of your file is /home/foster/Desktop/script.sh
First make it executable by :
$ chmod +x /home/foster/Desktop/script.sh
Now just Add path of the script to file "/etc/rc.local" :
sh /home/foster/Desktop/script.sh
exit 0
edited Nov 8 '16 at 12:16
answered Jul 3 '14 at 17:00
vivekyad4vvivekyad4v
3091411
3091411
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f491313%2fhow-to-run-a-sh-file-in-terminal-on-login%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
All of those methods should have worked (well, the
.bashrc
one is only on opening a Terminal;.profile
would have been better). What are you doing inside the .sh file? Is the executable bit set? Does it start with#!/bin/bash
?– saiarcot895
Jul 3 '14 at 16:41
As @saiarcot895 you may forgot to give executable permissions to file.
– Sudheer
Jul 3 '14 at 16:43
You would be able to find out what filetype it is set to by typing in
ls -la
– ryekayo
Jul 3 '14 at 16:49
Please edit your post and include the script in question. Also, please clarify if you want this to run for a single user or for all users.
– terdon♦
Jul 3 '14 at 16:53