Update WordPress from UNIX Shell Prompt

Posted on December 3, 2016 at 7:48 pm

Need to update WordPress from UNIX shell prompt?

Set the current directory to the root folder of WordPress installation:

cd /var/www/wpsite.com/htdocs/

Now type these commands to update WordPress to latest version:

rm -rf wp-admin
rm -rf wp-includes
mv wp-config.php wp-config.bak
rm -f *.php
mv wp-config.bak wp-config.php
wget -O latest.tar.gz https://wordpress.org/latest.tar.gz
gunzip latest.tar.gz
tar xf latest.tar
rm -f latest.tar
cd wordpress
mv * ../
cd ..
rm -rf wordpress

That’s all!

Here is a simple bash script:

#!/bin/bash
 
WP_PATH = ${1%/}
 
if [ -d "$WP_PATH" ]; then
    cd $WP_PATH
    rm -rf wp-admin
    rm -rf wp-includes
    mv wp-config.php wp-config.bak
    rm -f *.php
    mv wp-config.bak wp-config.php
    wget -O latest.tar.gz https://wordpress.org/latest.tar.gz
    gunzip latest.tar.gz
    tar xf latest.tar
    rm -f latest.tar
    cd wordpress
    mv * ../
    cd ..
    rm -rf wordpress
    echo "Done!"
fi

Save it as wp-updater.sh and set +x permissions:

chmod +x wp-updater.sh

Run it like this:

./wp-updater.sh /var/www/wpsite.com/htdocs/

Receive updates via email

Other Posts

Updated Posts