100 linux command for vps setup

Learn 100+ Essential Linux Commands to Set Up a Fresh VPS with Python, PostgreSQL, MySQL, and MongoDB

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

  1. ssh user@server-ip – Connect to VPS over SSH.
  2. ssh -p 2222 user@server-ip – Connect using a custom port.
  3. ssh-keygen -t rsa -b 4096 – Generate an SSH key.
  4. ssh-copy-id user@server-ip – Copy your public key to the server.
  5. who – Show who is logged in.
  6. w – Show logged-in users with processes.
  7. exit – Close the SSH session.
  8. history – Show previous commands.
  9. clear – Clear terminal screen.
  10. screen – Create a persistent session.

2. System Info & Monitoring

  1. uname -a – Kernel and OS info.
  2. lsb_release -a – Linux distribution info.
  3. hostname – Show hostname.
  4. uptime – Show uptime.
  5. top – View running processes.
  6. htop – Interactive process viewer (install with apt install htop).
  7. free -h – Show memory usage.
  8. df -h – Show disk space usage.
  9. du -sh /path – Disk usage of a folder.
  10. vmstat – System performance stats.

3. User & Permission Management

  1. adduser deploy – Create a new user.
  2. passwd deploy – Change user password.
  3. usermod -aG sudo deploy – Add user to sudo group.
  4. id deploy – Show user info.
  5. groups deploy – Show user’s groups.
  6. chown user:group file – Change file owner.
  7. chmod 755 file – Set permissions.
  8. chmod -R 755 /path – Recursive permissions change.
  9. sudo visudo – Edit sudo permissions safely.
  10. deluser username – Delete a user.

4. File & Directory Management

  1. pwd – Show current directory.
  2. ls -lah – List files with details.
  3. cd /path/to/dir – Change directory.
  4. mkdir myapp – Create a directory.
  5. mkdir -p dir/subdir – Create nested directories.
  6. touch file.txt – Create an empty file.
  7. nano file.txt – Edit the file in Nano.
  8. vi file.txt – Edit file in Vim.
  9. cp file1 file2 – Copy file.
  10. mv file1 file2 – Move or rename the file.
  11. rm file.txt – Delete file.
  12. rm -rf dir – Delete the directory and its contents.
  13. cat file.txt – Show file contents.
  14. less file.txt – View file with pagination.
  15. head -n 10 file.txt – Show first 10 lines.
  16. tail -n 10 file.txt – Show last 10 lines.
  17. tail -f logs.txt – Follow a log file.
  18. find /path -name file.txt – Search for a file.
  19. locate filename – Find files quickly (needs mlocate).
  20. stat file.txt – Show file info.

5. Networking & Firewall

  1. ping google.com – Check network connectivity.
  2. curl ifconfig.me – Show public IP.
  3. ip a – Show IP addresses.
  4. netstat -tulnp – Show listening ports.
  5. ss -tuln – Show open ports.
  6. ufw status – Check firewall status.
  7. sudo ufw allow 22 – Allow SSH port.
  8. sudo ufw allow 80 – Allow HTTP.
  9. sudo ufw allow 443 – Allow HTTPS.
  10. sudo ufw enable – Enable firewall.

6. Package Management (Debian/Ubuntu)

  1. sudo apt update – Update package list.
  2. sudo apt upgrade – Upgrade packages.
  3. sudo apt install package – Install package.
  4. sudo apt remove package – Remove package.
  5. sudo apt autoremove – Remove unused packages.
  6. apt list --installed – List installed packages.
  7. dpkg -l – List installed packages (dpkg).
  8. dpkg -i file.deb – Install .deb file.
  9. apt-cache search keyword – Search packages.
  10. sudo apt purge package – Remove with config files.

7. Git & Code Deployment

  1. git clone repo-url – Clone repository.
  2. git pull origin main – Pull the latest code.
  3. git checkout branch – Switch branches.
  4. git status – Check repo status.
  5. git fetch --all – Fetch all branches.
  6. scp file user@server:/path – Copy file to server.
  7. scp -r dir user@server:/path – Copy the directory to the server.
  8. rsync -avz local/ user@server:/path – Sync files.
  9. wget url – Download file.
  10. curl -O url – Download file with curl.

8. Web Server Setup

  1. sudo apt install nginx – Install Nginx.
  2. sudo systemctl start nginx – Start Nginx.
  3. sudo systemctl enable nginx – Enable Nginx at boot.
  4. sudo systemctl status nginx – Check status.
  5. sudo nano /etc/nginx/sites-available/default – Edit Nginx config.
  6. sudo nginx -t – Test Nginx config.
  7. sudo systemctl reload nginx – Reload config.
  8. sudo apt install apache2 – Install Apache.
  9. sudo systemctl start apache2 – Start Apache.
  10. sudo systemctl enable apache2 – Enable Apache at boot.

9. Process & Service Management

  1. ps aux – Show running processes.
  2. kill PID – Kill process by PID.
  3. kill -9 PID – Force kill process.
  4. systemctl start service – Start a service.
  5. systemctl stop service – Stop a service.
  6. systemctl restart service – Restart a service.
  7. systemctl status service – Check service status.
  8. journalctl -xe – View system logs.
  9. journalctl -u service – View logs for a specific service.
  10. 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 -y

On 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_server I have named the session so you can find it later.

3. Activate your virtual environment

source venv/bin/activate

Create your virtual environment folder

4. Navigate to your Django project

cd /path/to/your/project

5. 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 -ls

8. Reattach to the session

screen -r django_server

9. Kill the screen session (stop the server)

screen -X -S django_server quit

Please comment below if you guys like my post.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top