Secure Shell (SSH) provides a secure and encrypted way to access and manage remote servers. One of the most common tasks that system administrators and developers perform over SSH is creating and editing files. This article will guide you through the basic steps of file management over SSH using built-in command line editors.
Before you can create or edit a file, you must establish an SSH connection:
username: Your SSH user (e.g. root or admin).
your-server-ip: The IP address of your remote server.
If you are using your own port, add -p port_number:
To create a new file, you can use one of several commands:
touch
This creates an empty file called myfile.txt in the current directory.
This creates a file and adds a line of text.
You can edit files with command line text editors. Here are the most common options:
Easy to use, with on-screen commands.
Use Ctrl O to save, Ctrl X to exit.
Press i
to enter insert mode.
Enter your content.
Press Esc
, then type :wq
to save and exit.
To display or append content:
After creating/editing, you may want to change the permissions:
Or change the ownership:
Managing files via SSH is an essential part of remote server management. Whether you’re setting up configuration files or logging system data, tools like nano
, vi
and touch
make it easy to get the job done. Once you have mastered these basics, you can work efficiently on any Linux-based system via SSH.