Upgrade Magento 2.2 to 2.3 (from shell)

cd /var/www/domain.com/web && php7.0 bin/magento maintenance:enable;
# Set composer to 2.3.0
cd /var/www/domain.com/web && php7.0 /usr/bin/composer require magento/product-community-edition 2.3.0 --no-update;
# Download and execute pre composer script
cd /var/www/domain.com/web && wget "https://raw.githubusercontent.com/magento/magento2/2.3-develop/dev/tools/UpgradeScripts/pre_composer_update_2.3.php";
cd /var/www/domain.com/web && php7.2 -f pre_composer_update_2.3.php -- --root=/var/www/domain.com/web --composer=/usr/bin/composer --edition=community --repo=https://repo.magento.com/;
cd /var/www/domain.com/web && php7.2 /usr/bin/composer update;
cd /var/www/domain.com/web && rm -rf var/cache/*;
cd /var/www/domain.com/web && rm -rf var/page_cache/*;
cd /var/www/domain.com/web && rm -rf generated/code/*;
cd /var/www/domain.com/web && php7.2 bin/magento setup:upgrade;
cd /var/www/domain.com/web && php7.2 bin/magento setup:di:compile;
cd /var/www/domain.com/web && php7.2 bin/magento indexer:reindex;
cd /var/www/domain.com/web && php7.2 bin/magento setup:static-content:deploy;
cd /var/www/domain.com/web && php7.2 bin/magento cache:flush;
cd /var/www/domain.com/web && chmod 777 -R var generated;
cd /var/www/domain.com/web && php7.0 bin/magento maintenance:disable;
cd /var/www/domain.com/web && php7.2 bin/magento --version;

If you get an error it maybe due to read/write permissions. In that case run:

cd /var/www/domain.com/web && find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento;
cd /var/www/domain.com/web && rm -rf var/cache/*; rm -rf var/page_cache/*; rm -rf var/generation/*