Skip to main content

Linux

Use this cheat sheet for everyday VPS and Linux server work: navigation, files, permissions, packages, processes, services, logs, ports, and SSH.

Show current folder:

pwd

List files:

ls
ls -la

Move into a folder:

cd /path/to/folder

Go back one folder:

cd ..

Go to home folder:

cd ~

Files And Folders

Create a folder:

mkdir folder-name

Create nested folders:

mkdir -p app/uploads

Create an empty file:

touch file.txt

Copy a file:

cp source.txt destination.txt

Copy a folder:

cp -r source-folder destination-folder

Move or rename:

mv old-name new-name

Remove a file:

rm file.txt

Remove a folder:

rm -r folder-name

Read Files

Print a file:

cat file.txt

View a file page by page:

less file.txt

Show the first lines:

head file.txt

Show the last lines:

tail file.txt

Follow a log file:

tail -f app.log

Edit Files

Open a file with Nano:

nano file.txt

Common Nano shortcuts:

Ctrl + O Save
Enter Confirm filename
Ctrl + X Exit
Ctrl + W Search

Permissions

Show permissions:

ls -la

Make a script executable:

chmod +x script.sh

Change owner:

chown user:user file.txt

Change owner recursively:

chown -R user:user folder-name

Packages

Update package list:

apt update

Upgrade installed packages:

apt upgrade -y

Install a package:

apt install package-name -y

Remove a package:

apt remove package-name -y

Search for a package:

apt search package-name

Processes

Show running processes:

ps aux

Find a process:

ps aux | grep app-name

Show live process usage:

top

Stop a process by PID:

kill PID

Force stop a process:

kill -9 PID

Services

Check service status:

systemctl status nginx

Start a service:

systemctl start nginx

Stop a service:

systemctl stop nginx

Restart a service:

systemctl restart nginx

Reload a service:

systemctl reload nginx

Enable service on boot:

systemctl enable nginx

Logs

View system logs for a service:

journalctl -u nginx

Follow service logs:

journalctl -u nginx -f

Show recent logs:

journalctl -u nginx -n 100

Network And Ports

Show IP address:

ip addr

Test a domain:

ping example.com

Check open listening ports:

ss -tulpn

Check if a local service responds:

curl http://127.0.0.1:8000/health

Check public URL:

curl https://api.yoursite.com/health

SSH

Connect to server:

ssh root@SERVER_IP

Connect with a key:

ssh -i ~/.ssh/key.pem root@SERVER_IP

Copy file to server:

scp file.txt root@SERVER_IP:/root/

Copy folder to server:

scp -r folder-name root@SERVER_IP:/root/

Disk Usage

Show disk space:

df -h

Show folder size:

du -sh folder-name

Find large folders:

du -h --max-depth=1 | sort -h

Common VPS Flow

For a deployed backend:

ssh root@SERVER_IP
cd /root/project/backend
git pull
source venv/bin/activate
systemctl restart nginx

If using Supervisor:

supervisorctl restart app-name

Key Ideas

  • SSH connects you to the server.
  • Apt installs system packages.
  • Systemctl manages services.
  • Journalctl reads service logs.
  • Permissions control who can read, write, and execute files.
  • Ports expose apps to local or public traffic.