Essential Linux Commands for Busy WordPress & Server Admins

Essential Linux Commands for Busy WordPress & Server Admins

When the Server Is On Fire and All You Have Is SSH

A few years ago, one of my WooCommerce clients called: “Site is down, we’re losing orders.”

I SSH’d into their tiny VPS from my old laptop, saw a blinking cursor, and… blanked. I knew Linux enough, but in that moment, I needed just a handful of commands to find logs, kill a bad process, and fix permissions.

That’s what this article is for.

If you run WordPress, WooCommerce, or any small-business site on Linux and mostly live in cPanel or a GUI, this is your survival pack of essential Linux commands. Nothing fancy—just the stuff that actually helps you fix problems.


Basic Survival: Getting Around the Filesystem

These are the commands you’ll use 80% of the time when poking around a Linux server.

1. `ls` – List Files

ls shows files and directories in the current path.

Examples:

ls          # list files in current directory
ls -l       # long format (permissions, owner, size)
ls -a       # include hidden files (like .htaccess)

Why it matters: You’ll use ls to confirm if a file really exists, check permissions, or see what’s inside your web root.

2. `cd` – Change Directory

Move between folders.

cd /var/www
cd /var/www/html
cd ~          # go to your home directory
cd ..         # go up one level

Why it matters: Basic navigation is required before you do anything else (edit config, check logs, etc.).

3. `pwd` – Where Am I?

Prints your current directory.

pwd

Why it matters: Easy way to avoid running dangerous commands in the wrong folder.

4. `cp` – Copy Files (Careful With Overwrites)

Copies files or directories.

cp source.php backup.php
cp -r /var/www/html /var/www/html-backup
  • -r means recursive (needed for directories).

Safety tip: Always copy critical files (like wp-config.php) before editing:

cp wp-config.php wp-config.php.bak

5. `mv` – Move or Rename Files

Used to move or rename files.

mv oldname.php newname.php
mv file.php /var/www/html/

Why it matters: Quick way to “disable” a plugin or config by renaming it.

6. `rm` – Delete Files (Danger Zone)

Removes files.

rm file.php
rm -r somedir
  • -r removes directories and their contents.

Safety tip: This doesn’t go to trash. Double-check with ls and pwd before hitting Enter.


Peeking Inside Files: Logs, Configs, and Quick Checks

You don’t always need a full editor. Sometimes you just want to see what’s wrong.

7. `cat` – Print Entire File

Shows the contents of a file.

cat wp-config.php

Good for small files, but can flood your screen for big logs.

8. `head` and `tail` – First or Last Lines

View the top or bottom of a file.

head error.log         # first 10 lines
tail error.log         # last 10 lines
tail -n 50 error.log   # last 50 lines

Why it matters: Log files often have the most recent error at the bottom, so tail is your friend during outages.

9. `grep` – Search Inside Output or Files

Search for text patterns.

grep "Fatal error" error.log

You can also combine with other commands using | (pipe):

tail -n 100 error.log | grep "PHP"

Why it matters: Fast way to find specific errors in giant log files.

10. `diff` and `cmp` – Compare Files

Compare two files to see what changed.

diff old.php new.php
cmp old.php new.php
  • diff shows line-by-line differences.
  • cmp checks whether files differ at all.

Good when you’ve edited something and want to see exactly what changed.


Permissions and Ownership: Fixing “Permission Denied” Safely

If your WordPress can’t write to wp-content, or backups fail, it’s usually permissions.

11. `chmod` – Change Permissions

Controls who can read, write, or execute a file.

chmod 644 file.php
chmod 755 directory

Why it matters: Too strict and your site breaks, too loose and you open security holes.

Basic idea: you’re adjusting mode bits to control access.

12. `chown` – Change Owner

Sets which user owns a file.

chown user file.php
chown -R user:group /var/www/html
  • -R applies recursively to all files and subdirectories.

