The most important SSH commands every VPS owner should know are those for navigation, file management, and system monitoring: ls, cd, cp, mv, rm, top, df, and free. Master these first, then add package management and service control commands for full control of your server.
What Is SSH and Why Do You Need It?
SSH (Secure Shell) is the standard protocol for securely connecting to a remote server over an unsecured network. When you rent a VPS (Virtual Private Server), you get a machine in a data center that you control entirely through the command line. SSH encrypts all traffic between your local computer and the server, so passwords, commands, and data cannot be intercepted easily.
You connect using a terminal program (like Terminal on macOS/Linux or PuTTY on Windows) with the command:
ssh username@server_ip_address
Once connected, you see a prompt like root@vps:~# or user@vps:~$. Everything you type is executed on the remote machine, not on your local computer.
Essential Navigation and File Commands
Before you can manage anything, you need to move around the file system and inspect files. These commands work on almost every Linux distribution (the most common OS for VPS).
pwd– prints the current directory path.ls– lists files and directories. Add-lato see hidden files and detailed permissions.cd /path/to/dir– changes directory. Usecd ..to go up one level,cd ~to go home.cp source dest– copies a file or directory (add-rfor directories).mv source dest– moves or renames a file/directory.rm file– deletes a file. Userm -r dirfor directories. Be careful: there is no trash bin.mkdir dirname– creates a new directory.touch file– creates an empty file or updates its timestamp.cat file– prints file contents. For long files, useless fileto scroll.nano fileorvim file– edit files directly in the terminal. Nano is easier for beginners.
These commands form the backbone of daily VPS work. For example, to move a website folder:
mv /var/www/oldsite /var/www/newsite
System Monitoring Commands
A VPS owner must know what the server is doing. These commands show real-time resource usage and help diagnose problems.
toporhtop– shows running processes, CPU and memory usage.htopis more user-friendly but must be installed first.df -h– shows disk space usage on all mounted filesystems in human-readable format.free -m– shows memory (RAM) usage in megabytes.uptime– shows how long the server has been running and the load average.ps aux– lists all running processes with details. Combine withgrepto find a specific one:ps aux | grep nginx.journalctl– on systemd-based systems, shows system logs. Usejournalctl -u service_nameto see logs for a specific service.
If your website is slow, run top first. If CPU is at 100%, find the process with ps and investigate.
Package Management Commands
Installing and updating software is a core VPS task. The commands depend on the Linux distribution:
- Debian/Ubuntu (apt):
apt update(refresh package lists),apt upgrade(upgrade all packages),apt install package_name,apt remove package_name. - CentOS/RHEL (yum or dnf):
yum updateordnf update,yum install package_name,yum remove package_name. - Alpine (apk):
apk update,apk add package_name,apk del package_name.
Always run apt update before installing new software to get the latest versions. For security, run apt upgrade regularly to patch vulnerabilities.
Service and Process Management
Most VPS software runs as a service (like web servers, databases, SSH itself). Modern distributions use systemctl to control services.
systemctl start service_name– starts a service.systemctl stop service_name– stops it.systemctl restart service_name– restarts (useful after config changes).systemctl status service_name– shows if it is running and recent logs.systemctl enable service_name– makes it start automatically at boot.systemctl disable service_name– disables auto-start.
For example, after editing an Nginx config, run systemctl restart nginx. To check if MySQL is running, use systemctl status mysql.
File Transfer and Permissions
You often need to copy files between your local machine and the VPS. Use scp (secure copy) or rsync for larger transfers.
- Upload a file:
scp /local/path/file.txt user@server:/remote/path/ - Download a file:
scp user@server:/remote/path/file.txt /local/path/ - Sync a directory (better for many files):
rsync -av /local/dir/ user@server:/remote/dir/
File permissions are critical for security. Use chmod to change them and chown to change ownership. For example, to make a script executable:
chmod +x script.sh
To give the web server user ownership of a folder:
chown -R www-data:www-data /var/www/html
Common Problems and How to Fix Them
Even experienced owners hit issues. Here are common ones and quick fixes.
- “Permission denied� when using sudo: Make sure your user is in the sudo group. On Ubuntu, add with
usermod -aG sudo username. - SSH connection refused: Check if SSH service is running with
systemctl status sshd. Also ensure the firewall allows port 22 (default). - Disk full: Use
df -hto see usage. Find large files withdu -sh *inside directories. Delete unnecessary logs or old backups. - Out of memory (OOM): Use
free -mto check. Stop unused services or increase swap space (but be careful). - Forgot root password: Most VPS providers offer a recovery console or password reset from their control panel. You can also boot into single-user mode if you have physical access via KVM.
Frequently Asked Questions
How do I change my SSH port for security?
Edit the SSH config file /etc/ssh/sshd_config and change the line #Port 22 to Port 2222 (or any port above 1024). Then restart SSH with systemctl restart sshd. Always ensure your firewall allows the new port before disconnecting, or you may lock yourself out.
What is the difference between sudo and root?
Root is the superuser account with unrestricted access. sudo allows a normal user to run specific commands as root, logging the action. It is safer because you don’t always operate as root, and you can limit which users have sudo privileges.
How do I keep my VPS secure?
Use SSH keys instead of passwords, disable root login over SSH (set PermitRootLogin no in sshd_config), keep the system updated, configure a firewall (like UFW or firewalld), and use fail2ban to block repeated login attempts.
Why is my server slow even with low CPU?
Check memory with free -m – if swap is heavily used, the server is thrashing. Also check disk I/O with iostat (if installed) and network traffic with iftop. Sometimes the bottleneck is the VPS provider’s disk or network limits.
Can I use SSH on Windows without installing extra software?
Yes, since Windows 10, the built-in OpenSSH client is available. Open PowerShell or Command Prompt and type ssh user@server. For older Windows, use PuTTY.
How do I see the last 100 lines of a log file?
Use tail -100 /var/log/syslog (or the relevant log file). To follow new lines as they are written, use tail -f /var/log/syslog.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Mac Start Up Automatically After Power Failure?
- Expose Self-Hosted Service Securely Without Cloudflare Tunnel
- Nano Delivery for Functional Foods: What It Can and Can’t Do4.00
- Disable Apple Watch Turn-by-Turn Vibration While Driving
- Convert Play FLAC in iTunes: Full Guide
- Soda Foundation Charter: What It Means