BASH Super Oneliner Update Command

Run all update commands form the Linux command line with just one simple command.

sudo bash -c 'apt update && apt upgrade -y && apt autoremove -y;snap refresh'; brew upgrade; flatpak update

Adjust as necessary for your needs:

  1. Put additional commands that require sudo after snap refresh but before the apostrophe '.
  2. Put additional commands that do not need sudo privileges after flatpak update. Separate new commands with a semi-colon.

Add the command to your terminal alias list:

Open your local alias file:

nano ~/.bash_aliases

Add this alias to the file to create your new super update command supdate:

alias supdate=" sudo bash -c 'apt update && apt upgrade -y && apt autoremove -y;snap refresh'; brew upgrade; flatpak update"

Save the file using Ctrl+X.

Execute BASH:

. ~/.bashrc

Now test your new oneliner update command:

supdate

We use supdate as our custom alias command to prevent it colliding with other commands. We can’t us su because that’s taken for use as a BASH command. We can’t use update because that might be taken by a script.

Type it Faster

We can use a BASH history shortcut to shorten our supdate command.

Your BASH command history can be recalled by typing history in the command line. Any historical command can be executed by typing !# where # represents the line order of the command.

For example, if your history looks like:

history
1 history
2 nano ~/.bash_history

You could type !1 to view history or !2 to edit your command history.

Edit your BASH history and add the alias for your new super oneliner update command to your command history list. Add it near the top of the list, say, item 3 so it can be executed as !3.

nano ~/.bash_history

Add supdate to the list:

history
1 history
2 nano ~/.bash_history
3 supdate

Faster Access?

Add a desktop launcher then add it to your Task Manager bar for one-click updates.

There are two options for this:

  1. Execute the full command with the launcher
  2. Execute the alias with the launcher (recommended)

Decide which to use then execute one of the following commands.

Full Command

echo -e "[Desktop Entry]\nVersion=1.0\nType=Application\nName=System Update\nComment=Update system packages\nExec=sudo bash -ic 'apt update && apt upgrade -y && apt autoremove -y;snap refresh'; brew upgrade; flatpak update\nIcon=system-software-update\nTerminal=true\nCategories=System;" > ~/.local/share/applications/system-update.desktop

chmod +x ~/.local/share/applications/system-update.desktop

Alias (recommended)

Using this method makes the command easier to modify.

echo -e "[Desktop Entry]\nVersion=1.0\nType=Application\nName=System Update\nComment=Update system software\nExec=bash -ic 'source ~/.bashrc; supdate'\nIcon=system-software-update\nTerminal=true\nCategories=System;" > ~/.local/share/applications/system-update.desktop

chmod +x ~/.local/share/applications/system-update.desktop

Add the launcher to your Task Manager

Open your Programs Manager menu and browse to System > System Update then right-click the System Update icon to pin the new launcher to your Task Manager bar.

How to update the command

If you need to modify the supdate alias command all you need to do is open ~/.bash_aliases to edit your alias. The desktop launcher will run your alias command.

If you used the full command in the desktop launcher you will need to edit the launcher with nano ~/.local/share/applications/system-update.desktop

Hot Tip

Check your bashrc file to confirm a separate aliases file is being called into it.

nano ~/.bashrc

Uncomment or add:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

Your aliases stored in bash_aliases will not work without the above lines in bashrc.

Have fun and share your tips in the comments.

Sharing is caring!

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x