If you know how to use the command line and SSH, you manage your website and server much quicker than you would using the front end admin area.
According to the Linux Information Project: “A command line is the space to the right of the command prompt on an all-text display mode on a computer monitor in which a user enters commands and data. It provides a means of communication between a user and a computer that is based solely on textual input and output.”
You can use it with the Secure Socket Shell Protocol, or Secure Shell Protocol (SSH) to log in, execute commands, and manage data securely between computers using an encrypted connection.
This also includes logging into your server to transfer, execute, and otherwise manage the files and folders on your website at lightning speeds.
Today, I’ll share how to use the command line and SSH to manage your website as well as more detail on what they are, and the requirements to use them.
What is the Command Line
To understand what the command line is, exactly, it’s essential to first know about the command prompt, and Command-Line Interface, what a command is as well as the apps you need to use them to manage your website, or network.
A Command-Line Interface (CLI) is a user interface (UI) that’s text based. It’s typically a program with a black, or white background. You type commands into it to manage files and folders on a computer, or server.
Windows has a CLI called Command Prompt and for Mac computers, there’s the Terminal.app. Both are pre-installed. You can use one of them, and there are also other options available such as PuTTY.
Here’s where things get a little confusing: The command prompt can also be used to describe the symbol or series of characters that appear in the CLI and asks – or prompts – the user to enter a command. It’s sometimes referred to as a “prompt.”
A command is an instruction that the user types into the CLI that they want executed. This can be creating and naming a file or folder, transferring files, moving them, editing them, and many other options.
A command line is the line or space that appears after the prompt where the user can type a command.
If that’s not confusing enough already, try this on for size: “Command Line” is often used to refer to a CLI, especially for Linux operating systems.
What is SSH
Secure Shell or Secure Socket Shell (SSH) is a protocol used to securely connect to an otherwise insecure computer, or server.
It uses cryptography to provide strong authentication methods to determine that a computer or server you’re trying to connect to is legitimate, and actually where you meant to connect.
It also uses encryption to secure the connection between your computer and the destination.
It’s a successor to Telnet, rlogin, and rsh. It securely replaces all of these other protocols which were prominently used in the 1990’s. It’s now best practise to use SSH over these other options.
You can enable SSH when you use the command line to ensure your connection is secure and your data is safe.
“SSH” is also used among web developers in casual conversations to refer to using the command line with SSH.
How to Use the Command Line: Basic Requirements
The command line is intended to be used with Unix-like distributions such as Linux. But, you can still use it on Windows if you install OpenSSH.
The April 2018 update for Windows 10 also automatically has OpenSSH installed and enabled so you don’t have to do anything else to use the Command Prompt to connect to your site’s server.
If you’re using a different version of Windows, you can also choose to use PuTTY, or you can use it instead of the updated Command Prompt since it has a user-friendly Graphical User Interface (GUI) that can help you use the command line more efficiently.
To access the Command Prompt, press CTRL and R on your keyboard, type “cmd” into the text field, (without quotation marks) and press the Enter key.
If you have a Mac, you can use the Terminal app that’s inherently available. You can find it in your Applications > Utilities folder, or you can search for it by name using the Launchpad app. Either way, it’s labelled as “Terminal.app.”
Other than these basic requirements, you also need to have SSH enabled on your server. Depending on your host, or hosting plan, you may not have SSH available such as for shared servers and hosting plans. SSH is typically made available on VPS, dedicated, managed, and some cloud servers.
If you’re unsure of whether you can use SSH to connect to your site’s server, check with your hosting provider. They can also guide you through enabling it since most hosts vary slightly, or a great deal when it comes to their control panels.
How to Use the Command Line: Other Requirements
Other than those basic requirements, there are other tools and options that are commonly used with the command line.
For example, it’s incredibly common to come across tutorial after tutorial that already assumes you have these pre-installed, or updated to the latest version. In most cases, most of these are already set up on your server, but you can ask your host if you’re unsure.
Here are a few common tools that you’ll often need:
- Advanced Packaging Tool (APT) – A, well, packaging tool for Debian and Ubuntu so you can install programs, scripts, extensions, plugins and apps like WP-CLI, Redis, an SSL certificate, and boundless other options.
- GNU WGET Utility – You can use this to install various programs similar to APT, but for Linux instead.
- VI Visual Text Editor – A text editor for the command line.
- VIM Text Editor – An advanced text editor for the command line. It can be used with the VI editor.
- YUM – It’s a utility used to manage and install packages.
Keep in mind that this is by no means a complete list, but it should give you a good idea of what to expect and look for when you learn how to use the command line and SSH.
How to Use the Command Line: What You Need to Connect
To use the command line, there are some key things you need to connect to your site’s server:
- IP address
- Port number
Typically, these can all can be found before, or after logging into your account with your hosting provider.
The username for servers can often be “root,” but this isn’t always the case so be sure to double check. The username and password typically is the same as your credentials to log into your web host account. This isn’t always the case so when in doubt, contact your host.
Commonly, port number 22 is used in most cases, but this also isn’t always the case. You can also check with your host to be sure of which port you should use.
In cPanel, you can find your IP address on the right-hand side after logging in.
How to Use the Command Line: Logging In
Once you have noted the credentials you need as listed above, you can go ahead and fire up Command Prompt, the Terminal app, or whatever CLI you want to use.
Next, type the command below, then press the enter or return key on your keyboard:
Be sure to replace “username” with your actual username, and “IP address” with your server’s IP address. You can also choose to use your domain name instead of your server’s IP address.
For example, your command should look similar to the example below:
Once that’s done, you’ll be prompted to enter your password. Type it in, then press the enter or return key again.
If you need to use a port number other than 22, use this command instead:
Similar to the above example, replace “username” and “IP address” in this example with your actual credentials. Also, replace “####” with the port number you want to use.
For example, your command will look similar to this:
Logging in with PuTTY
If you’re using PuTTY, the process of logging in is slightly different.
Once you have downloaded the SSH client, open it and in the configuration window, enter your IP address and port number into the corresponding fields. Be sure to also select the SSH option under Connection type if it’s not already selected.
Next, click the Open button.
A new window will launch with the command line. Type your username, then press enter or return on your keyboard.
Next, type your password. Then, press the enter or return key again.
How to Use the Command Line: Commands
Now that you’re logged in, you can start entering the commands you need to fulfill the tasks you want to accomplish.
For full lists of commands you can use, check out An A-Z List of the Linux Command Line, Useful Terminal Commands for Ubuntu or Debian, and Basic SSH (PuTTY) Commands.
Chances are you already have everything you need to get started, and now you know how to use the command line with SSH to manage your site and server files and folders.
Do you now know how to use the command line and SSH, or are there some questions that you still have? What type of CLI do you use, and which one do you prefer? Do you prefer using a GUI? Share your experience in the comments below.