1

I'm looking for help creating a shortcut to open the terminal and run

sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y

I'd like to see the terminal and the progress the update is making if possible.

I know I can create a cron job or set up "Unattended-upgrades" but i'd like to execute the command myself and a desktop shortcut seems ideal.

So far I have created a blank file with this code:

[Desktop Entry]
Version=1.0
Name=Update
Comment=Test the terminal running a command inside it
Exec=bash 'sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y'
Icon=utilities-terminal
Terminal=True
Type=Application
Categories=Application;

All that seems to happen though is the cursor spins for a while and I don't know if it has actually run the command.

Thanks

  • have you looked at any task manager if it's actually running? You can tell that it is based on the network activity (LAN port lights flashing) and disk activity (yellow light flashing rapidly/continuously) – PNDA Jun 30 '16 at 15:46
  • I've ran it a few times now with the task manager open and there is no extra usage in ram or cpu. The ethernet switch on my desktop doesnt blink anymore than it is doing normally so I would say it isnt running the command. – Tabias Jun 30 '16 at 15:51
  • Did you make the file executable? – PNDA Jun 30 '16 at 15:55
  • not too sure tbh. all i did to create the file I've outlined above. – Tabias Jun 30 '16 at 15:56
  • sudo chmod +x /path/to/your/file – PNDA Jun 30 '16 at 16:18
1

I would create a file called update.sh then right click on the file and go to properties. In there you will see a property called "Allow executing file as program" Check that tick box and save. Now upon double clicking on the file it will now ask you to open it in the terminal and I believe your problem will now be solved.

Goodluck

  • I followed these instructions and added the line from above edited with PandaLion98 and Scruss's suggestions and it works. It prompts me to open in terminal but other than that it does everything I want it to. Thanks everyone!! – Tabias Jul 1 '16 at 11:45
  • Anything more complicated than just pointing to a script can be problematic in shortcuts. – SDsolar May 23 '18 at 15:08
0

Your problem is with the Exec line. bash 'command' is not a valid way to execute a command with bash, you want bash -c 'command'. However the exec line already uses a shell to execute the command so you do not need bash wrapper at all and can just use:

Exec=sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y

Note that you might find that the terminal window closes right after the last command finishes. If you want to keep it open you can add (depending on your terminal)

TerminalOptions=--hold or TerminalOptions=--noclose (depending on the terminal application you use).

Alternative you can append ; read to the end of the command to keep the terminal window open waiting for some input. This will work even if your terminal does not support an option to keep it open.

Exec=sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y; read

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.