Setting Up Linux Development Environment
A Linux-based development environment offers a powerful, customizable, and secure platform for developers across all fields, from web development to systems programming and data science. Whether you`re a beginner taking your first steps in programming or an experienced developer looking to optimize your workflow, configuring your development tools properly on Linux can dramatically improve productivity and efficiency. Ubuntu is one of the best Linux distributions for developers.
In this guide, we will walk through everything you need to set up a modern development environment on Linux. You`ll learn how to choose the right Linux distribution based on your goals, install and manage programming languages such as Node.js, Python, and Java, and configure your terminal, editor, and version control tools.
How to Set Up a Linux Development Environment Node.js?
Setting up a Linux development environment for Node.js involves installing the right runtime, managing versions effectively, using a code editor, and understanding how to initialize and run Node applications. Whether you`re building APIs, web apps, or command-line tools, a clean and functional environment helps avoid compatibility issues and improves your development workflow.
Below is a step-by-step guide to help you install Node.js, configure your tools, and get started writing and running Node applications on any Debian-based Linux system (such as Ubuntu).
1. Update System Packages
Before installing new software, always ensure your package list is current with the following commands.
sudo apt update && sudo apt upgrade -y
This helps avoid installation errors and ensures you're getting the latest stable packages. apt update refreshes the list of available packages and versions. apt upgrade installs the newest versions of all packages currently installed.
2. Install Node.js and npm (Node Package Manager)
Node.js is the JavaScript runtime, and npm is the Node Package Manager used to install packages like frameworks and utilities. npm is essential for installing libraries, frameworks (like Express), and development tools. To install node.js and npm use the following commands.
sudo apt install nodejs npm
Check versions to confirm the installation with the following command.
node -v
npm -v
3. Install nvm (Node Version Manager) - (Optional but Recommended)
If you're working on multiple projects or want more flexibility with Node versions. nvm (Node Version Manager) allows you to install and switch between multiple Node.js versions, which is especially useful if you work on different projects. To install nvm use the following commands.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc
nvm install --lts
curl command downloads and runs the official installation script for nvm (Node Version Manager) from GitHub.
source ~/.bashrc command loads the new nvm environment into your current terminal session. Without this, nvm commands won’t be recognized until you restart your shell.
With nvm, you can easily switch between versions using nvm use <version>.
4. Install Git for Version Control
Version control is essential for tracking your code and collaborating with others. Git lets you track changes in your project and collaborate with others. Even for solo projects, version control prevents mistakes and allows safe experimentation.
The following commands set up your Git identity. These details appear in your commit history.
sudo apt install git
git config --global user.name "Your Name"
git config --global user.email [you@example.com](mailto:you@example.com)
Verify with the following command.
git --version
5. Initialize a Node.js Project
Start by creating a project folder and generating a package.json file, which keeps track of your project's dependencies and scripts. Create your project folder and set up package.json with the following commands.
mkdir my-node-app
cd my-node-app
npm init -y
This file will track your project’s dependencies and scripts.
6. Install Project Dependencies
You can now install packages your app will use, for example, the popular Express.js framework. To install express.js use the following commands.
npm install express
Installed modules are added to node_modules and listed under dependencies in package.json.
7. Create and Run a Basic Application
Create a file named index.js and paste the following code.
const express = require(`express`);
const app = express();
app.get(`/`, (req, res) => res.send(`Hello Node!`));
app.listen(3000, () => console.log(`Server is running on port 3000`));
Run the app with the following command.
node index.js
Visit [http://localhost:3000](http://localhost:3000) in your browser to see your server running.
Figure 1. Visiting Localhost to See the Server Running
8. (Optional) Install nodemon for Auto-Restart During Development
Install nodemon, a development tool that automatically restarts your app whenever file changes are detected. Use the following command to install.
npm install --save-dev nodemon
Then run your app with the following command.
npx nodemon index.js
This allows you to make changes to your code and see the updates instantly without needing to restart the server manually each time, speeding up your development workflow.
9. (Optional) Configure Firewall for External Access
If you want to test your application on another device or access it over a local network (LAN), you need to allow incoming traffic through the firewall. Otherwise, the app may only work on your local machine and appear unreachable from external devices, even if it’s running correctly.
Use the following command to allow traffic on port 3000.
sudo ufw allow 3000/tcp
10. Install a Code Editor (e.g., VS Code)
Using a feature-rich code editor improves your development experience with tools like syntax highlighting, linting, debugging, and built-in Git integration. One of the most popular editors for Node.js development is Visual Studio Code (VS Code), which offers a rich extension marketplace and seamless terminal support.
To install it via Snap, use the following command.
sudo snap install code --classic
How to Set Up a Linux Development Environment for Python?
Python is a widely used, beginner-friendly programming language known for its simplicity and versatility. Whether you’re building web applications, writing scripts for automation, or exploring data science, setting up a reliable Python development environment on Linux is essential.
This guide walks you through the fundamental steps to prepare your system, install Python and pip, isolate project environments, and get started with code, all tailored for a Linux (Debian-based) system.
1. Install Python 3 Using the Package Manager
Most Linux distributions come with Python pre-installed, but it’s good practice to ensure you have the latest supported version.
You can do this by running the following commands.
sudo apt update
sudo apt install python3
To verify the installation and check the version, use the command below. This ensures you`re working with Python 3.x, which is the standard for modern projects.
python3 --version
2. Install pip (Python Package Installer)
pip is used to install third-party libraries and tools from the Python Package Index (PyPI).
To install and verify the installation, use the following commands.
sudo apt install python3-pip
pip3 --version
