4

This question already has an answer here:

I know there is lots of information on this around, but I still find it confusing. Please help me with this quick one liner.

What do I need to write and where to make this a permanent feature of my system?

This is the command:

sudo apt update &&\
sudo apt upgrade -y &&\
sudo flatpak update &&\
conda upgrade --all -y

Maybe call it with sudo updateall

Slight digression: I asked a question about upgrade appimage and snap a while ago. There exists appimagehub but it pooly supported at the current time and snap by design updates without user involvement and there is no way to change this I believe. The others here can be manually updated.

marked as duplicate by Eliah Kagan, Videonauth, karel, Charles Green, muru bash Nov 23 '17 at 14:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I'd store your 'command' in a text file 'updateall' (maybe as a second line with #!/bin/bash as the first line). next chmod a+rx the file so its executable. finally make it available to anyone & everywhere sudo ln -s /home/user/updateall /usr/local/bin/updateall (or somewhere else you want in your $PATH), so anyone can execute it. it can also be done in other ways eg. your own ~/bin or using alias etc – guiverc Nov 23 '17 at 1:14
  • 1
    Personally, I'd separate the commands. && implies relying on previous commands to work. For apt upgrade and update it makes sense, but doesn't for other two. So sudo bash -c 'apt update && apt upgrade' and let other two run by themselves. But that's just my opinion. – Sergiy Kolodyazhnyy Nov 23 '17 at 9:28
-1

To make it available to all users who have sudo privileges(needed for the commands)

sudo nano /etc/bash.bashrc

To make it available for your user only sudo nano /home/yourusername/.bashrc

Go to the bottom of the file and add your aliases like so, I included the commented out (#)ALIAS LIST title

#ALIAS LIST

alias updateall='apt update && sudo apt upgrade -y && sudo flatpak upgrade && conda upgrade --all -y'

alias sudo='sudo '

Save the file, then run exec bash from the terminal.

The first alias is your command, the second alias allows you to use sudo with aliases.

  • 2
    No need to alias sudo . Simply put sudo into the alias. – Videonauth Nov 23 '17 at 7:55
1

Here is a alias making command that will help you :

Open your .bashrc file using Sublime Text or Nano

subl ~/.bashrc

and paste the following in the end

aliasx() { echo "alias $1"="'${@:2}'" >> ~/.bashrc; }

Next time you want to add a bash alias jsut type in the terminal :

aliasx alias_name alias_command

Example : aliasx ba subl ~/.bashrc

EDIT:

YES, this method works with your sudo and &&, || and other perators like ;.

Example : aliasx updateall sudo apt-get update '&&' sudo apt-get upgrade

This results in the line alias updateall='sudo apt-get update && sudo apt-get upgrade' added in the end of your .bashrc

Use '&&', IE enclose the operators in single quotes to get them into your .bashrc files without errors.

Also as someone pointed out, maybe use separate commands ; instead of &&.

0

Create a file updateall, put it on your path /usr/local/bin and make it executable.

You can format the file like this:

#!/bin/sh

sudo apt-get update
sudo apt-get upgrade -y
sudo flatpak upgrade
conda upgrade --all -y

Then just run the script as updateall (without sudo)

  • 3
    I think this is actually a more elegant solution by removing sudo from the script. Except that conda is not a sudo command so that doesn't actually work. – jbbiomed Nov 23 '17 at 1:29
  • You can allow the conda command to be run as a normal user as terdon explains here – Zanna Nov 23 '17 at 9:26
  • Answer modified to run all commands except conda with sudo. – thomasrutter Nov 23 '17 at 22:19
  • sudo -u $USER conda upgrade --all -y does the job of running conda without sudo privileges. – himanshuxd Dec 13 '17 at 5:29

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