Wordpress has their own guide to upgrade wordpress, but in this post I will show you how I upgrade my all wordpress sites.

I using Ubuntu 14.04 server and I update wordpress from command line.

Backups

Before upgrade we backup our database and wordpress directory.

$ mkdir -p ~/backup
$ mysqldump -u user -p <database name> | gzip -9 > ~/backup/$(date +"%Y%m%d")_wordpress.sql.gz
$ tar -zcvf ~/backup/$(date +"%Y%m%d")_wordpress-dir.tar.gz /home/niko/public_html/

Download wordpress

$ cd /tmp/
$ wget https://wordpress.org/latest.zip
$ unzip latest.zip

Overwrite all new files

Remember change current directory to where wordpress located in your server.

$ cd ~/public_html/
$ cp -avr /tmp/wordpress/* .
$ rm -rf /tmp/wordpress /tmp/latest.zip

Open http://your_domain.com/wp-admin/upgrade.php in a browser and run that script. It makes all needed database conversions. If something fails, you still have your backups in ~/backup/ directory.

Source

http://www.cyberciti.biz/tips/howto-upgrade-wordpress-from-linux-unix-shell-prompt.html