Skip to content

Instantly share code, notes, and snippets.

@njanirudh
Last active April 27, 2025 07:37
Show Gist options
  • Save njanirudh/353d986d9b7ddd1f52efc961e4b0989b to your computer and use it in GitHub Desktop.
Save njanirudh/353d986d9b7ddd1f52efc961e4b0989b to your computer and use it in GitHub Desktop.
Bash script to setup a new Ubuntu PC with my custom setup
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# --------------------------------------------------
# SSH Key Setup
echo "Setting up SSH keys..."
if [ ! -f "$HOME/.ssh/id_rsa" ]; then
ssh-keygen -t rsa -b 4096 -C "$USER@$(hostname)" -N "" -f "$HOME/.ssh/id_rsa"
echo "SSH key generated."
else
echo "SSH key already exists."
fi
# --------------------------------------------------
# Generate Folders
echo "Creating directories..."
mkdir -p ~/Software ~/NJ ~/Musicmaking/Ampero ~/Hobby/Programming ~/Book \
~/Downloads/Programs ~/Downloads/Documents ~/Downloads/Media \
~/NJ_Github
# --------------------------------------------------
# Update and Install APT Packages
echo "Updating package list and installing packages..."
sudo apt update
sudo apt install -y \
terminator \
tmux \
nmap \
neovim \
autokey-gtk \
wireshark \
docker.io \
gimp \
folder-color \
python3-opencv \
libasio-dev \
code # Assuming VS Code is available from repository
# --------------------------------------------------
# Install VS Code extensions
echo "Installing VS Code extensions..."
code --install-extension ms-python.python
code --install-extension ms-vscode.cpptools
# --------------------------------------------------
# Install PyTorch, CUDA, and PyTorch Lightning
# (Assuming pip and pip3 are already installed)
echo "Installing PyTorch, CUDA, and PyTorch Lightning..."
pip3 install torch torchvision torchaudio pytorch-lightning --index-url https://download.pytorch.org/whl/cu118
# --------------------------------------------------
# Setup TurboVNC
# (Assuming you have the TurboVNC installer script or repo access)
echo "Setting up TurboVNC..."
sudo apt install -y turbovnc
# --------------------------------------------------
# Modify .bashrc
echo "Adding custom settings to .bashrc..."
BASHRC_FILE="$HOME/.bashrc"
CUSTOM_SECTION="\n# Custom Settings\n"
CUSTOM_SECTION+="alias ll='ls -la'\n"
CUSTOM_SECTION+="export PATH=\"$HOME/.local/bin:$PATH\"\n"
CUSTOM_SECTION+="\n# Showing git branch\n"
CUSTOM_SECTION+="source /usr/lib/git-core/git-sh-prompt\n"
CUSTOM_SECTION+="export PS1=\"\${debian_chroot:+(\$debian_chroot)}\\[\\033[01;32m\\]\\u: \\[\\033[01;34m\\]\\w\\[\\033[00m\\]\$(__git_ps1)\\[\\033[00m\\] \"\n"
if ! grep -q "# Custom Settings" "$BASHRC_FILE"; then
echo -e "$CUSTOM_SECTION" >> "$BASHRC_FILE"
echo ".bashrc updated."
else
echo "Custom settings already exist in .bashrc."
fi
# --------------------------------------------------
# Done!
echo "Setup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment