Skip to content

MeMoElprince/My-Ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

🐧 My Ubuntu

A step-by-step guide to set up a fresh Ubuntu machine — for development and production servers

Ubuntu Shell License


📖 About

Two guides in one place:

Guide For Jump to
🖥️ Desktop Setup A new development machine (laptop / workstation) Go →
☁️ VPS / Server Setup A fresh cloud server you will deploy apps to Go →

Tip

Run commands one block at a time and read the note above each block before pasting. Don't paste the whole file blindly.


🧭 Table of Contents


🖥️ Part 1 — Desktop Setup

Set up a fresh Ubuntu desktop as a development machine.

1. Prerequisites

Update the system and install the essentials.

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y git curl wget g++ build-essential gnome-tweaks
Package Why
git Version control
curl / wget Download files & install scripts
g++ / build-essential C / C++ compiler + build tools
gnome-tweaks Extra desktop settings

Done — system updated and base tools installed.


2. Configure Git

Set your identity (used on every commit).

git config --global user.name "Your Name"
git config --global user.email "your@email.com"
git config --global init.defaultBranch main

Verify:

git config --global --list

Done — Git knows who you are.


3. Generate an SSH Key & add it to GitHub

Note

Modern guidance recommends the Ed25519 key type — it's faster and more secure than the old RSA default.

1. Generate the key

ssh-keygen -t ed25519 -C "your@email.com"
  • Press Enter to accept the default location (~/.ssh/id_ed25519).
  • Enter a passphrase (recommended) or press Enter twice to leave it blank.

Example: generating an SSH key

2. Copy the public key

cat ~/.ssh/id_ed25519.pub

Copy the entire output (starts with ssh-ed25519 ...).

3. Add it to GitHub

  1. Open GitHub → profile picture → Settings.
  2. Go to SSH and GPG keys.
  3. Click New SSH key.
  4. Give it a title (e.g. My Laptop) and paste the key.
  5. Click Add SSH key.

4. Test the connection

ssh -T git@github.com

You should see: "Hi username! You've successfully authenticated…"

Done — you can now push/pull over SSH.


4. Install VS Code

sudo snap install --classic code

Recommended extensions

Extension Purpose
C/C++ IntelliSense & debugging
Code Runner Run snippets in one click
C/C++ Themes Better C/C++ syntax colors
CMake CMake project support
Markdown Preview Enhanced Rich Markdown preview
Markdown All in One Markdown shortcuts & TOC

Install from the Extensions panel (Ctrl+Shift+X), or from the terminal:

code --install-extension ms-vscode.cpptools \
     --install-extension formulahendry.code-runner \
     --install-extension ms-vscode.cmake-tools \
     --install-extension shd101wyy.markdown-preview-enhanced \
     --install-extension yzhang.markdown-all-in-one

Quick settings

  • Auto Save: File → Auto Save
  • Run in terminal: Settings → Extensions → Run Code → ✔ Run In Terminal

Done — VS Code ready.


5. Set up zsh + Oh My Zsh

1. Install zsh

sudo apt-get install -y zsh

2. Install Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

3. Make zsh your default shell

chsh -s $(which zsh)

Log out and back in for the change to take effect.

Done — zsh + Oh My Zsh installed.


6. Theme: Powerlevel10k

1. Clone the theme

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
  ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

2. Set it in ~/.zshrc

nano ~/.zshrc

Find the ZSH_THEME line and change it to:

ZSH_THEME="powerlevel10k/powerlevel10k"

Save with Ctrl+OEnter, exit with Ctrl+X.

3. Apply the changes

source ~/.zshrc

The Powerlevel10k configuration wizard starts automatically. To re-run it anytime:

p10k configure

Done — your terminal looks 🔥.


🎉 Desktop setup complete. Reboot once and you're ready to build.


☁️ Part 2 — VPS / Server Setup

Take a fresh cloud server (DigitalOcean, Hetzner, AWS, etc.) from zero to deploying web apps with Nginx, SSL and PM2.

Warning

Run these as you SSH into the server. Steps 1–2 are security basics — don't skip them. Servers running as root with no firewall get compromised fast.

1. Create a non-root user

Working as root is risky. Create a dedicated user with sudo rights.

