How to run a .sh file in terminal on loginStarting Xmodmap on login (12.10)Cannot add/edit/remove Startup Applications; Ubuntu 14.04 with UnityHow to set gxmessage to run at login, and make exit codes trigger eventsanother login loop problemHow do I associate a file type with an appimage?Startup application not working after loginActivating conda environment in “startup applications” script
Can a polling station shut early if everyone has voted?
Bushing OK or need clamp? NM-B 6/3 going into breaker box
Is the weight of the aircraft flying in the sky transferred to the ground?
Secure Implementation of Password Database
How to arrange objects in outward facing circle?
Why is the superlative of "nah" not "am nähsten" but "am nächsten"?
How does a soft landing technically work without air on the moon?
Can a public school in the USA force a 14yr old to create a Twitter account for a passing grade?
Can you wield a a typical shield and Aegis of the Raven Queen at the same time?
Unexpected large rent payments, by moneygram, for my apartment, not by me
Could the barycenter orbit of our sun be greatly underestimated?
Do multimedia speaker systems run on AC power rather than DC?
Six letter words from "MONSTER"
Is the net charge on a capacitor zero? If yes, then why?
Are there any spell casters that can cast life giving spells without 'expensive' components?
Is it appropriate to rewrite and republish another author's useful but very badly written paper?
Has any person or company ever become a sovereign state?
No transit zone at Linate airport. Couldn't get on connecting flight. Whose responsibility is it?
Would a uranium 235 fuel pellet the size of Earth explode?
Is harmlessly appearing to be a school bus driver a crime?
Mysql GROUP BY is really slow on a simple view
Why is there no No:6 in the movie?
Undesired blank space between some words
Running SXA Creative Exchange Import on build and release pipelines (CI / CD)
How to run a .sh file in terminal on login
Starting Xmodmap on login (12.10)Cannot add/edit/remove Startup Applications; Ubuntu 14.04 with UnityHow to set gxmessage to run at login, and make exit codes trigger eventsanother login loop problemHow do I associate a file type with an appimage?Startup application not working after loginActivating conda environment in “startup applications” script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
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.bashrcone is only on opening a Terminal;.profilewould 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
111 silver badge2 bronze badges
111 silver badge2 bronze badges
1
All of those methods should have worked (well, the.bashrcone is only on opening a Terminal;.profilewould 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.bashrcone is only on opening a Terminal;.profilewould 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/4.0/"u003ecc by-sa 4.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
70.5k10 gold badges152 silver badges254 bronze badges
70.5k10 gold badges152 silver badges254 bronze badges
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
3541 gold badge4 silver badges12 bronze badges
3541 gold badge4 silver badges12 bronze badges
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
.bashrcone is only on opening a Terminal;.profilewould 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