Ubuntu: Step-by-Step Setup for Development
This article guides a newcomer through preparing a clean Ubuntu system for development. Follow the commands exactly, and copy/paste only what applies to your machine. Where appropriate, I explain why each step is done.
1. Update the system and install basic tools
Section titled “1. Update the system and install basic tools”Open a terminal and run:
sudo apt updatesudo apt upgrade -ysudo apt install -y build-essential curl wget git ca-certificates gnupg lsb-releasebuild-essentialinstalls GCC,make, and essential headers.gnupgandlsb-releaseare used when adding third-party repositories.
2. Create a working user and basic directory layout
Section titled “2. Create a working user and basic directory layout”If you are using the default user created during installation, skip user creation. Otherwise create a regular user (do not use root for daily work):
sudo adduser devusersudo usermod -aG sudo devusersu - devusermkdir -p ~/projects ~/binStore projects under ~/projects and personal scripts in ~/bin (add ~/bin to PATH later if needed).
3. Configure Git
Section titled “3. Configure Git”Set global name and email, and a sensible core editor:
git config --global user.name "Your Name"git config --global user.email you@example.comgit config --global core.editor "nvim"git config --global credential.helper cache4. Install development editor (Neovim) and language tooling
Section titled “4. Install development editor (Neovim) and language tooling”Install Neovim and Python support:
sudo apt install -y neovim python3-pippip3 install --user pynvimFor Node and other toolchains, follow upstream installers for predictable versions (e.g., NodeSource, pyenv, rbenv).
5. Install kernel headers and DKMS (for building modules)
Section titled “5. Install kernel headers and DKMS (for building modules)”Install the headers matching your running kernel:
sudo apt install -y linux-headers-$(uname -r) dkmsIf headers are unavailable for a custom kernel, install a matching linux-headers-<version> package from Ubuntu repositories.
6. Graphics drivers (NVIDIA) — safe, step-by-step
Section titled “6. Graphics drivers (NVIDIA) — safe, step-by-step”Ubuntu provides tested proprietary drivers via ubuntu-drivers. Preferred workflow:
sudo ubuntu-drivers devicessudo ubuntu-drivers autoinstallReboot after install. If secure boot is enabled, Ubuntu will prompt to enroll a Machine-Owner Key (MOK) during the next boot — follow on-screen instructions and set a password to complete enrollment.
If you prefer manual control, install a specific driver package, for example:
sudo apt install -y nvidia-driver-535sudo rebootVerify the driver:
nvidia-smiIf nvidia-smi fails, check dmesg and journalctl -u systemd-modules-load for DKMS/module load errors.
7. Mesa / Intel / AMD (open drivers)
Section titled “7. Mesa / Intel / AMD (open drivers)”Intel and AMD GPUs typically work with Mesa. Keep Mesa recent via the official Ubuntu updates or a supported PPA (only if needed).
Basic check:
glxinfo | grep "OpenGL renderer"Install mesa-utils for diagnostics:
sudo apt install -y mesa-utils8. Wi‑Fi and Bluetooth firmware
Section titled “8. Wi‑Fi and Bluetooth firmware”Check available interfaces:
ip linkIf a Wi‑Fi device is present but not working, check dmesg for firmware messages (dmesg | grep -i firmware), then install the vendor firmware package, for example:
sudo apt install -y linux-firmware-iwlwifisudo modprobe -r iwlwifi && sudo modprobe iwlwifiFor Broadcom chipsets, the bcmwl-kernel-source package is commonly required:
sudo apt updatesudo apt install -y bcmwl-kernel-sourcesudo modprobe -r b43 bcma wl && sudo modprobe wl9. Docker (for containerized development)
Section titled “9. Docker (for containerized development)”Install Docker via the official repository to get up-to-date releases:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgecho "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt updatesudo apt install -y docker-ce docker-ce-cli containerd.iosudo usermod -aG docker $USERnewgrp dockerdocker run --rm hello-worldLog out and back in to apply group changes permanently.
10. Secure Boot considerations
Section titled “10. Secure Boot considerations”If Secure Boot is enabled, kernel modules that are not signed may be blocked. For third-party drivers (NVIDIA) DKMS packages will usually trigger a MOK enrollment prompt. If you encounter unsigned module errors, either disable Secure Boot in firmware or sign modules (advanced).
11. Basic firewall and SSH
Section titled “11. Basic firewall and SSH”Enable uncomplicated firewall and allow SSH if you need remote access:
sudo apt install -y ufwsudo ufw allow OpenSSHsudo ufw enable
sudo apt install -y openssh-serversudo systemctl enable --now ssh12. Test small C program and debugging toolchain
Section titled “12. Test small C program and debugging toolchain”Create ~/projects/hello.c:
#include <stdio.h>int main(){ printf("hello\n"); return 0; }Build and run:
gcc -g -O0 -o hello ~/projects/hello.c./hellogdb ./hello13. Troubleshooting commands (collection)
Section titled “13. Troubleshooting commands (collection)”dmesg— kernel messagesjournalctl -b— boot logssudo lshw -C network— hardware list for networklspci -k— device and driver mappinglsmod | grep <module>— check loaded modules
Next steps
Section titled “Next steps”If you want, I will now produce:
- a per-command walkthrough for Ubuntu 24.04 with copyable commands for NVIDIA, Wi‑Fi (Intel/Broadcom), and DKMS module building; and
- matching Chinese translations.
Which specific driver/topic should I expand first? NVIDIA, Wi‑Fi, DKMS, or Secure Boot module signing?