# 1. Create the user (you'll be prompted for a password)
adduser memo

# 2. Grant sudo privileges
usermod -aG sudo memo

# 3. Switch to the new user
su - memo

Replace memo with your chosen username throughout this guide.

Done — you now have a safer, non-root account.


2. Basic firewall (UFW)

Allow only what you need, then enable the firewall.

sudo apt update && sudo apt install -y ufw

sudo ufw allow OpenSSH        # keep SSH open — don't lock yourself out!
sudo ufw allow 'Nginx Full'   # HTTP (80) + HTTPS (443)

sudo ufw enable
sudo ufw status

Caution

Always allow OpenSSH before running ufw enable, or you'll be locked out of the server.

Done — firewall active.


3. Install Node.js (LTS)

Install the latest LTS release straight from NodeSource.

sudo apt update && sudo apt install -y curl

# Add the NodeSource LTS repository
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

sudo apt install -y nodejs

Verify:

node -v
npm -v

Done — Node.js + npm installed.


4. Install Docker & Docker Compose

Follow the official instructions (kept current by Docker):

Note

Use sudo when installing Docker Compose.

Run Docker without sudo:

sudo usermod -aG docker memo

Log out and back in for the group change to take effect.

Verify:

docker --version
docker compose version   # or: docker-compose version

Done — Docker ready.


5. Install & configure Nginx

sudo apt update
sudo apt install -y nginx

sudo systemctl enable nginx   # start on boot
sudo systemctl start nginx

sudo systemctl status nginx

If you didn't already do this in step 2:

sudo ufw allow 'Nginx Full'

Visit http://your-server-ip — you should see the Nginx welcome page.

Done — Nginx is serving.


6. Free SSL with Certbot

Install Certbot and the Nginx plugin:

sudo apt install -y certbot python3-certbot-nginx

Issue a certificate for each domain (point your DNS A record at the server first):

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot auto-configures Nginx and sets up auto-renewal. Test renewal with:

sudo certbot renew --dry-run

Done — HTTPS enabled and auto-renewing. 🔒


7. Deploy a frontend with PM2

PM2 keeps your app running and restarts it on crash or reboot.

sudo npm install -g serve pm2

Serve a built static app (e.g. a Vite dist/ folder):

pm2 start serve --name memo-landing -- -s dist -l 3000

Other common patterns:

# Static site on a custom port
pm2 start "npx serve -s dist -l 3000" --name arayees-front-client-3000

# Another static app
pm2 start "npx serve -s dist -l 2233" --name hola-dashboard-2233

# A Next.js app
pm2 start "npx next start -p 2233" --name hola-dashboard

Make PM2 survive reboots:

pm2 save
pm2 startup   # run the command it prints

Useful PM2 commands:

pm2 list           # show all processes
pm2 logs           # tail logs
pm2 restart <name> # restart an app
pm2 delete <name>  # stop & remove an app

Done — your app stays up.


8. Nginx reverse proxy per domain

Point a domain at a local PM2 app (e.g. dashboard.memo.comlocalhost:3001).

1. Create the site config

sudo nano /etc/nginx/sites-available/dashboard.memo.com

2. Paste this (adjust domain + port):

server {
    listen 80;
    server_name dashboard.memo.com;

    location / {
        proxy_pass http://localhost:3001;   # your app's port
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

3. Enable the site, test, reload

sudo ln -s /etc/nginx/sites-available/dashboard.memo.com /etc/nginx/sites-enabled/
sudo nginx -t          # test the config
sudo systemctl reload nginx

4. Add SSL for it

sudo certbot --nginx -d dashboard.memo.com

Done — domain live over HTTPS, proxied to your app.


🚀 Server ready. Repeat steps 7–8 for each app you deploy.


🧩 Cheat Sheet

Task Command
Update system sudo apt update && sudo apt upgrade -y
Test GitHub SSH ssh -T git@github.com
List PM2 apps pm2 list
Tail PM2 logs pm2 logs
Test Nginx config sudo nginx -t
Reload Nginx sudo systemctl reload nginx
Firewall status sudo ufw status
Renew SSL (dry run) sudo certbot renew --dry-run

Made with ☕ by Mustafa — happy hacking!

About

My inital setup for my ubuntu environment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors