How to Upgrade WordPress via SSH

How to Upgrade WordPress via SSH
WordPress has been very exciting and helpful especially in creating beautiful custom menus and lots of exciting drag and drop plugins. No doubt the long stress of coding and writing unnecessary programming language has been cut down or reduced by the innovative nature of WordPress.  For most WordPress users updating to a newer version is pretty straight forward.
Experimentally, it simply involves log into the WordPress dashboard, click on “Updates” and then select the option to update WordPress. Within 10 seconds or so you are set.
However, this is a dependent feature and depending on the settings of your server, the automatic update option will not work. In this case you’ll need to perform the update manually, which means deleting and uploading the files via FTP, which takes a lot of time (around 15 minutes for all WordPress files with an average Internet connection).
Is there a better way? Yes of course, and it’s called SSH. SSH stands for Secure Shell, and it’s a protocol for remote communications. Using this protocol you can basically connect to your server and perform commands as if you were using the computer personally.
PRECAUTIONS: Ensure you appropriately backup all your data and databases before trying any type of update, as you could mess things up and lose everything. Try the stuff below at your own risk.
First of all you need to contact your hosting provider to make sure you have SSH enabled on your account. After that you can login to your server by typing
on the command line, and after that you’ll be prompted to put your password. Usually the user and password are the same of your FTP account, but they might be different.
Once you are logged in you need to browse to your public_html directory, which is usually where WordPress is installed. If you are using a sub-directory, navigate to it. Then type this to download the latest WordPress files:
After that type this to decompress the file:
tar xfz latest.tar.gz
Next we need to delete the wp-admin and wp-includes directories, which you can do with the following commands:
rm -rf ./wp-includes
rm -rf ./wp-admin
Now you want to move the new wp-admin and wp-include directories to the root, so type the following commands:
mv ./wordpress/wp-admin ./
mv ./wordpress/wp-includes ./
Finally, go inside the WordPress directory with
cd wordpress
and copy its content to the parent directory (i.e., the root) overwriting the old ones:
cp -rpf -f * ../
Finally, type “cd ..” to go back to the root directory and delete both the tar file you downloaded and the wordpress directory with this:
rm -rf ./wordpress/
rm -f latest.tar.gz
That’s it. All you have to do now is to run the upgrade script on your WordPress install (i.e.,