1

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.

5
  • 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? Jul 3, 2014 at 16:41
  • As @saiarcot895 you may forgot to give executable permissions to file.
    – Sudheer
    Jul 3, 2014 at 16:43
  • You would be able to find out what filetype it is set to by typing in ls -la
    – ryekayo
    Jul 3, 2014 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, 2014 at 16:53
  • You can try this askubuntu.com/questions/704768/… /etc/profile.d
    – dedunu
    May 29, 2020 at 7:26

2 Answers 2

0

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

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .