Skip to content

Latest commit

 

History

History
410 lines (259 loc) · 3.93 KB

Linux-command.md

File metadata and controls

410 lines (259 loc) · 3.93 KB
# 🐧 Linux Command Cheat Sheet (Raspberry Pi / Home Server)

This document provides a practical reference of the most important Linux commands used in this project, with a focus on:

- service management (systemd)
- networking
- remote access (SSH / XRDP)
- Tailscale VPN
- system monitoring and troubleshooting

---

## ⚙️ Service Management (systemd)

### 🔍 Check service status

```bash
systemctl status <service>

Examples:

systemctl status xrdp
systemctl status tailscaled

▶️ Start / Stop / Restart services

sudo systemctl start <service>
sudo systemctl stop <service>
sudo systemctl restart <service>

🔄 Enable / Disable at boot

sudo systemctl enable <service>
sudo systemctl disable <service>

📋 List running services

systemctl list-units --type=service --state=running

📋 List enabled services

systemctl list-unit-files --state=enabled

🧹 Reset failed services

sudo systemctl reset-failed

🌐 Networking

📡 Show network interfaces

ip a

🛣️ Show routing table

ip route

🌍 Test connectivity

ping -c 3 8.8.8.8

🔎 Show open ports and listening services

sudo ss -tulnp

Filter examples:

sudo ss -tulnp | grep 3389
sudo ss -tulnp | grep 22

🌐 Get local IP address

hostname -I

🌍 Check public IP

curl ifconfig.me

🔐 SSH (Secure Shell)

Connect to a device

ssh user@192.168.x.x
ssh user@100.x.x.x

Copy files

scp file.txt user@host:/path

🖥️ XRDP (Remote Desktop)

Check XRDP status

systemctl status xrdp

Restart XRDP

sudo systemctl restart xrdp

Check RDP port (3389)

sudo ss -tulnp | grep 3389

🔐 Tailscale (VPN)

Check connection status

tailscale status

Get Tailscale IP

tailscale ip -4

Start Tailscale

sudo tailscale up

Stop Tailscale

sudo tailscale down

Restart service

sudo systemctl restart tailscaled

📦 Package Management (APT)

Update system

sudo apt update
sudo apt upgrade -y

Install package

sudo apt install <package> -y

Remove package

sudo apt remove <package>

Full cleanup

sudo apt autoremove -y

📊 System Monitoring

CPU / Processes

top
htop

Memory usage

free -h

Disk usage

df -h

System uptime

uptime

📂 Logs & Debugging

System logs

journalctl -xe

Service logs

journalctl -u xrdp
journalctl -u tailscaled

Boot logs

journalctl -b

🔍 Process Management

List processes

ps aux

Find process

ps aux | grep <name>

Kill process

kill -9 <PID>

🧹 System Cleanup & Checks

Check active VPN / network interfaces

ip link

Check for VPN-related services

systemctl list-units | grep -E "vpn|wg|tailscale"

Check installed VPN packages

dpkg -l | grep -E "wireguard|tailscale|openvpn"

🔥 Useful Debug Workflow

When something doesn't work:

  1. Check service:
systemctl status <service>
  1. Check ports:
sudo ss -tulnp
  1. Check logs:
journalctl -u <service>
  1. Check network:
ip a
ip route

💡 Pro Tips

  • Always verify services with systemctl status
  • Use ss -tulnp to debug networking issues
  • Logs (journalctl) are your best friend
  • Prefer Tailscale IP (100.x.x.x) for remote access
  • Avoid exposing services directly to the internet