Linux commands for website owners

Essential Linux Commands Every Website Owner Should Know

A website can look simple in a browser while relying on many moving parts behind the scenes. When a page becomes slow, a domain stops resolving or a certificate appears incorrect, a few terminal commands can reveal the cause quickly. These Linux commands for website owners are useful on virtual private servers, cloud instances and local workstations with shell access.

You do not need to memorise every option. Start with the commands below, read their output carefully and avoid making changes until you understand what the system is reporting.

1. Check Storage with df and du

A full disk can prevent applications from writing logs, uploading files or updating databases. Run df -h to see available space on mounted filesystems in a readable format. If one is almost full, use du -sh on likely directories to estimate how much space they consume.

Large log, backup and cache directories are common causes. Investigate before deleting anything, because removing active files without a plan can create a larger problem.

2. Review Memory and Load

The free -h command summarises total, used and available memory. Linux deliberately uses spare memory for caching, so focus on the available figure rather than assuming every used megabyte is a problem.

Use uptime for a quick view of server load, or top for a live list of processes. Sustained high load may point to busy PHP workers, database queries, traffic spikes or scheduled jobs. These checks complement broader website monitoring beyond simple uptime.

3. Test HTTP Responses with curl

curl -I https://example.com retrieves response headers without downloading the full page. The status code shows whether the request succeeded, redirected or failed. Headers can also reveal caching behaviour, content type and the responding server.

Add -L when you want curl to follow redirects. This is especially helpful after changing a domain, enabling HTTPS or updating redirect rules.

4. Inspect DNS with dig

Use dig example.com to inspect DNS answers, including the returned IP address and TTL. Query a specific record with commands such as dig example.com MX or dig example.com NS. Comparing answers from different resolvers can help identify caching or propagation issues.

If the output feels unfamiliar, first review how DNS connects a domain name to a website.

5. Read Logs Efficiently

Logs often contain the clearest explanation for an error. tail -n 50 filename shows the latest 50 lines, while tail -f filename follows new entries in real time. Use grep to filter for a status code, IP address or error phrase.

Check your web server and application documentation for the correct log locations. Never publish log output without removing passwords, tokens, email addresses and other sensitive data.

6. Verify TLS with openssl

The command openssl s_client -connect example.com:443 -servername example.com displays the certificate presented by a server. It can help confirm the issuer, certificate chain and hostname when a browser reports an HTTPS problem. For background, see our guide to SSL certificates and HTTPS protection.

Build a Safe Troubleshooting Routine

Begin with read-only checks: storage, memory, load, HTTP response, DNS and logs. Record what you observe, change one thing at a time and test again. This method turns Linux commands into a dependable troubleshooting toolkit instead of a collection of risky shortcuts.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *