For a developer, setting up a VPS for production can be one of the most challenging tasks. Here’s a basic setup guide to get your server ready for deployment. Whether you’re hosting a Django app, Node.js API, or Laravel website, you’ll need a reliable set of Linux commands to prepare your environment.
In this post, I’m sharing 100+ essential Linux commands that I personally use when setting up a fresh VPS. These commands cover everything from server access and file management to firewall configuration, database installation, and much more—making your VPS deployment smooth and production-ready.
1. Server Access & Session Management
ssh user@server-ip– Connect to VPS over SSH.ssh -p 2222 user@server-ip– Connect using a custom port.ssh-keygen -t rsa -b 4096– Generate an SSH key.ssh-copy-id user@server-ip– Copy your public key to the server.who– Show who is logged in.w– Show logged-in users with processes.exit– Close the SSH session.history– Show previous commands.clear– Clear terminal screen.screen– Create a persistent session.
2. System Info & Monitoring
uname -a– Kernel and OS info.lsb_release -a– Linux distribution info.hostname– Show hostname.uptime– Show uptime.top– View running processes.htop– Interactive process viewer (install withapt install htop).free -h– Show memory usage.df -h– Show disk space usage.du -sh /path– Disk usage of a folder.vmstat– System performance stats.
3. User & Permission Management
adduser deploy– Create a new user.passwd deploy– Change user password.usermod -aG sudo deploy– Add user to sudo group.id deploy– Show user info.groups deploy– Show user’s groups.chown user:group file– Change file owner.chmod 755 file– Set permissions.chmod -R 755 /path– Recursive permissions change.sudo visudo– Edit sudo permissions safely.deluser username– Delete a user.
4. File & Directory Management
pwd– Show current directory.ls -lah– List files with details.cd /path/to/dir– Change directory.mkdir myapp– Create a directory.mkdir -p dir/subdir– Create nested directories.touch file.txt– Create an empty file.nano file.txt– Edit the file in Nano.vi file.txt– Edit file in Vim.cp file1 file2– Copy file.mv file1 file2– Move or rename the file.rm file.txt– Delete file.rm -rf dir– Delete the directory and its contents.cat file.txt– Show file contents.less file.txt– View file with pagination.head -n 10 file.txt– Show first 10 lines.tail -n 10 file.txt– Show last 10 lines.tail -f logs.txt– Follow a log file.find /path -name file.txt– Search for a file.locate filename– Find files quickly (needsmlocate).stat file.txt– Show file info.
5. Networking & Firewall
ping google.com– Check network connectivity.curl ifconfig.me– Show public IP.ip a– Show IP addresses.netstat -tulnp– Show listening ports.ss -tuln– Show open ports.ufw status– Check firewall status.sudo ufw allow 22– Allow SSH port.sudo ufw allow 80– Allow HTTP.sudo ufw allow 443– Allow HTTPS.sudo ufw enable– Enable firewall.
6. Package Management (Debian/Ubuntu)
sudo apt update– Update package list.sudo apt upgrade– Upgrade packages.sudo apt install package– Install package.sudo apt remove package– Remove package.sudo apt autoremove– Remove unused packages.apt list --installed– List installed packages.dpkg -l– List installed packages (dpkg).dpkg -i file.deb– Install .deb file.apt-cache search keyword– Search packages.sudo apt purge package– Remove with config files.
7. Git & Code Deployment
git clone repo-url– Clone repository.git pull origin main– Pull the latest code.git checkout branch– Switch branches.git status– Check repo status.git fetch --all– Fetch all branches.scp file user@server:/path– Copy file to server.scp -r dir user@server:/path– Copy the directory to the server.rsync -avz local/ user@server:/path– Sync files.wget url– Download file.curl -O url– Download file with curl.
8. Web Server Setup
sudo apt install nginx– Install Nginx.sudo systemctl start nginx– Start Nginx.sudo systemctl enable nginx– Enable Nginx at boot.sudo systemctl status nginx– Check status.sudo nano /etc/nginx/sites-available/default– Edit Nginx config.sudo nginx -t– Test Nginx config.sudo systemctl reload nginx– Reload config.sudo apt install apache2– Install Apache.sudo systemctl start apache2– Start Apache.sudo systemctl enable apache2– Enable Apache at boot.
9. Process & Service Management
ps aux– Show running processes.kill PID– Kill process by PID.kill -9 PID– Force kill process.systemctl start service– Start a service.systemctl stop service– Stop a service.systemctl restart service– Restart a service.systemctl status service– Check service status.journalctl -xe– View system logs.journalctl -u service– View logs for a specific service.crontab -e– Edit cron jobs.
Bonus command
This is for running the development server only. If you want to run a production server, use Gunicorn or uWSGI. View my previous blog on how to deploy Django on AWS.
Here’s a step-by-step guide on how to run a Django project on a server in the background using screen:
1. Install screen (if not already installed)
sudo apt update
sudo apt install screen -yOn CentOS/RHEL: sudo yum install screen -y
2. Start a new screen session
django_server Just name whatever you want; you can make it.
screen -S django_server-S django_serverI have named the session so you can find it later.
3. Activate your virtual environment
source venv/bin/activateCreate your virtual environment folder
4. Navigate to your Django project
cd /path/to/your/project5. Run the Django development server
python3 manage.py runserver 0.0.0.0:8000- You can access your project on a public IP address if you run on
0.0.0.0:8000.
6. Detach from the screen session
Press this command:
CTRL + A then D- If you close your VPS, your Django server will run in the background.
7. List all screen sessions
screen -ls8. Reattach to the session
screen -r django_server9. Kill the screen session (stop the server)
screen -X -S django_server quitPlease comment below if you guys like my post.

