Server Commands Reference

💻 Platform-Specific Commands

🖥️ Windows Server

Restart a Web Server

net stop cloudflared
net start cloudflared

net stop cloudflared && net start cloudflared
            

Open MySQL Workbench and Connect to Any One Database

(Then launch MySQL Workbench manually and connect to your database.)

Open in File Manager

Open terminal and navigate to:
F:\4Born-Server-setup
            

🐧 Linux Server (Ubuntu)

Restart a Web Server

sudo systemctl stop cloudflared
sudo systemctl start cloudflared

sudo systemctl restart cloudflared
            

Open MySQL and Connect to Database

mysql -u root -p
# Or connect to specific database:
mysql -u username -p database_name
            

Navigate to Project Directory

cd /home/4Born-Server-Setup
# Or open file manager:
nautilus /home/4Born-Server-Setup
            

PM2 Process Manager Commands

Note: PM2 commands are identical on both Windows and Linux systems. The following commands work on both platforms.

🚀 Most Important & Frequently Used Commands

pm2 list Check all running processes - your go-to command to see what's running
pm2 save Save current configuration - CRITICAL to persist your processes after changes
pm2 restart [id/name] Restart a process - most common command for applying changes
pm2 start app.js --name "App Name" Create and start a new PM2 instance with custom name
pm2 resurrect Recover all saved processes after system restart or PM2 restart
pm2 monit Open monitoring dashboard - essential for debugging and performance monitoring
pm2 logs [id/name] View real-time logs - crucial for debugging application issues
pm2 stop [id/name] Stop a process gracefully - use when you need to pause an application

📋 Process Listing & Information

pm2 ls Quick list of all running processes (shorthand)
pm2 list Detailed list showing process status, memory usage, and uptime
pm2 info [id/name] Show detailed information about a specific process including environment variables and restart count
pm2 -v Display PM2 version information

🔄 Process Control

pm2 start [id/name] Start a specific process or all processes with 'all'
pm2 stop [id/name] Stop a specific process gracefully or all processes
pm2 restart [id/name] Restart a process (stops and starts) - useful for applying changes
pm2 reload [id/name] Zero-downtime reload - starts new instance before stopping old one
pm2 delete [id/name] Remove a process from PM2 management completely

📊 Monitoring & Logs

pm2 monit Open real-time monitoring dashboard showing CPU, memory, and logs
pm2 logs Display logs from all processes in real-time
pm2 logs [id/name] Show logs for a specific process only
pm2 flush Clear all log files - useful for freeing up disk space

💾 Configuration & Persistence

pm2 save Save current process list to disk - essential for persistence across reboots
pm2 resurrect Restore previously saved processes after PM2 restart or system reboot
pm2 startup Configure PM2 to start automatically when system boots up
pm2 startup systemd Generate systemd service file for automatic startup on Linux systems
pm2 startup windows Configure PM2 for Windows startup (Windows only)
pm2 unstartup Remove PM2 from system startup - disable auto-start

⚡ System Management

pm2 kill Kill PM2 daemon and all managed processes - use with caution
pm2 --help Show comprehensive help with all available commands and options

💡 Pro Tips

  • Process ID vs Name: You can use either process ID (number) or app name to target specific processes
  • Zero-downtime: Use pm2 reload instead of pm2 restart for production deployments
  • Always save: Run pm2 save after making changes to persist them
  • Monitor first: Use pm2 monit to understand your application's resource usage
  • Platform Notes: PM2 startup commands differ between Windows (pm2 startup windows) and Linux (pm2 startup systemd)

🐧 Additional Linux System Commands

📁 File & Directory Operations

ls -la List all files and directories with detailed information
cd /home/4Born-Server-Setup Navigate to project directory
pwd Show current directory path
chmod +x filename Make file executable

🔧 System Services

sudo systemctl status service-name Check service status
sudo systemctl enable service-name Enable service to start on boot
sudo systemctl disable service-name Disable service from starting on boot

📊 System Monitoring

htop Interactive process viewer (install with: sudo apt install htop)
df -h Show disk space usage in human-readable format
free -h Display memory usage in human-readable format
ps aux | grep node Find all Node.js processes