Have you ever felt frustrated when your WordPress site goes down and you can’t access the dashboard? Or wished you could resolve an issue quickly without waiting for your hosting provider?
This is where SSH commands come to your rescue.
With SSH, you can perform tasks such as troubleshooting, updating files, and managing your site independently of the WordPress dashboard.
If you’re not a developer, SSH may seem daunting at first. However, once you become familiar with it, it will be one of the most dependable methods to keep your site operating smoothly.
In this guide, we will introduce you to 16 essential SSH commands that every WordPress user should be familiar with. These commands are straightforward, effective, and extremely helpful for routine tasks as well as unexpected issues.
🌟 Pro Tip: Are you locked out of your WordPress site and unsure how to proceed? Our team of experts can assist you in regaining access swiftly. Explore our CanadaCreate Premium Support Services today!
Quick Navigation: SSH Commands for WordPress Users
Below are all the topics and commands we will discuss in this guide. Click the links to navigate directly to any section:
- What Is SSH?
- How to Connect to Your WordPress Site Using SSH
- pwd – Displays the full path of the current directory
- ls – Lists all files and folders in the current directory
- cd – Changes the current directory
- mkdir – Creates a new directory
- rmdir – Deletes an empty directory
- cp – Copies a file or folder
- mv – Moves a file or folder to a new location
- grep – Searches for a specific text string
- find – Locates files and directories
- zip – Compresses a folder into a zip file
- unzip – Extracts files from a zip archive
- history – Displays a list of recently used commands
- tar – Creates and extracts compressed archive files
- clear – Clears the terminal screen of all text
- du – Shows the size of a file or folder
- exit – Disconnects from the remote server
- Common Questions About SSH
Let’s begin.
What is SSH?
SSH, which stands for Secure Shell, is a secure protocol that allows you to manage your website through a command-line interface.It enables you toconnect
your computer to your website’s server.
The advantage of using SSH is that it provides remote access to your site, eliminating the need to log into the WordPress dashboard.
Think of it as having a direct access point to your WordPress site. 🚪
SSH is designed for more technical users or developers who wish to execute commands directly.
Nonetheless, other users can utilize SSH to access their site if issues arise that prevent them from accessing the WordPress admin area.
How We Utilize SSH at CanadaCreate
Our development team depends on SSH for effective server management.
While we use FTP clients for basic file transfers, SSH is our preferred method for troubleshooting complex errors, securely adjusting file permissions, and running command-line tools for site migrations.
It provides us with direct access to resolve issues swiftly, particularly during those rare instances when the WordPress admin area is inaccessible.
Now, let’s first explore how you can connect to your site’s server using SSH.
How to Connect to Your WordPress Site via SSH
The initial step is to verify whether SSH is installed on your site server.
Since SSH is a client-server technology, you can confirm its configuration by reaching out to your WordPress hosting provider, who can assist you. Alternatively, you can attempt to access the cPanel or hosting dashboard.
You should see a display similar to the image below:
Next, make sure to record the IP address, username, password, and port. This information is essential for connecting to your site via SSH from your computer.
Using SSH on a Mac or Linux Computer
If you are using a Mac or Linux operating system, you can easily connect to your site through the terminal application.
Please enter the following command in the terminal:
ssh username@server_ip_address
Simply replace the username and server_ip_address with the details provided by your hosting provider.
Using SSH on a Windows Computer
To connect to your site using SSH on a Windows machine, you will need to use a third-party application such as PuTTY.
After downloading and installing the application, fill in the ‘Host Name (or IP address)’ and ‘Port’ fields with the information you gathered earlier to connect to your site.
Once you have entered these details, click the ‘Open’ button. A terminal window will appear where you can enter your username and password to access your site.
Now, let’s explore some essential SSH commands that every WordPress user should be familiar with.
SSH Commands for Basic Navigation
Different SSH commands can help you navigate files and directories effectively. Here are some essential navigation commands you should be familiar with.
⚠️ Important Notice:SSH provides powerful access to your server, but with this power comes responsibility. A single incorrect command can lead to serious problems, such as deleting important files or disrupting your website.
We highly recommendalwayscreating a complete backup of your website before executing major commands. This is the best way to safeguard your site while using SSH.
1. pwd – Displays the Full Path to the Current Directory
The pwd command shows the complete path to the directory you are currently in. This is extremely helpful for moving between different files and folders:
pwd
Since there are no visual cues to indicate your current location on the server, you can use this command to navigate effectively.
2. ls – Lists Files and Folders in a Directory
To view the contents of a directory, you can simply use the ls command.
You can also include additional parameters to obtain more detailed information about the contents. For instance, just add -lfor comprehensive details or -ato display hidden files.
ls -1
3. cd – Change Directory
The cd command allows you to navigate between directories. You can access a subdirectory or switch to a completely different directory:
cd [directory]
In the example above, substitute [directory] with the actual name of the directory.
For instance, if you type thecd wp-content/themes command, it will take you to the themes directory within your WordPress setup.
Essential SSH Commands for Managing Files and Folders
Now, let’s explore some SSH commands for effectively managing files and folders on your WordPress website server.
4. mkdir – Create a New Directory
With the mkdir command, you can create a new directory in your current location. Just enter the following command along with the desired folder name:
mkdir [folder name]
For example, if you want to create a folder for stylesheets, the SSH command would be mkdir stylesheets.
To create a new directory within an existing subdirectory, use the mkdir command followed by the full path.
The syntax for this command is as follows:
mkdir /plugins/myplugin/stylesheets
5. rmdir – Remove an Empty Directory
⚠️Important Note:Exercise caution when using this command, as deleting a directory from the server is irreversible.
You can use the rmdir command to remove a directory from your website’s server. Simply enter the command followed by the directory name:
rmdir [folder name]
6. cp – Copy a File or Folder
The cp command allows you to copy a file or folder to a different location. Specify the name of the file or folder and the destination for the copy:
cp [file name] [destination]
Remember to include the file extension when specifying the file name, such as examplefile.txt or readme.html.
To create a copy of a file in the same directory, use the following command:
cp readme.html readme2.html
To copy a file to a different directory, use the following command:
cp /public_html/wp-content/readme.html /public_html/etc/
You can also utilize various options with the cp command, such as:
cp -rto copy all contents of a directorycp -ato archive all filescp -uto overwrite a file in the destination directory only if it has newer or different contentcp -nto avoid copying a file if it already existscp -ito display a warning before overwriting a filecp -fto replace or delete a file in the destination directory if a file with the same name already exists
7.mv – Moves a File or Directory
To relocate a file or directory to a new location, you can use the mv command.
Similar to the cp command, you need to specify the file name and the destination where you want to move the file:
mv [file name] [destination]
For instance, if you want to move an index.php file to the stylesheets directory, the command would be:
mv index.php stylesheets
8. grep – Search for a Specific Phrase
You can utilize the grep command to locate a specific phrase or string within a file. Keep in mind that this command is case-sensitive.
Here’s the syntax you would use:
grep '[search phrase]' [file name]
For instance, if you want to find the term ‘header’ in the info.txt file,
the command would be:
grep 'header' info.txt
Additionally, you can use the -i option to make the search case-insensitive.
9. find – Locate Files and Directories
If you need to find a specific file or directory, you can use the find command to search by file name, size, type, and more.
The syntax for the find command is as follows:
find [starting directory] [parameter] [search term]
In the above code, you can define the search criteria.
Here are some options you can use:
- (slash) – This allows you to search the entire system.
- . (dot) – This lets you search within the current working directory.
- ~This command searches within the home directory.
Additionally, the SSH command allows you to define parameters such as name, size, file type, and more.
-nameThis option searches for a specific file name.-userThis option searches for files associated with a specific user.-sizeThis option specifies the file size.-type -dThis option searches for directories.-type -fThis option searches for files.
Finally, you can enter the search term you want to find. For example, to locate a file named ‘task’ in the directory,
the SSH command would be:
find / -name "task"
Bonus Tip:Additional Useful SSH Commands
Now that you are familiar with basic SSH commands for navigating and managing files and folders on your site, here are some more commands you should be aware of.
10. zip – Compress a Folder
If you need to compress large files or folders, you can use thezipcommand. Simply include the name of the file or folder you wish to compress:
zip filename.zip foldername
You can also use various parameters with this command to choose whether to delete the original folder.
zip -r archive.zip directory– This command compresses a directory without removing it.zip -m archive.zip directory– This option compresses a directory and deletes the original, leaving only the compressed version.zip -d archive.zip filename– Use this command to remove a specific file from an existing zip archive.zip -u archive.zip filename– This updates a file in an existing zip archive, which is useful if you’ve modified the original file and want to keep the same zip file.
11. unzip – Extract Files from a Zip Archive
After zipping a directory, you will need to unzip it. To do this, simply enter the following command:unzip command:
unzip [archive.zip]
12. history – Display Recently Used Commands
The history command is helpful for recalling previously entered commands. You can specify a number to limit the results shown.
For instance, if you want to view the last 10 commands, use the following syntax:
history 10
13. tar – Create and Extract Compressed Archive Files
taris a widely used SSH command for extracting.tar.gzfiles. This format is commonly utilized by various third-party tools for file compression, serving as an alternative to zip files.
To archive a folder, you can use the following command. Just replace ‘archivename.tar.gz’ with your desired file name and ‘directory’ with the path to the directory:
tar -cvzf archivename.tar.gz directory
Once you’ve created the archive, you can extract the.tar.gzfile using this command:
tar -xvzf archivename.tar.gz directory
14. clear – Clear the Terminal Screen
You can utilize theclearcommand to clear all text from the terminal window:
clear
This command is helpful if you’ve made a mistake or wish to start anew.
15. du – Check File or Folder Size
If you want to determine the size of a file or folder on your WordPress server, you can use theducommand:
du -h [file or folder name]
The-hoption in the command displays the file size in a format that is easy to read.
For instance, if you want to check the size of the.htaccessfile.
Simply enter the following command:
du -h .htaccess
16. exit – Disconnect from the Remote Server
When you finish working on your WordPress site and wish to disconnect from the remote server, just type in the exit command:
exit
We recommend using this command every time you log out of your site. This ensures that no one else can access your server via SSH after you have completed your tasks.
Common Questions About SSH
Still have questions about how SSH operates or if it’s suitable for you? Here are some frequently asked questions by WordPress users.
What distinguishes SSH from FTP?
Both SSH and FTP allow you to manage files on your server, but SSH offers significantly more functionality. FTP is primarily used for uploading and downloading files.
With SSH, you gain complete command-line access. This allows you to execute scripts, manage databases, and carry out advanced tasks securely. Additionally, SSH connections are fully encrypted, providing enhanced security compared to standard FTP.
Is using SSH safe for my WordPress site?
Absolutely. SSH encrypts all data transmitted between your computer and the server, safeguarding your site and login information from potential interception.
Exercise caution when executing commands, as SSH provides direct access to your server. A minor error can lead to significant issues. It’s advisable to create a complete backup before undertaking any major changes.
Is SSH access included with all WordPress hosting plans?
Not necessarily. Most VPS, dedicated, and managed WordPress hosting plans typically include SSH access by default.
However, some basic shared hosting plans may not include SSH or might offer it as an additional feature. Always verify with your hosting provider.
What occurs if I enter a command incorrectly?
If it’s merely a typo or an unrecognized command, you’ll generally receive a harmless ‘command not found’ message.
The real danger lies in executing a valid command on the wrong file or in the incorrect directory, such as unintentionally deleting something crucial. To prevent this, always double-check your command and current directory using pwd before pressing enter.
🌟Important Reminder: If you ever find yourself locked out and unsure of the next steps, don’t worry. Our team of experts is ready to assist you in regaining access swiftly and securely. Check out CanadaCreate Premium Support Services for professional help when you need it most.
We trust this article has equipped you with essential SSH commands that are crucial for every WordPress user. Additionally, you might find our comprehensive list of common WordPress errors and their solutions helpful, along with our troubleshooting guide for WordPress.
If you enjoyed this article, consider subscribing to our YouTube Channel for insightful WordPress video tutorials. You can also connect with us on Twitter and Facebook.



