Commands I've learned
A working reference of 183 terminal commands gathered while shipping real projects — git, Docker, nginx, SSH, deployment and more. Search it, filter it, copy it.
183 commands
crontabSchedule automated tasks
crontab -e # Edit cron jobs crontab -l # List cron jobs 0 2 * * * /usr/local/bin/backup.sh
tarCreate and extract tar archives
tar -czf backup.tar.gz /var/www # Create compressed backup tar -xzf backup.tar.gz # Extract backup
apt installInstall packages using apt
sudo apt install -y nginx curl git
apt updateUpdate package repository information
sudo apt update # Update package lists
apt upgradeUpgrade installed packages
sudo apt upgrade -y # Upgrade all packages
cdChange directory
cd /var/www # Absolute path cd .. # Parent directory
chmodChange file permissions
chmod +x script.sh # Make executable chmod 644 file.txt # Set specific permissions
chownChange file ownership
sudo chown user:group file.txt # Change owner and group
lsList directory contents
ls -la # Detailed list with hidden files
mkdirCreate directories
mkdir -p /var/www/app # Create with parent directories
Chrome cache clearClear browser cache and site data on macOS
Cmd + Shift + Delete # Chrome cache clear shortcut chrome://settings/content/all # Site data management
Hard refreshForce browser to reload ignoring cache
Cmd + Shift + R # macOS hard refresh Ctrl + Shift + R # Windows/Linux hard refresh
Safari cache clearClear Safari cache on macOS
Cmd + Option + E # Clear Safari cache Safari → Develop → Empty Caches
mongoConnect to MongoDB shell
mongo mongodb://localhost:27017/myapp
mysqldump -u username -p database > backup.sqlCreate MySQL database backup
mysqldump -u root -p myapp > backup.sql
pg_dump database > backup.sqlCreate PostgreSQL database backup
pg_dump myapp > backup.sql
psql -U username -d databaseConnect to PostgreSQL database
psql -U postgres -d myapp
redis-cliConnect to Redis server
redis-cli
./deploy.shRun automated deployment script
./deploy.sh # Execute deployment script with progress indicators
rsync -avz --progress --exclude 'node_modules' --exclude '.next' . forexuser@217.154.33.169:/var/www/fx-platform/Sync project files to VPS excluding build artifacts
rsync -avz --progress --exclude 'node_modules' --exclude '.next' . forexuser@217.154.33.169:/var/www/fx-platform/
scp -P 2222 file.txt forexuser@217.154.33.169:/path/to/destinationCopy single file to VPS via SCP
scp -P 2222 Acuity-Final.mq5 forexuser@217.154.33.169:~/
SSH VPS connectionConnect to IONOS VPS with custom port
ssh -p 2222 forexuser@217.154.33.169 # Connect to DevHakim VPS
VPS deployment pipelineComplete deployment process for VPS
cd /var/www/devhakim && git pull && npm install && npm run build && pm2 restart devhakim
docker --versionCheck Docker version
docker --version
docker buildBuild Docker image from Dockerfile
docker build -t myapp:latest . # Build image with tag
docker build -t image-name .Build Docker image from Dockerfile
docker build -t my-app .
docker exec -it container-id bashExecute interactive bash in running container
docker exec -it abc123def456 bash
docker logsView container logs
docker logs container-name # View logs docker logs -f container-name # Follow logs
docker logs container-idView container logs
docker logs abc123def456
docker psList running containers
docker ps # Running containers docker ps -a # All containers
docker runRun container from image
docker run -p 3000:3000 myapp # Run with port mapping
docker run -p 3000:3000 image-nameRun container with port mapping
docker run -p 3000:3000 my-app
docker run hello-worldRun a test container to verify Docker installation
docker run hello-world
docker stop container-idStop running container
docker stop abc123def456
docker system prune -aRemove all unused containers, images, and networks
docker system prune -a
docker-compose upStart services defined in docker-compose.yml
docker-compose up -d # Start in detached mode
docker-compose up -dStart services defined in docker-compose.yml in background
docker-compose up -d
git addStage changes for commit
git add . # Stage all changes git add file.txt # Stage specific file
git add .Stage all changes for commit
git add .
git branchList, create, or delete branches
git branch feature/new-login # Create branch git branch -d old-branch # Delete branch
git checkoutSwitch branches or restore files
git checkout feature/new-login # Switch branch git checkout -- file.txt # Restore file
git checkout -b branch-nameCreate and switch to new branch
git checkout -b feature/user-profile
git cloneClone a repository from remote URL
git clone https://github.com/username/repo.git
git clone <repository-url>Clone a remote repository to local machine
git clone https://github.com/user/repo.git
git commitCommit staged changes
git commit -m "Add user authentication feature"
git commit -m "message"Commit staged changes with a message
git commit -m "Add user authentication feature"
git initInitialize a new Git repository
git init # Creates .git directory in current folder
git logShow commit history
git log --oneline --graph --all -20
git merge branch-nameMerge specified branch into current branch
git merge feature/user-authentication
git pullFetch and merge remote changes
git pull origin main # Pull latest changes from main
git pull origin mainPull latest changes from remote repository
git pull origin main
git pushPush commits to remote repository
git push origin main # Push to main branch
git push origin mainPush commits to remote repository
git push origin main
git reset --hard HEAD~1Reset to previous commit and discard changes
git reset --hard HEAD~1
git stashTemporarily save uncommitted changes
git stash save "work in progress"
git statusShow the working directory status
git status # Shows modified, staged, and untracked files
df -hShow disk space usage
df -h # Disk usage in human readable format
free -hShow memory usage in human readable format
free -h # Memory usage with MB/GB units
htopInteractive process viewer
htop # Better than top, interactive UI
iotopMonitor disk I/O usage
sudo iotop # Real-time disk I/O monitoring
kill PIDKill process by process ID
kill 1234
nethogsMonitor network usage per process
sudo nethogs # Network usage by process
tail -f /var/log/nginx/error.logFollow Nginx error logs in real-time
tail -f /var/log/nginx/error.log
uptimeShow system uptime and load
uptime # System uptime and load average
whoamiDisplay current username
whoami
xset qQuery X server settings and verify display connection
DISPLAY=:1 xset q
sudo fuser -k 3001/tcpKill process using port 3001
sudo fuser -k 3001/tcp
sudo lsof -i :3001Check what's using port 3001
sudo lsof -i :3001
sudo ss -tlnp | grep :5000Check what process is using port 5000
sudo ss -tlnp | grep :5000
curlTest HTTP endpoints
curl http://localhost:3001 # Test API curl -I https://domain.com # Headers only
curl -kTest HTTPS endpoints bypassing SSL verification
curl -k -I https://devhakim.com # Test HTTPS with insecure flag
curl redirect testTest HTTP to HTTPS redirects
curl -I http://devhakim.com # Check if HTTP redirects to HTTPS
lsof -iList processes using network ports
lsof -i :3001 # Check what's using port 3001 lsof -i tcp # All TCP connections
netstat -tlnpDisplay network connections
sudo netstat -tlnp | grep :3002
nslookupLook up DNS information
nslookup domain.com # Check DNS resolution
ss -tlnpShow listening ports and processes
sudo ss -tlnp | grep :80 # Check port 80 sudo ss -tlnp | grep -E "3001|3002|5000"
nginx -s reloadSend reload signal to Nginx master process
sudo nginx -s reload
nginx -tTest nginx configuration
sudo nginx -t # Test configuration syntax
systemctl reload nginxReload Nginx configuration without stopping
sudo systemctl reload nginx
systemctl restart nginxRestart nginx service
sudo systemctl restart nginx
systemctl status nginxCheck nginx service status
sudo systemctl status nginx
tail -f /var/log/nginx/access.logFollow Nginx access logs in real-time
tail -f /var/log/nginx/access.log
npm auditCheck for security vulnerabilities
npm audit # Show vulnerabilities npm audit fix # Auto-fix issues
npm cache clean --forceClear npm cache to fix installation issues
npm cache clean --force
npm initInitialize a new npm project
npm init -y # Skip questions and use defaults
npm installInstall dependencies from package.json
npm install # Install all dependencies npm install express # Install specific package
npm install --save-dev package-nameInstall package as development dependency
npm install --save-dev nodemon
npm install package-nameInstall a specific package
npm install express
npm listList installed packages
npm list --depth=0 # Show top-level packages only
npm runRun scripts defined in package.json
npm run dev # Start development server npm run build # Build for production
npm run script-nameRun npm script defined in package.json
npm run dev
npm updateUpdate packages to latest versions
npm update # Update all packages npm update express # Update specific package
npx commandExecute package without installing globally
npx create-react-app my-app
npx create-next-appCreate new Next.js application
npx create-next-app@latest my-app --typescript --tailwind
pm2 deleteDelete PM2 applications
pm2 delete all # Delete all apps pm2 delete api # Delete specific app
pm2 logsView PM2 application logs
pm2 logs --lines 50 # Last 50 lines pm2 logs api --lines 20 # Specific app
pm2 logs --lines 50View PM2 logs with 50 lines
pm2 logs --lines 50
pm2 restartRestart PM2 applications
pm2 restart all # Restart all apps pm2 restart api # Restart specific app
pm2 saveSave PM2 process list
pm2 save # Save current process list
pm2 save && pm2 startupConfigure PM2 autostart on boot
pm2 save && pm2 startup
pm2 startStart application with PM2
pm2 start server.js --name "api" # Start with custom name
pm2 start server.js --name "forexacuity-api"Start API server with PM2
pm2 start server.js --name "forexacuity-api"
pm2 startupGenerate startup script for PM2
pm2 startup # Auto-start PM2 on system boot
pm2 statusShow all PM2 processes
pm2 status # List all running processes
pm2 stopStop PM2 applications
pm2 stop all # Stop all apps pm2 stop api # Stop specific app
pip freezeList installed packages with versions
pip freeze > requirements.txt # Export to file
pip freeze > requirements.txtExport installed packages to requirements file
pip freeze > requirements.txt
pip installInstall Python packages
pip install fastapi # Install specific package pip install -r requirements.txt # Install from file
pip install package-nameInstall Python package using pip
pip install requests
pytestRun Python tests with pytest
pytest tests/
python --versionCheck Python version
python --version
python -c "import sys; print(sys.path)"Check Python path configuration
python -c "import sys; print(sys.path)"
python -m http.server 8000Start simple HTTP server
python -m http.server 8000
python -m pip install --upgrade pipUpgrade pip to latest version
python -m pip install --upgrade pip
python -m uvicornRun FastAPI server with uvicorn
python -m uvicorn main:app --reload --port 5000
python -m venvCreate Python virtual environment
python -m venv venv && source venv/bin/activate
python -m venv venvCreate virtual environment
python -m venv venv
python script.pyRun Python script
python app.py
source venv/bin/activateActivate virtual environment
source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows
certbot --nginx -d forexacuity.co.uk -d www.forexacuity.co.ukInstall SSL certificates with Certbot
sudo certbot --nginx -d forexacuity.co.uk -d www.forexacuity.co.uk
fail2ban-clientManage fail2ban intrusion prevention
sudo fail2ban-client status # Show jail status sudo fail2ban-client status sshd
ufwUncomplicated Firewall management
sudo ufw enable # Enable firewall sudo ufw allow 80/tcp # Allow HTTP
ufw allow 2222/tcpAllow SSH on custom port through firewall
sudo ufw allow 2222/tcp
ufw allow 80/tcp && ufw allow 443/tcpAllow HTTP and HTTPS through firewall
sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
ufw statusCheck firewall status and rules
sudo ufw status verbose # Detailed firewall status
rsyncSynchronize files between local and remote
rsync -avz --progress -e "ssh -p 2222" local/ user@server-ip:/remote/
scpSecure copy files over SSH
scp -P 2222 local-file.txt user@server-ip:/remote/path/
sshConnect to remote server via SSH
ssh user@server-ip # Basic connection ssh -p 2222 user@server-ip # Custom port
ssh -L 5901:localhost:5900 -p 2222 -N forexuser@217.154.33.169 &Create SSH tunnel for VNC access
ssh -L 5901:localhost:5900 -p 2222 -N forexuser@217.154.33.169 &
ssh -p 2222 forexuser@217.154.33.169Connect to VPS via SSH on custom port
ssh -p 2222 forexuser@217.154.33.169
ssh-copy-idCopy SSH public key to remote server
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server-ip
ssh-keygenGenerate SSH key pair
ssh-keygen -t ed25519 -C "your-email@example.com"
ssh-keygen -t ed25519 -C "email@example.com"Generate SSH key for secure access
ssh-keygen -t ed25519 -C "hakim@devhakim.com"
certbotGenerate SSL certificates with Let's Encrypt
sudo certbot --nginx -d domain.com -d www.domain.com
certbot --reinstallReinstall SSL certificate and fix nginx configuration
sudo certbot --nginx -d devhakim.com -d www.devhakim.com --reinstall
certbot certificatesList installed SSL certificates
sudo certbot certificates # Show all certificates
certbot renewRenew SSL certificates
sudo certbot renew --dry-run # Test renewal sudo certbot renew --quiet # Renew silently
openssl s_clientCheck SSL certificate details and validation
echo | openssl s_client -connect devhakim.com:443 -servername devhakim.com 2>/dev/null | openssl x509 -noout -subject -dates
systemctl list-timersCheck systemd timers including SSL auto-renewal
systemctl list-timers | grep certbot # Check certbot auto-renewal status
apt update && apt upgrade -yUpdate system packages
sudo apt update && sudo apt upgrade -y
cat filenameDisplay file contents
cat package.json
cd /path/to/directoryChange directory to specified path
cd /var/www/fx-platform
chmod +x filenameMake file executable
chmod +x ~/start-mt5.sh
cp source destinationCopy files or directories
cp .env.example .env.local
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -Add Node.js repository
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo bash -
dpkg --add-architecture i386Enable 32-bit architecture for Wine
sudo dpkg --add-architecture i386
export DISPLAY=:1Set display environment variable for X11 applications
export DISPLAY=:1
grep "pattern" filenameSearch for text pattern in files
grep "error" /var/log/nginx/error.log
ls -laList all files and directories with detailed info
ls -la
mkdir -p /path/to/directoryCreate directory and parent directories if needed
mkdir -p ~/Downloads/installers
mv source destinationMove or rename files and directories
mv old-file.txt new-file.txt
nano filenameEdit file with nano text editor
nano .env.local
pkill -f wineKill all processes containing "wine" in command line
pkill -f wine
pwdPrint working directory (show current location)
pwd
rm -rf directoryRemove files and directories recursively
rm -rf node_modules/
wget https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exeDownload MT5 installer from official source
wget https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe
which commandFind location of command executable
which node
journalctlView service logs
sudo journalctl -u nginx -f # Follow logs sudo journalctl -u nginx --since "10 minutes ago"
journalctl -u mt5 -fFollow MT5 service logs in real-time
journalctl -u mt5 -f
systemctl daemon-reloadReload systemd configuration
sudo systemctl daemon-reload # After editing service files
systemctl enableEnable service to start on boot
sudo systemctl enable nginx
systemctl enable x11-virtualEnable X11 virtual display service
sudo systemctl enable x11-virtual
systemctl startStart a service
sudo systemctl start nginx
systemctl stopStop a service
sudo systemctl stop nginx
crontab -lList user cron jobs
crontab -l 2>/dev/null | grep certbot # Check certbot cron jobs
fuserFind and kill processes using files/ports
sudo fuser -k 3001/tcp # Kill processes using port 3001
groupsCheck user group membership
groups # Show current user groups groups username # Show specific user groups
killTerminate processes by PID
kill -9 1234 # Force kill process kill $(lsof -t -i:3001) # Kill process on port
ps auxList all running processes
ps aux | grep node # Find Node.js processes ps aux | head -20
ps aux | grepFind specific processes by name
ps aux | grep nginx # Find nginx processes ps aux | grep node # Find Node.js processes
tail -fFollow log files in real-time
tail -f /var/log/nginx/error.log # Follow nginx errors tail -f app.log
DISPLAY=:1 xdpyinfo | head -5Test X11 display connection
DISPLAY=:1 xdpyinfo | head -5
x11vnc -display :1 -nopw -forever -shared -rfbport 5900 &Start VNC server on virtual display
x11vnc -display :1 -nopw -forever -shared -rfbport 5900 &
Xvfb :1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &Start virtual X display for headless GUI apps
Xvfb :1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &
xwininfo -root -treeDisplay X11 window tree and hierarchy
DISPLAY=:1 xwininfo -root -tree
DISPLAY=:1 wine ~/.wine/drive_c/Program\ Files/MetaTrader\ 5/terminal64.exeStart MT5 with virtual display
DISPLAY=:1 wine ~/.wine/drive_c/Program\ Files/MetaTrader\ 5/terminal64.exe
rm -rf /home/forexuser/.cache/winetricksClear Winetricks cache to fix dependency issues
rm -rf /home/forexuser/.cache/winetricks
wineRun Windows applications in Wine
wine setup.exe # Run Windows installer DISPLAY=:1 wine terminal64.exe
wine reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion /t REG_SZ /d "10.0" /fConfigure Wine to emulate Windows 10
wine reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion /t REG_SZ /d "10.0" /f
winecfgConfigure Wine settings
winecfg # Open Wine configuration GUI
wineserver -kStop Wine server and terminate all Wine processes
wineserver -k
winetricksInstall Windows dependencies in Wine
winetricks corefonts vcrun2019 # Install common dependencies
winetricks corefonts vcrun2019 msxml6 msxml3Install Windows dependencies for MT5
winetricks corefonts vcrun2019 msxml6 msxml3