Last active
October 1, 2025 15:31
-
-
Save njanirudh/353d986d9b7ddd1f52efc961e4b0989b to your computer and use it in GitHub Desktop.
Bash script to setup a new Ubuntu PC with my custom setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| ask() { | |
| # $1 = question text, $2 = default (y/n) | |
| local prompt | |
| if [[ "$2" == "y" ]]; then | |
| prompt="[Y/n]" | |
| default="y" | |
| else | |
| prompt="[y/N]" | |
| default="n" | |
| fi | |
| read -p "$1 $prompt " reply | |
| reply=${reply:-$default} | |
| if [[ "$reply" =~ ^[Yy]$ ]]; then | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| # -------------------------------------------------- | |
| # SSH Key Setup | |
| if ask "Do you want to set up SSH keys?" y; then | |
| 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 | |
| fi | |
| # -------------------------------------------------- | |
| # Generate Folders | |
| if ask "Do you want to create directories?" y; then | |
| echo "Creating directories..." | |
| mkdir -p ~/Software ~/NJ ~/Musicmaking/Ampero ~/Hobby/Programming ~/Book \ | |
| ~/Downloads/Programs ~/Downloads/Documents ~/Downloads/Media \ | |
| ~/NJ_Github | |
| fi | |
| # -------------------------------------------------- | |
| # Update and Install APT Packages | |
| if ask "Do you want to update and install APT packages?" y; then | |
| 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 \ | |
| neofetch \ | |
| code | |
| fi | |
| # -------------------------------------------------- | |
| # Install VS Code extensions | |
| if ask "Do you want to install VS Code extensions?" y; then | |
| echo "Installing VS Code extensions..." | |
| code --install-extension ms-python.python | |
| code --install-extension ms-vscode.cpptools | |
| fi | |
| # -------------------------------------------------- | |
| # Install PyTorch, CUDA, and PyTorch Lightning | |
| if ask "Do you want to install PyTorch, CUDA, and Lightning?" y; then | |
| echo "Installing PyTorch, CUDA, and PyTorch Lightning..." | |
| pip3 install torch torchvision torchaudio pytorch-lightning --index-url https://download.pytorch.org/whl/cu118 | |
| fi | |
| # -------------------------------------------------- | |
| # Setup TurboVNC | |
| if ask "Do you want to set up TurboVNC?" n; then | |
| echo "Setting up TurboVNC..." | |
| sudo apt install -y turbovnc | |
| fi | |
| # -------------------------------------------------- | |
| # Modify .bashrc | |
| if ask "Do you want to modify .bashrc with custom settings?" y; then | |
| 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 | |
| fi | |
| # -------------------------------------------------- | |
| echo "Setup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment