Testing shell_exec: whoami: nobody pwd: /var/www/html Testing postgres access: Command: sudo -u postgres psql bluebirds_ai -t -A -F'|' -c "SELECT COUNT(*) FROM blog_posts;" 2>&1 Result: ' We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required ' Testing simpler query: Command: sudo -u postgres psql bluebirds_ai -t -c "SELECT 'test';" 2>&1 Result: ' We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required '