To upgrade and update Raspbian, enter the following from the command line:
sudo apt-get update && sudo apt-get upgrade -y
The -y means you don't have to say 'yes' to any Yes/No questions.
sudo apt-get install rpi-update
If you want to automate these procedures it can be done by configuring apt's Periodic options. The Raspberry Pi comes with apt installed (it provides the apt-get commands, etc.), and as part of that package an automated script is installed (in /etc/cron.daily/apt) for doing automated updates on a daily basis (using the cron daemon). These may be controlled by creating (as root) a file /etc/apt/apt.conf.d/10periodic putting the following into it:
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "0";
This configuration will just run update every day for you so when you run sudo apt-get upgrade you'll install the latest packages (without having to first run apt-get update).
To configure apt to automatically upgrade packages as well - firstly you'll need to install a new package to make the unattended upgrades work:
sudo apt-get install unattended-upgrades
Then you change the following option to “1” in /etc/apt/apt.conf.d/10periodic to enable automated upgrades:
For more details see the comments inside the /etc/cron.daily/apt and then put the relevant options into the /etc/apt/apt.conf.d/10periodic file.