0

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

I have 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.

Tasmotanizer
  • 337
  • 1
  • 5
  • 15
  • 1
    Does this answer your question? [Prevent Gnome Terminal From Exiting After Execution](https://stackoverflow.com/questions/4465930/prevent-gnome-terminal-from-exiting-after-execution) – tripleee May 17 '23 at 07:23

2 Answers2

0

You can do something like this:

#!/bin/bash
gnome-terminal -- bash -c "echo \"Hello World\";bash"

But keep in mind that the new spawned terminal will close after the command is done executing. So if you execute without the bash as the last command, the terminal will execute, but will be gone before you can see it.

Baldo
  • 26
  • 4
0

In Ubuntu you can do it in such a way:

Create a script you want to run, let it be script.sh. Make the file executable:

chmod +x script.sh.

Open autostart application and add command:

gnome-terminal --command="/path/to/your/script.sh"

enter image description here

Restart.

Viktor Ilienko
  • 817
  • 8
  • 15