2

I need to run the gnome-terminal with some command with sudo rights on the startup. How could I do that?

1 Answers1

0

Several people asking me why do I need to run the script on the startup with the GUI. The answer is - I want to know what's happening on the machine(Jetson Nano with Ubuntu). I need to know if the script running or not, what it does at a moment.

I've found the solution by myself:

the command to run the gnome-terminal on root with some command as an argument will look like this:

gnome-terminal -- sh -c 'echo "YOURPASSWORD" | sudo -S sh PATH_TO_YOUR_SCRIPT && sleep 1 && printf "\n"'

To put it on autostart:

create the file:
nano ~/.config/autostart/gnome-terminal.desktop

input the following :

[Desktop Entry]
Type=Application
Exec=gnome-terminal -- sh -c 'echo "YOURPASSWORD" | sudo -S sh PATH_TO_YOUR_SCRIPT && sleep 1 && printf "\n"'
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=anything
Name=anything
Comment[en_US]=anything
Comment=anything

Then Ctrl+x to save.
Done.