Permanent alias to update everything?

In Terminal, I can enter:

alias UpdateAll='sudo apt update && sudo apt full-upgrade && sudo flatpak update && sudo snap refresh'

... then when I enter UpdateAll, it runs through all the updates. But when Terminal is closed, that alias is lost.

How do I make it permanent, and how to I add a shortcut on the Zorin menu that I can just click?

Ah, figured part of it out.

In Terminal, enter:

sudo gedit ~/.bashrc

Edit that file by adding:

# Added manually
alias UpdateAll='sudo apt update && sudo apt full-upgrade && sudo flatpak update && sudo snap refresh'

Then exit gedit and in Terminal enter:

source ~/.bashrc

Now you can just start Terminal, enter UpdateAll, and it runs through the update process.

Now I just have to figure out how to add a shortcut on the Zorin menu.

2 Likes

You could do this by placing your snippet into a bash script instead of placing it in ~/.bashrc

Then set a keyboard shortcut pointing to your script.

1 Like

I'm trying different combinations in the Main Menu application, but each time I click the icon, gnome-terminal starts up with the error Failed to execute child process ā€œ-eā€ (No such file or directory).

I just have to figure out how to pass a command to gnome-terminal when starting it.

Well, apparently one cannot pass an alias as an argument when starting Terminal, but I got it working the brute-force way.

Zorin (menu) > System Tools (menu item) > Main Menu (program) > System Tools (menu item in the Main Menu program) > Administration (menu item in the Main Menu program)

... click New Item and enter under Name Update All, under Command gnome-terminal -- /bin/sh -c 'echo Updating; sleep 5; sudo apt update; sudo apt full-upgrade; sudo flatpak update; sudo snap refresh; exec bash', under Comment Updates all software, FlatPaks and Snaps, leave the Launch in Terminal? unchecked, and finally click the OK button.

If you want the Terminal to close automatically after the update is finished, you'd do all of the above, but you'd enter under Command gnome-terminal -- /bin/sh -c 'echo Updating; sleep 5; sudo apt update; sudo apt full-upgrade; sudo flatpak update; sudo snap refresh'

One last item... how do I assign a custom icon to a Zorin menu item?

Install alacarte

sudo apt install alacarte

It is very similar to Main Menu (Menulibre)
Select an app, then in the right hand toolbar, select Properties.
A new window pops up. On the left, you see the Icon in an icon button. Click that.
Navigate to the location of your preferred icon and select it.

It may work the same way in Menulibre... I am not sure.

Sort of got it figured out... I found a bunch of icons at /usr/share/icons/, but when I change the icon in the Main Menu program, that change isn't reflected in the Zorin menu. I'll try a reboot to see if that's what's required.

[EDIT]
Nope, still got some learning to do. Reboot didn't change the icons in the Zorin menu.

In a text file, you should be able to write the shebang and then your command. I've put together an example below:

#! /bin/bash
apt update && apt full-upgrade && flatpak update && snap refresh

Best practice would be NOT to use sudo in the script.

  1. Write the script without the use of sudo.

  2. chmod script file to root and take all permissions away from user and others. Ensure it is executable (whether placing it in an executable directory or modifying just this file).

  3. Run the script with sudo. (Ex. sudo ~/Documents/update [update would be the file name... extensions aren't necessary in Linux] ).

This way sudo is called once and applies to all commands in the script.

Assign the script to a key combination [SUPER + Alt + u] and it will execute.

1 Like

Reboot should not be necessary - it changes that moment.

I just tested this and it took effect immediately.

In order to run an alias with sudo (ie: sudo UpdateAll, rather than merely UpdateAll with sudo within the command), you have to set an alias for sudo in ~/.bashrc:

alias sudo='sudo'

That's why I included sudo in the command gnome-terminal -- /bin/sh -c 'echo Updating; sleep 5; sudo apt update; sudo apt full-upgrade; sudo flatpak update; sudo snap refresh; exec bash'... I couldn't figure out how to get it to run from a Zorin menu icon with sudo wrapping all the arguments.

Huh... I was perusing Stacer's Uninstaller section, and I noticed that alacarte was already installed, so I opened terminal and gave the command sudo alacarte, and Main Menu came up! Main Menu is alacarte.

1 Like

They are both so similar and I use them so infrequently, I can never remember which is what comes default.

By the way, you can also assign that code above to a keyboard shortcut.

Settings > Keyboard Shortcuts, scroll to the bottom and click the '+' button. Enter in a name for the shortcut, enter in the code... for instance:

gnome-terminal -- /bin/sh -c 'echo Updating...; sleep 5; sudo apt update; sudo apt full-upgrade; sudo flatpak update; sudo snap refresh'

... you can change it to any Terminal commands between the single quotes, separate multiple commands with a semicolon and a space...

... then provide whatever keyboard shortcut you want. I've got Super+M to recover memory, and Super+U to update.

It helps, of course, if you increase the time period that the OS doesn't ask you for a password again.

sudo visudo

That opens /etc/sudoers

Change the line:
Defaults env_reset
to...
Defaults env_reset, timestamp_timeout=480
... or whatever timeout you want. I've got my timeout set to one day (timestamp_timeout=1440).

Then press Ctrl+X, then Y to exit visudo.