The command line looks intimidating until you realize 90% of the work is three commands: see where you are, list what’s there, and change folders. Learn those and the rest of this series becomes easy. This is part one: the foundation WP-CLI and SSH build on.
pwd: where am I?
The terminal always has a “current folder”. pwd (print working directory) prints its full path so you know where you’re standing.
pwd
/home/youraccount/public
ls: what’s here?
ls lists the contents of a folder. Flags make it more useful: -l gives a detailed list, -a shows hidden files (the ones starting with a dot, like .htaccess).
ls # simple list
ls -la # detailed, including hidden files
ls wp-content/plugins # list a specific folder
cd: change folder
cd (change directory) moves you between folders. A few shortcuts are worth gold: .. goes up one level, ~ takes you to your home folder, and cd with no argument does the same.
cd public/wp-content # go into wp-content
cd .. # up one level
cd ~ # home
cd /home/youraccount/public # jump straight there by full path
A practical example
Say you’ve just SSH’d in and want to reach your WordPress install to run WP-CLI. Here’s how you find it:
pwd # where did I land?
ls # do I see a "public" folder?
cd public # go into the web root
ls wp-config.php # is it there? Then I'm in the right place.
If you see wp-config.php and wp-content, you’re in the root of your WordPress site, where every WP-CLI command should be run.
Three time-saving tips
- Tab completion: start typing a folder name and press Tab, and the terminal fills in the rest.
- Up arrow: recalls your last command so you don’t retype it.
- clear: wipes the screen when it gets cluttered.
The full WP-CLI series
- Terminal basics: getting around with cd and ls
- SSH into your server and run search-replace
- Update plugins with WP-CLI
- Update your theme with WP-CLI
- The most important WP-CLI commands
Rather not do it yourself? At Celestio, WP-CLI and SSH access are part of Managed WordPress. We keep core, themes and plugins updated for you. And you can always SSH into your own cloud server and run the commands above whenever you like.
