Maintaining and updating a website can be accomplished through various methods, such as utilizing a user-friendly interface like a file manager or an FTP program. However, SSH access can significantly enhance productivity by providing a more efficient and agile way to perform tasks on your site.


In this article, we will explore commonly used SSH commands for managing a website. By the end, you will have the ability to navigate server directories, as well as create, modify, and relocate files and folders. Additionally, we will cover the process of backing up site files. All of these tasks will be executed via the command line interface. Keep progressing and acquiring knowledge!
Prior to commencing
Before we discuss SSH commands, let’s review some fundamental concepts. SSH stands for Secure Shell and is a protocol that enables server access on the internet with the right credentials. For further information, we suggest reading the article “What is SSH and how to use it to access your hosting.”
To implement the steps suggested in the article, we will require just two items.
- Login and hosting password (or a public-private key pair)
- An SSH customer
If you are using Linux or Mac, you do not have to install anything because the default terminal supports SSH commands. However, if you are using Windows, you will need to install an SSH client such as Putty or Git for Windows terminal.
With the access information ready, begin by opening the terminal and connecting to the server via the SSH command.
Replace the user input with your username and the mysite address. Replace .com.br with your server website’s domain or IP. If it’s your first time accessing, a prompt will show up on the screen asking you to confirm your intent to continue. Simply type “yes” and press Enter to proceed.
The system will prompt for the server access password. Simply enter it and press Enter to submit the details. If successful, the terminal pointer will switch to display your username and server name.
In the example provided, “user” refers to the user name, “server name” is the connected server, [~] denotes its location, ~ signifies the user directory (e.g. /root/user/), and ($) represents the prompt symbol. Commands should be input after the $ symbol.
If you’ve managed to connect to the server, it indicates that we are prepared to proceed.
Navigate through directories and view content by using SSH commands.
The terminal can be challenging for users accustomed to graphical interfaces for file management, like those found on Windows and Mac systems. Commands are required in the terminal to view files.
I’m sorry, but it seems like there was an error in your request. Could you please provide the text that you would like me to paraphrase?
The command “ls” lists all items in a directory. Adding the “-a” parameter includes hidden files starting with a point. The “-l” flag provides details like file owner, size, and modification date. Multiple flags can be used together for more specific results.
The outcome will be similar to:


Current working directory
Using this command is equivalent to inquiring about one’s current location in the terminal. PWD stands for Print Working Directory, indicating the action of printing the current working directory. Upon executing this command, the path of the current location is shown on the screen.

chsyys/iStock

In the example provided, the user base folder path (/home/tshs2016) is shown as the tilde (~) in the default terminal display.
I’m sorry, but it seems like you haven’t provided any text for me to paraphrase. Could you please provide the text you’d like me to paraphrase?
This command, derived from “change directory” in Portuguese, is used to switch from the current directory to another. You can enter a directory by specifying its name after the command. To move up a level, use two points (..) after the command. Full paths are also valid for changing directories. Examples of using the cd command are provided.
Copying and transferring files
Now that we know how to access and move around server directories and files, we will learn essential SSH commands for copying, moving, and renaming files.
Sorry, I couldn’t paraphrase the text as it seems to be incomplete. Please provide more context or a complete sentence for paraphrasing.
The abbreviation “cp” stands for copy, indicating the action of duplicating a file or directory while preserving the original. This command is practical for creating backups or duplicates. To use it, specify the file to copy and its new name. Additionally, you can save the copy in a different directory by providing the path along with the new name. Examples are provided for clarification.
I’m sorry, but it looks like you didn’t provide any text for paraphrasing. Could you please provide the text you’d like me to paraphrase?
The command for moving files and directories is called “mv,” short for “moves” in English. Unlike the cp command, it relocates the file from its original location to a new one specified by you. Similar to cp, you need to specify the source file and the destination for moving it.
Use the mv command to change the names of files and directories.
The mv command can be used to rename a file or directory by simply changing the file name without specifying a directory.
Viewing and modifying file content
By using an SSH command terminal, you can carry out various file and directory edits. The terminal is more robust than graphical tools and is also more lightweight. It is important to exercise caution when handling files and operations through the terminal. With practice and training, one can become proficient with the terminal, leading to increased productivity over time.
We will learn various SSH commands to view and edit files using the terminal.
Feline
This command displays the contents of files when the file name is provided after it.
The outcome will be:


I witnessed
The vi command originates from visual editor and enables direct file editing in the terminal. This robust text editor may seem daunting to new users due to its less intuitive operation.
To access a file using vi, simply employ the command:
When you open the file, you access the navigation mode to save changes and find code sections. To make direct edits, switch to editing mode by pressing the i key. Exit editing mode by pressing ESC and save changes with :w. To exit the file, use :q in the terminal.
For a list of fundamental vi commands, visit this page.
Backing up, compressing, and decompressing files and folders
Performing tasks on the server using the terminal can be efficient and convenient for individuals familiar with SSH commands. The commands outlined below are particularly valuable for creating website backups, as they are mainly used for compressing files. Creating a single compressed file that includes entire directories greatly streamlines the process of transferring them to another location.
paraphrase: zip code
This function compresses a file or folder. To compress a folder with all its subfolders, it is essential to utilize the -r flag, indicating that the command should operate recursively through all subdirectories. For instance:
To extract a compressed file using zip, you can utilize the unzip command. For instance, to extract the file generated in the previous example, the command would be:
The unzip command may not be included in all Linux distributions by default. If that’s the case, you can easily install it by following the package installation procedure for your specific distribution.
tar
This command is commonly used in the Linux world for grouping files without compressing them. It is popular due to its various options, and by adding specific parameters, you can monitor the compression process in real-time. An example of a common use of the tar command is shown below:
The parameters in the example indicate different actions: creating the file, displaying actions in the terminal as they occur, compressing the file using the GNU zip method, and setting the file name.
Another commonly used parameter in tar for unpacking files is -x, which stands for extract.
To extract the file we previously made in the example, the command would be used.
Backing up data to a different server using SSH commands
The zip and tar commands create a single file that should be transferred to another location for backup purposes, ensuring that the backup remains secure in case of any issues on the production server.
Files can be transferred between servers using various methods, such as using commands like rsync and scp through the terminal. More information on how to use these commands can be found in a new article. 😉
Conclusion
In this article, we learn essential instructions for controlling a website through the SSH protocol. It’s worth noting that the terminal offers a wide range of capabilities beyond what is covered here. For a comprehensive list of all bash commands and their corresponding flags, visit www.ss64.com/bash/.
Do you want to include a command that wasn’t mentioned in the article? Feel free to ask questions and start a conversation by leaving a comment!
The publication date was 18/10/2017 and was updated on 30/12/2020.
Tutorials are labeled as Tags.