Why it matters: Web server processes need correct ownership to read/write files.

Safety tip: Be extra careful with -R. Run ls -l first to see current ownership.

13. `sudo` – Run as Another User (Usually Root)

Executes commands with elevated privileges.

sudo ls /root
sudo cp file.php /var/www/html/

Why it matters: Many system tasks require higher permissions. Overusing sudo can hide mistakes, so only use it when needed.


Managing Processes: When Something Hogs the Server

High CPU, slow site, or stuck cron job? These commands help you see and control what’s running.

14. `ps` – List Processes

Shows running processes.

ps
ps aux

You’ll typically combine it with grep to find something specific:

ps aux | grep php

15. `top` – Live Process Viewer

Gives a live, updating view of processes and resource usage.

top

Why it matters: Good for spotting which process is eating CPU or memory.

Press q to quit.

16. `kill` – Stop a Process by PID

Ends a process using its ID (PID).

kill 1234

You normally get the PID from ps or top.

17. `killall` – Kill by Name

Stops all processes with a given name.

killall php

Use with care on production servers. It’s powerful and can stop more than you expect.


Networking Basics: Checking Connectivity and Remote Access

When your site is “down,” sometimes it’s just a network or SSH issue.

18. `ping` – Check Reachability

Tests if a host is reachable.

ping example.com

Watch for packet loss or high latency.

19. `ssh` – Remote Login

Securely connect to another Linux system.

ssh user@server

Why it matters: This is usually how you access your VPS or dedicated server.

20. `scp` – Secure Copy Between Machines

Transfers files over SSH.

scp backup.sql user@server:/path/
scp user@server:/path/file.php ./

Good for moving backups or config files between local and remote.

21. `wget` – Download Files

Fetch files from the web.

wget https://example.com/file.zip

Useful for grabbing packages or tools directly on the server.


Archiving and Compression: Backups the Simple Way

You don’t always need a fancy backup system; sometimes a quick archive is enough.

22. `tar` – Archive Files

Combines multiple files into one archive.

tar cf archive.tar dir/
  • c = create
  • f = use file name

Good for packaging directories before moving or backing them up.

23. `zip` and `unzip` – Compressed Archives

Handle zipped files.

zip archive.zip file1 file2
unzip archive.zip

Why it matters: Many plugins/themes or off-site backups use .zip format.

Safety tip: Unzip to a test directory first if you’re not sure what’s inside.


Built-In Help: Learn the Command Before You Break Stuff

You don’t need to memorize everything. Linux has documentation built in.

24. `man` – Manual Pages

Shows detailed documentation for a command.

man ls
man chmod

Why it matters: When you’re unsure about flags or syntax, man is your primary reference.

Tip: Use / to search within man pages, and q to quit.


Safe Habits: Don’t Turn a Small Problem Into a Disaster

Always Know Where You Are

Before running anything destructive like rm or chmod -R, run:

pwd
ls

This simple check saves you from wiping the wrong directory.

Copy Before You Edit

For any important file (configs, themes, plugins), keep a quick backup:

cp file.php file.php.bak

If your change breaks the site, just restore the backup.

Use Staging When Possible

If you have a staging server, test your changes there first. Same commands, less risk.


Quick Recap

You don’t need to be a Linux guru to keep a WordPress or small-business server healthy. If you’re comfortable with:

  • Navigating (ls, cd, pwd)
  • Viewing files and logs (cat, head, tail, grep)
  • Handling permissions (chmod, chown, sudo)
  • Managing processes (ps, top, kill, killall)
  • Doing basic networking and transfers (ssh, ping, scp, wget)
  • Creating simple backups (tar, zip, unzip)

…you already have a solid toolkit.

Next time your site is misbehaving and all you see is that lonely SSH prompt, you’ll have a practical set of commands to start troubleshooting, instead of random guessing.

Need more help? Check the latest CrushEdge posts.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.