{
  "slug": "Introduction-to-Ubuntu-22-04-System-Setup-and-Environment-Configuration-for-a-Golang-developer-c0979cb9e68d",
  "title": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
  "subtitle": "This comprehensive guide provides a step-by-step walkthrough for setting up a fully functional Ubuntu development environment from scratch…",
  "excerpt": "This comprehensive guide provides a step-by-step walkthrough for setting up a fully functional Ubuntu development environment from scratch…",
  "date": "2025-10-25",
  "tags": [
    "Go",
    "Linux"
  ],
  "readingTime": "6 min",
  "url": "https://medium.com/@mobinshaterian/introduction-to-ubuntu-22-04-system-setup-and-environment-configuration-for-a-golang-developer-c0979cb9e68d",
  "hero": "https://cdn-images-1.medium.com/max/800/1*evrvh0WS882VVj1YTx0PkQ.png",
  "content": [
    {
      "type": "paragraph",
      "html": "This comprehensive guide provides a step-by-step walkthrough for setting up a fully functional Ubuntu development environment from scratch. Whether you’re a developer, system administrator, or power user, this document covers everything from essential system updates and networking configuration to installing professional development tools and optimizing your workflow."
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*evrvh0WS882VVj1YTx0PkQ.png",
      "alt": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
      "caption": "",
      "width": 1024,
      "height": 1024
    },
    {
      "type": "paragraph",
      "html": "The guide begins with fundamental system maintenance tasks, including package updates and DNS configuration, which form the foundation of a stable system. It then progresses through installing popular development tools such as Go, Visual Studio Code, Docker, and linting tools like golangci-lint. Beyond development utilities, you’ll find instructions for productivity applications, communication platforms, and system optimization techniques."
    },
    {
      "type": "paragraph",
      "html": "A key section focuses on configuring DNSMasq for advanced DNS management, enabling split-DNS capabilities that allow you to route different domains through custom DNS servers — a particularly useful feature for managing multiple network environments or accessing region-specific services. The guide also covers network security setup with SSH keys, VPN connectivity through OpenConnect, and performance monitoring tools."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Here is the list of configurations mentioned in this article:"
    },
    {
      "type": "paragraph",
      "html": "The article covers system-level configurations, including Ubuntu package updates and installation of the fix-broken dependencies tool. Network configuration is extensively detailed through DNS setup via /etc/resolv.conf, followed by advanced DNSMasq configuration for split-DNS routing with custom nameservers for specific domains. Firefox settings adjustments are mentioned for DNS preferences, while OpenConnect configuration includes SSL certificate extraction using OpenSSL commands for VPN connectivity."
    },
    {
      "type": "paragraph",
      "html": "Development environment configurations involve setting up Golang with PATH exports and GOPATH definitions in bashrc, along with Visual Studio Code settings for golangci-lint integration with specific linting flags. System service management includes enabling and disabling systemd-resolved, restarting DNSMasq services, and checking unit file status through systemctl commands. Security configurations encompass SSH key setup procedures and file permissions management using chattr commands to make /etc/resolv.conf immutable."
    },
    {
      "type": "paragraph",
      "html": "Performance and logging configurations feature DNSMasq log file creation at /var/log/dnsmasq.log with query logging enabled, along with cache size optimization settings. Virtual machine configurations address VirtualBox kernel module issues, Windows VM screen resolution adjustments, and audio input enablement. Storage optimization includes swap size increase procedures, while monitoring configurations involve htop setup and iotop installation for system resource tracking. Additional configurations cover desktop environment customization through Bing wallpaper integration, calendar extension setup, and SafeEyes configuration for break reminders during extended work sessions."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Update Ubuntu"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt update\nsudo\napt install -f"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Telegram"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo snap install telegram-desktop"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Set DNS"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo vi /etc/resolv.conf"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "nameserver 10.202.10.10nameserver 10.202.10.11"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Set in Firefox settings"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*fBBt3kGaTF4HtVJZw1xZlQ.png",
      "alt": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
      "caption": "",
      "width": 759,
      "height": 827
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Insomnia"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo snap install insomnia"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install htop"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt  install htop"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Postman"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo snap install postman"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Proxychains"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt-get install proxychains\nsudo gedit/etc/proxychains.conf"
    },
    {
      "type": "paragraph",
      "html": "curl icanhazip.com"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "LiberOffice"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt install libreoffice"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Gedit"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt  install gedit"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt install dbus-x11"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install DNSMASQ"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo add-apt-repository universe\nsudo\napt install software-properties-common\nsudo\napt install dnsmasq"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "dnsmasq --versionDnsmasq version 2.90  Copyright (c) 2000-2024 Simon KelleyCompile time options:\nIPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset nftset auth\ncryptohash DNSSEC loop-detect inotify dumpfile"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "This software comes with ABSOLUTELY NO WARRANTY.Dnsmasq is free software, and you are welcome to\nredistribute itunder the terms of the GNU General Public License, version 2 or 3."
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Check running"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "systemctl list-unit-files | grep dnsmasq"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Make a log file"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo touch /var/log/dnsmasq.log"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "sudo gedit /etc/dnsmasq.d/99-split-dns.conf"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "# Listen only on loopbackinterface=lobind-interfaceslisten-address=127.0.0.1"
    },
    {
      "type": "code",
      "lang": "go",
      "code": "# Special DNS for specific\ndomainsserver=/mysite.ir/1.1.1.1server=/youtube.com/4.4.4.4server=/shecan.ir/178.22.122.101server=/ir/1.1.1.1"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "# Default DNS (Shecan)server=178.22.122.101"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "# Security & behaviordomain-neededbogus-privno-resolvno-poll"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "# Performancecache-size=1000"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Logging (optional — logs go to journal/syslog by\ndefault)log-querieslog-facility=/var/log/dnsmasq.log"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Check config syntax (optional but helpful)"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo dnsmasq --testdnsmasq: syntax check OK."
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Restart DNSMasq"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo systemctl restart dnsmasq"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Ensure /etc/resolv.conf uses 127.0.0.1"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "cat /etc/resolv.conf"
    },
    {
      "type": "paragraph",
      "html": "It should contain:"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "nameserver 127.0.0.1"
    },
    {
      "type": "paragraph",
      "html": "If it shows <code>127.0.0.53</code> (systemd-resolved) or something else:"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Stop and disable systemd-resolved\nsudo systemctl stop systemd-resolved\nsudo systemctl disable\nsystemd-resolved"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Replace resolv.confecho \"nameserver 127.0.0.1\" | sudo tee /etc/resolv.conf"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Remove the symlink and create a static /etc/resolv.conf"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Remove the symlink\nsudo rm /etc/resolv.conf"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Create a new static file with DNSMasq as the resolverecho \"nameserver 127.0.0.1\" | sudo tee\n/etc/resolv.conf"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "(Recommended) Lock the file to prevent overwrites"
    },
    {
      "type": "paragraph",
      "html": "Many services (NetworkManager, cloud-init, and DHCP clients) will try to restore the symlink."
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Make it immutable:"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo chattr +i /etc/resolv.conf"
    },
    {
      "type": "paragraph",
      "html": "🔒 To edit it later:"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo chattr -i /etc/resolv.conf"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "✅ Verify the fix"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "cat /etc/resolv.conf\ncat /var/log/dnsmasq.log"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Dig DNS"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "dig @127.0.0.1 datadriveninvestor.com\nsudo tail -f /var/log/dnsmasq.log\nsudo cat\n/etc/dnsmasq.d/99-split-dns.conf"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Language"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*EiYAReirOPlYMrQutVmftQ.png",
      "alt": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
      "caption": "",
      "width": 508,
      "height": 522
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Golang"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "rm -rf /usr/local/go && tar -C /usr/local -xzf go1.25.3.linux-amd64.tar.gz"
    },
    {
      "type": "code",
      "lang": "javascript",
      "code": "export PATH=$PATH:/usr/local/go/bin"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "go version"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Add to bashrc"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Go installation path\nexport PATH=$PATH:/usr/local/go/bin"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Set GOPATH explicitly (optional but clearer)\nexport GOPATH=$HOME/go"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Add Go workspace bin to PATH\nexport PATH=$PATH:$GOPATH/bin"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "source ~/.bashrc"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Make a folder"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "mkdir $HOME/go/src\nmkdir $HOME/go/pkg\nmkdir $HOME/go/bin"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "How to Set Up SSH Keys on Ubuntu 22.04"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Vscode"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Safe Eye"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "Protect Your Eyes From Eye Strain"
    },
    {
      "type": "paragraph",
      "html": "SafeEyes is a simple, beautiful, and extensible break reminder that helps prevent eye strain when working long hours at the computer."
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt install safeeyes"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Chrome"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo dpkg -i google-chrome-stable_current_amd64.deb"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Golangci-lint"
    },
    {
      "type": "paragraph",
      "html": "Golangci-lint is a fast linters runner for Gois a fast linters runner for Go"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "# Install to $(go env GOPATH)/bin (common and recommended)\ncurl -sSfL\nhttps://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env\nGOPATH)/bin v1.59.1"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "golangci-lint --version"
    },
    {
      "type": "paragraph",
      "html": "Open your workspace or user <code>settings.json</code>"
    },
    {
      "type": "code",
      "lang": "json",
      "code": "{\n  \"go.lintTool\": \"golangci-lint\",\n  \"go.lintOnSave\": \"file\",\n  \"go.lintFlags\": [\n    \"--fast\"\n  ]\n}"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Docker"
    },
    {
      "type": "paragraph",
      "html": "<a href=\"https://www.arvancloud.ir/fa/dev/docker\" target=\"_blank\" rel=\"noreferrer noopener\">https://www.arvancloud.ir/fa/dev/docker</a>"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install tools"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt install calc\nsudo\napt-get install unrar\nsudo\napt-get install iotop\nsudo\napt-get install vim\nsudo\napt-get install curl\nsudo\napt-get install build-essential\nsudo snap install vlc\nsudo\napt install net-tools"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Change the background with Bing wallpaper"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo snap install bing-wall"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Shamsi Calendar Extension"
    },
    {
      "type": "paragraph",
      "html": "sudo apt install gnome-shell-extensions"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "https://extensions.gnome.org/extension/240/persian-calendar/"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Open connect"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt-get install openconnect network-manager-openconnect network-manager-openconnect-gnome"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "openssl pkcs12 -in user.pfx -out exported.pem -nokeysopenssl pkcs12 -in user.pfx -out exported.key\n-nocerts"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*gm-MrO5J2oFMJAksQ8KA6Q.png",
      "alt": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
      "caption": "",
      "width": 560,
      "height": 336
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Increase swap size"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install SonarQube"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "PGAdmin 4"
    },
    {
      "type": "paragraph",
      "html": "<a href=\"http://127.0.0.1/pgadmin4\" target=\"_blank\" rel=\"noreferrer noopener\">http://127.0.0.1/pgadmin4</a>"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Node.js ≥ v20 using NodeSource"
    },
    {
      "type": "paragraph",
      "html": "Follow these steps to install a supported version:"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "1. Install required dependencies"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt update\nsudo\napt install -y ca-certificates\ncurl gnupg"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "2. Add NodeSource repository (for Node.js 22.x)"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "curl -fsSL https://deb.nodesource.com/setup_22.x |\nsudo -E bash -"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "3. Install Node.js"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt install -y nodejs"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "4. Verify installation"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "node --versionnpm --version"
    },
    {
      "type": "paragraph",
      "html": "which node"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "/usr/bin/node"
    },
    {
      "type": "paragraph",
      "html": "Then in VS Code settings.json:"
    },
    {
      "type": "code",
      "lang": "json",
      "code": "{\n  \"sonarlint.pathToNodeExecutable\": \"/usr/bin/node\"\n}"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Windows as a virtual machine (VM) on Ubuntu 22.04"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "1. Install VirtualBox"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt update\nsudo\napt install virtualbox virtualbox-ext-pack -y2"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "⚠️ Problem 1: VirtualBox kernel module not loaded"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt --fix-broken install"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "2. Download Windows ISO"
    },
    {
      "type": "paragraph",
      "html": "Go to Microsoft’s official page:<br>&nbsp;👉 <a href=\"https://www.microsoft.com/software-download/windows10\" target=\"_blank\" rel=\"noreferrer noopener\">https://www.microsoft.com/software-download/windows10</a><br>&nbsp;or<br>&nbsp;👉 <a href=\"https://www.microsoft.com/software-download/windows11\" target=\"_blank\" rel=\"noreferrer noopener\">https://www.microsoft.com/software-download/windows11</a>"
    },
    {
      "type": "paragraph",
      "html": "Save the&nbsp;<code>.iso</code> file (e.g., <code>Win11_English_x64.iso</code>)."
    },
    {
      "type": "heading",
      "level": 3,
      "text": "3. Install Windows"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "4. How to change screen resolution in VirtualBox Windows 11 VM"
    },
    {
      "type": "embed",
      "provider": "youtube",
      "url": "https://www.youtube.com/embed/hseQds2TOIw?feature=oembed"
    },
    {
      "type": "heading",
      "level": 3,
      "text": "5. enable input audio"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*MVCxJXAG1vwVtDQb9X_HHA.png",
      "alt": "Introduction to Ubuntu 22.04 System Setup and Environment Configuration for a Golang developer",
      "caption": "",
      "width": 485,
      "height": 404
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Concultion"
    },
    {
      "type": "paragraph",
      "html": "This comprehensive Ubuntu setup guide provides a complete roadmap for transforming a fresh installation into a robust, professionally configured development environment by systematically addressing system updates, network configurations, security protocols, and development tool installations. The article demonstrates that proper system configuration extends beyond simply installing applications, with critical elements such as DNS management through DNSMasq, SSH key security implementation, and firewall setup through Proxychains, creating a secure and reliable computing environment. The inclusion of development tools like Golang, Docker, and Visual Studio Code, combined with productivity applications and system monitoring utilities, ensures users have everything necessary for both professional development and daily operations. The guide emphasizes the importance of system maintenance and optimization, including swap size management, eye strain prevention through SafeEyes, and performance monitoring with htop and iotop, while the ability to run Windows as a virtual machine through VirtualBox adds versatility for cross-platform work. By following this guide methodically, users not only configure their systems efficiently but also gain practical knowledge about Linux system administration, networking, development workflows, and best practices for maintaining a secure and performant computing environment. Whether you are a beginner setting up your first development machine or an experienced administrator optimizing your workflow, this guide serves as a valuable reference for creating a personalized, fully functional Ubuntu setup tailored to your specific needs and preferences."
    }
  ]
}
