Last Updated: February 25, 2016
·
1.719K
· fdamilola

Updating and Upgrading packages on Ubuntu in a single shell script.

I have always found having to type apt-get update and upgrade commands cool but sometimes I just don't want to type them.

So I wrote a simple script to do the updating, upgrading and the subsequent cleaning of the packages from the cache for me.

It is a very simple script. Emphasis on "simple". I wouldn't be surprised if someone has done something similar.

Here is the content of the script:

sudo apt-get update
sudo apt-get upgrade
cd /var/cache/apt/archives
sudo rm -r *.deb
echo "Cleaned archive"

Simply copy the contents into a file and save as anything.sh .

You might wanna fix the file permissions to make it executable:

$chmod -R 0777 anything.sh

Then simply run using :

$./anything.sh

Voilla! You would just need to type in a "Y" when about to upgrade and your sudo password too.
Have fun. :)

PS :
If you are feeling cool enough, you might wanna hide the script somewhere in your directories and create an alias for it in your bash.rc file.

alias up="path/to/anything.sh"

That way you can easily, just run :

$up

and ./anything.sh gets executed.

Case closed. :D