Knowledge Base

List of Basic SSH Commands

List of Basic SSH Commands

What Are SSH Commands?

SSH commands allow you to perform administrative tasks on your hosting server safely.
They are text-based instructions entered via a terminal or SSH client such as PuTTY, Terminal (macOS), or Linux Shell.

These commands let you:

  • Move and manage files remotely
  • Monitor resource usage (CPU, memory, bandwidth)
  • Restart services
  • Install software
  • Edit configuration files

 Note: Always be careful when running destructive commands (like rm or mv) — they may permanently delete or overwrite data.

Basic SSH Commands and Their Descriptions

Command

Description

Example

ls

Lists all files and directories in the current location.

ls -al (shows all files including hidden ones)

cd

Changes directory.

cd /home/user/public_html

pwd

Displays the current directory path.

—

mkdir

Creates a new directory.

mkdir backups

cp

Copies files or directories.

cp file.txt /home/user/docs/

mv

Moves or renames files.

mv oldname.txt newname.txt

rm

Deletes files or directories (use with caution).

rm -rf foldername/

cat

Displays the contents of a file.

cat index.html

more / less

Views files one page at a time.

more /etc/passwd

tail

Shows the last lines of a file, often used for logs.

tail -f /var/log/messages

du -sh *

Displays the disk usage of each file/folder in readable format.

—

df -h

Shows overall disk usage of mounted file systems.

—

top

Displays running processes and system resource usage.

Press Shift + P to sort by CPU.

ps aux

Lists all running processes.

ps aux --forest

kill PID

Terminates a running process.

kill -9 10550

netstat -an

Displays all active network connections.

—

scp

Transfers files securely between local and remote servers.

scp file.txt user@host:/path

grep

Searches text for matching patterns.

grep root /etc/passwd

tar -zxvf

Extracts .tar.gz archive files.

tar -zxvf backup.tar.gz

touch

Creates an empty file.

touch newfile.txt

vi / nano

Edits text files inside the terminal.

vi /etc/hosts

 

Tip: To quickly find large files, use:
du -sh * | sort -rh | head -20
This lists the top 20 largest directories/files.

How to Combine SSH Commands

You can chain or combine commands for efficiency:

Symbol

Usage

Example

`

` (pipe)

Sends the output of one command into another.

> 

Redirects output into a new file.

ls > filelist.txt

>> 

Appends output to an existing file.

echo "test" >> notes.txt

< 

Reads input from a file.

mysql < backup.sql

&&

Runs the next command only if the previous one succeeds.

cd /var/www && ls

 

Best Practices for SSH Security

To keep your SSH sessions and servers safe:

  1. Disable root login in /etc/ssh/sshd_config
  2. Use SSH keys instead of passwords
  3. Restrict SSH access to trusted IPs only
  4. Use two-factor authentication (2FA)
  5. Keep SSH software up to date
  6. Monitor login attempts via /var/log/secure or /var/log/auth.log

 Good security starts with good SSH habits. Always close sessions when finished and never share your private key.

 

Please rate this article to help us improve our Knowledge Base.

0 0