Open a file with nano filename.php, make your edit, then press Ctrl+O to save and Ctrl+X to exit. That covers nano, the easier of the two editors you'll run into over SSH. If you land in vim instead (some systems alias vi to it, or a script opens it for you), the fix for "I'm stuck and can't type" is Esc then :q! and Enter to quit without saving.
Both are command-line text editors for making quick changes to files on your server without downloading them first. Useful for a one-line config tweak, a quick look at an error log, or fixing a typo in wp-config.php without opening an FTP client.
nano: the one to use
nano is available on effectively every Linux server, including Flashcloud's. Open any file with:
nano path/to/file.txt
You're in a normal text buffer immediately, no modes to think about. Arrow keys move the cursor, typing inserts text, backspace deletes. The bottom two rows show the available commands with ^ standing in for Ctrl:
Ctrl+O("Write Out") saves the file. Nano will ask you to confirm the filename, press Enter to accept.Ctrl+Xexits. If you have unsaved changes it asks whether to save them first.Ctrl+Kcuts the current line,Ctrl+Upastes it back.Ctrl+Wsearches for text in the file.Ctrl+Gopens the help screen if you forget any of this mid-edit.
That's most of what you'll ever need. Save, exit, done.
Why you might see vim instead
Some minimal server images ship without nano, or a package's default editor points at vi/vim. Vim is a modal editor: it starts in "normal mode" where typed characters are commands, not text, which is exactly why people get stuck. Pressing i to type a word and then trying to save with familiar keyboard shortcuts doesn't work the way it does in nano.
The keys that get you unstuck:
ienters insert mode, now you can type normally.Escleaves insert mode and returns to normal mode.:wqthen Enter, from normal mode, saves and quits.:q!then Enter, from normal mode, quits without saving. Use this if you've made a mess and want out.
If you only remember one thing about vim, remember Esc then :q!. It's the universal escape hatch.
If nano isn't installed and you don't want to fight vim, most distributions let you install it with your package manager (for example apt install nano on Debian/Ubuntu, or yum install nano on CentOS-based systems), assuming you have permission to install packages on that server.
Where you'll actually use this
On Flashcloud shared and WordPress hosting, SSH access is scoped to your account, so you're editing your own site's files. Connection setup is similar to your FTP and SFTP account.
On a VPS, you have root access, so you can edit anything on the system, including files owned by other users or system-level configs like nginx or PHP settings. That's more power and more risk: a typo in a system config can take a service down until you fix it or restore from a snapshot. Always double-check the path before you save, and consider copying a file before editing it if you're not fully sure of the change:
cp nginx.conf nginx.conf.bak
A couple of habits worth keeping
- Know before you open a file whether you're on shared hosting (scoped to your account) or a VPS (root, so mistakes can affect the whole server).
- For config files you don't edit often, make a backup copy first. It's one command and it saves you from reconstructing a file from memory.
- If a file looks like garbled text or binary data when you open it, don't save changes, exit and check you've got the right file.