Score:1

Open terminal and run sudo command on startup

mu flag

I have a custom command script called uua, that I put in /bin, and made it executable with chmod +x. I want my console to launch on startup and run the uua command, without me putting in the password for things with sudo.

/bin/uua's contents:

#!/bin/bash
sudo apt update -y && echo -e "\nUpdate Done\n" && echo -e "\nUpgrading:\n" && apt list --upgradable && echo && sudo apt upgrade -y && echo -e "\nUpgrade Done\n" && sudo apt autoremove -y && echo -e "\nAll Done!"

I tried things from some other posts, but I'm not sure how to get this done. The command to launch the console is konsole (since most other posts I've seen use gnome-terminal or something else).

Here are some things I tried:

  1. Adding konsole to startup applications, and changed the command there to konsole -e uua, and that works to start the konsole on startup, and execute the uua command, but required me to put in my password.
  2. For some reason, I didn't have /etc/rc.local, so I created it and added the konsole -e command there but that too, did not work.

In short, I want my console to launch on startup and run some sudo commands without me putting in the password.

Thanks!

vanadium avatar
cn flag
Prefer to put your custom binary in `/usr/local/bin` instead. Do you really need to run this command in a graphical terminal emulator? Can't you run it in the background then log the output for inspection if desired? Your approach, causing you to ask this question, very likely is not the best.
rogue1 avatar
mu flag
I would prefer for the command to run in a graphical terminal so I can see what it is updating/if it went through properly and also that way, I can make other commands/scripts which would need a graphical terminal. How can I make it run in the background without me putting in my password for sudo? Something like `uua > autoupdate.log`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.