Linux commands every WordPress developer needs on the server
Most WordPress hosts and every VPS give SSH access, and a handful of commands cover most server tasks faster than a control panel: finding what filled the disk, fixing file permissions, watching the error log while reproducing a bug, checking what PHP is doing. The examples assume Ubuntu or Debian with the site in /var/www/html; adjust the paths for your server.
Problem: A site shows errors or the disk is full, and the control panel is slow, limited or not available.
Solution: Use df and du for disk space, find with chmod for permissions, tail -f for logs, ps and top for processes, and systemctl to reload services.
Disk space
# Free space per partition
df -h
# The biggest folders inside wp-content
du -sh /var/www/html/wp-content/* | sort -h
# Files larger than 50 MB (old backups, huge logs)
find /var/www/html -type f -size +50M -exec ls -lh {} \;
Typical findings: backup archives in wp-content left by a backup plugin, a debug.log of several gigabytes, and thousands of thumbnails of an old theme in uploads.
Permissions
# Folders 755, files 644
find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;
# wp-config.php readable only by the owner (and the web server group)
chmod 640 /var/www/html/wp-config.php
# The owner should be the user PHP runs as, e.g. www-data
sudo chown -R www-data:www-data /var/www/html
Use 640 for wp-config.php when PHP runs as another user of the same group, 600 when it runs as the owner; with the wrong one the site shows “Error establishing a database connection”. Why these values and what to do when updates ask for FTP credentials is in correct WordPress file and folder permissions.
Logs
# Follow the error log while reproducing the problem in the browser
tail -f /var/log/apache2/error.log
tail -f /var/log/nginx/error.log
# WordPress' own log, with WP_DEBUG_LOG enabled
tail -n 50 /var/www/html/wp-content/debug.log
# Who hammers the site: requests per IP in the access log
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
Processes and services
# What uses the CPU right now top # PHP-FPM workers and their memory ps aux | grep php-fpm # Test the configuration, then reload without dropping connections sudo nginx -t && sudo systemctl reload nginx sudo apachectl configtest && sudo systemctl reload apache2 sudo systemctl restart php7.4-fpm
Reload instead of restart where possible: a reload applies the new configuration without interrupting requests that are running. Always test the configuration first; a typo and a restart take the whole site down.
NOTE: On shared hosting you usually cannot use sudo, chown or systemctl; the commands for disk space, permissions inside your own folder and logs still work. And before deleting anything large, check what it is: a “big backup” in wp-content may be the only recent copy of the site.