0

I want to have the gnome-terminal autostart and run a single line like echo "Hello World", after the user is logged in. Ubuntu automatically logs in the user. What is the best way to achieve this?

Tried to add gnome-terminal to the list of startprograms, but can't seem to add any additional commands. gnome-terminal -- 'echo "Hello World"' opens an empty terminal, but doesn't run the code.

5
  • Which flavor and version of Ubuntu are you using?
    – user68186
    Dec 6, 2020 at 13:14
  • Ubuntu 18.04 LTS with gnome. Dec 6, 2020 at 13:26
  • The answer suggests the same thing I have tried: gnome-terminal -- command, which for me opens the terminal, but without entering or executing the command. Dec 6, 2020 at 17:37
  • There are 5 answers with positive votes. Are you telling me y you have tried them all? If so please update your question with a link to the question and explain in your question how none of the answers in the other question didn't work for you.
    – user68186
    Dec 6, 2020 at 20:02
  • There is no error, the answer with gnome-terminal -- command opens the terminal without entering or executing the command. The second answer suggests the same, but without hardcoding gnome-terminal, so in the future other terminals could be used as well. Same issue though. The third answer does not help, as the user suggests an answer where the user can open a new terminal, from within the terminal. It's a manual process though. The fourth answer is the same as the first one, with the addition of the --tab flag to open multiple tabs. Still doesn't execute the command. Dec 14, 2020 at 17:22

1 Answer 1

0

To launch the terminal when a user logs in:

To launch for one user: copy /usr/share/applications/org.gnome.Terminal.desktop to ~/.config/autostart

To launch for all users on the system: copy /usr/share/applications/org.gnome.Terminal.desktop /etc/xdg/autostart/

This part may work, but I am unclear what the purpose of the output to the terminal will be.

To echo something out simply add whatever it is to the last line of the .bashrc, if you want it to only launch once per day you may need to get a little clever and set a "seen" file and test the date to see if has been seen once today for that user and if so don't show it again if not, update the "seen" file to set the new date.

If you want it for all users you will have to put a skeleton bashrc in /etc/skel but the code could be the same.

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