How to execute sudo command in terminal window at startup

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Pangolin
Level 3
Level 3
Posts: 150
Joined: Sat Sep 12, 2015 4:16 pm

How to execute sudo command in terminal window at startup

Post by Pangolin »

Hi all.
When I log into my user's account on LM 18 Xfce I would like a terminal window to open up and have a certain sudo command typed.
I WANT to type in my password every single time to execute the sudo command, I'm not looking for a "sudo-with-no-password" solution.
In the startup menu I have already tried to add the following custom entry:

Code: Select all

exo-open --launch TerminalEmulator sudo THE_COMMAND_I_NEED_TO_RUN
what I get is a terminal window popping up asking for my password, but when I type it in the window just shuts down without performing any command.
Can you please give me advice?
Thanks.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
I'm here thanks to Windows 10
deepakdeshp
Level 20
Level 20
Posts: 12341
Joined: Sun Aug 09, 2015 10:00 am

Re: How to execute sudo command in terminal window at startup

Post by deepakdeshp »

If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
User avatar
AndyMH
Level 21
Level 21
Posts: 13757
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: How to execute sudo command in terminal window at startup

Post by AndyMH »

Don't know xfce, I run cinnamon. Assuming it has 'startup applications' in the menu then try as the command:

Code: Select all

gnome-terminal -e  sudo <your command>
man gnome-terminal for more info.

I'm using this to run a program at startup that looks at my calender and then gives me all the entries for the next week, output is to terminal (next step is a GUI version). When I first tried it, just running <my prog>, like you, terminal popped up and then disappeared.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Locked

Return to “Beginner Questions”