What this is
This article is a beginner-friendly “for dummies” reference of the most common Linux commands used on a VPS. It is designed for people who are starting and want a practical cheat sheet with explanations.
What it is for
- Move around the server (folders and paths)
- Create, view, edit, copy, and delete files
- Understand permissions (why “Permission denied” happens)
- Check disk space, memory, CPU usage
- Start/stop services and verify health
- Get basic network information and troubleshoot
Prerequisites
- You are connected to your VPS via SSH (PowerShell/Terminal)
- Basic comfort with copy/paste
- If you are not
root, you may needsudofor some commands
Important beginner notes (read first)
- Linux is case-sensitive:
File.txtandfile.txtare different. - Be careful with delete commands (
rm): there is no “Recycle Bin”. - When you see
Permission denied, it usually means you needsudoor correct ownership/permissions. - When in doubt, run a “safe read” command first (like
lsorcat) before changing anything.
Step-by-step: the essential commands
1) Where am I? (current folder)
Command:
pwd
What it does: Prints your current directory.
Why it is needed: Helps you avoid editing the wrong location.
Expected output: A path like /root or /home/ubuntu.
2) List files and folders
Command:
ls
What it does: Lists files in the current directory.
Expected output: Names of files/folders.
Most useful variant:
ls -la
What it does: Shows hidden files (-a) and detailed info (-l).
Expected output: Lines with permissions, owner, size, date, file name.
Useful note: If you see files beginning with . they are hidden configuration files.
3) Change directory (move into a folder)
Command:
cd /path/to/folder
Example:
cd /var/www
What it does: Moves you into another directory.
Expected output: Nothing (success is silent). Check with pwd.
Go back:
cd ..
What it does: Goes one directory up.
Go home:
cd ~
4) Create folders and files
Create a folder
mkdir myfolder
What it does: Creates a directory.
Expected output: Nothing (silent on success).
Create an empty file
touch notes.txt
What it does: Creates the file if it does not exist (or updates its timestamp).
5) View file contents (safe reading)
Quick view
cat file.txt
What it does: Prints file content to the terminal.
Warning: For very large files it will “spam” your screen.
Paginated view (recommended for logs)
less /var/log/syslog
What it does: Opens an interactive viewer (scroll with arrows; press q to quit).
Show last lines of a file (very common)
tail -n 50 /var/log/syslog
What it does: Shows the last 50 lines.
Follow a log live
tail -f /var/log/syslog
What it does: Continues showing new lines as they appear.
How to stop: Press Ctrl + C.
6) Edit files (beginner-friendly)
Option A (simple editor):
nano /etc/hosts
What it does: Opens a terminal text editor.
How to save: Press Ctrl + O then Enter.
How to exit: Press Ctrl + X.
Important note: Editing system files often requires sudo:
sudo nano /etc/hosts
7) Copy, move, and delete
Copy a file
cp source.txt destination.txt
What it does: Copies a file.
Copy a folder (recursive)
cp -r folderA folderB
Warning: Be careful with large folders (it can take time and disk space).
Move / rename
mv oldname.txt newname.txt
Delete a file (dangerous)
rm file.txt
Warning: This permanently deletes the file.
Delete a folder (very dangerous)
rm -rf foldername
What it does: Removes a folder and everything inside without asking.
Beginner rule: Double-check with ls -la before using rm -rf.
8) Search: find text inside files
grep -R "ERROR" /var/log
What it does: Searches recursively for the text ERROR in files under /var/log.
Expected output: Matching lines with filenames.
9) Understand permissions
Check permissions and owner
ls -la
What to look for: The left side like -rw-r--r-- and the owner/group columns.
Change permissions (example)
chmod 600 ~/.ssh/authorized_keys
What it does: Sets file permissions to owner read/write only.
Why it matters: SSH will reject keys if permissions are too open.
Change owner (example)
sudo chown -R username:username /var/www/my-site
What it does: Changes ownership of a directory (recursive).
Warning: Changing ownership incorrectly can break services. Use carefully.
10) Check disk and memory quickly
Disk usage
df -h
Expected output: Filesystems and how full they are. Watch / (root) usage.
Folder sizes (quick)
du -sh *
What it does: Shows the size of each item in the current folder.
Memory usage
free -h
Expected output: Total, used, and available memory.
11) Processes: see what is using CPU/RAM
top
What it does: Shows live process activity.
How to exit: Press q.
Tip: If installed, htop is easier to read:
htop
12) Services: start/stop and check status
sudo systemctl status ssh
sudo systemctl status nginx
sudo systemctl status apache2
What it does: Shows whether each service is running.
Expected output: A line like Active: active (running).
Final verification (after you practice)
- Run
pwdandls -lain a couple of folders and confirm you understand paths. - Create a test folder with
mkdirand a test file withtouch. - Open a file with
nano, write a line, save, and view it withcat. - Check disk space with
df -hand memory withfree -h.
Conclusion
These commands are the foundation of working on a VPS. Once you are comfortable with them, tasks like installing a web server, enabling a firewall, or troubleshooting logs become much easier and safer.