Install tools and make Node.js available in the terminal
🎯 Introduction
A server may have several Node.js versions installed. Which one runs when you type node? This article installs Node.js 24 LTS on Ubuntu, then uses one command to find the executable's path. Run all commands below on Ubuntu. If connecting from a Mac terminal, log in to Ubuntu first.
🧱 Install download tools with APT
Ubuntu uses APT to install software. Packages contain programs and installation metadata; package repositories supply those packages. Before installing anything, refresh APT's package lists. Ubuntu package management
sudo apt update
update refreshes the lists. To install programs, use install. Install three packages here: curl downloads files, ca-certificates helps verify HTTPS connections, and xz-utils decompresses the .tar.xz archive used later.
sudo apt install curl ca-certificates xz-utils
First confirm that curl runs. --version displays its version.
curl --version
If the first line starts with curl and a version, such as curl 8.5.0, continue to the Node.js download.
🧱 Choose the correct Ubuntu archive
The official Node.js binaries are already compiled and can run after extraction. This course uses the long-term support 24.x series. First identify Ubuntu's CPU architecture: separate archives are published for each architecture. Node.js releases
uname -m
| Output on Ubuntu | Archive name must contain |
|---|---|
x86_64 | linux-x64 |
aarch64 | linux-arm64 |
Choose the architecture from the table and find the corresponding Node.js 24.x archive in the official download directory. Select a filename ending in .tar.xz. Node.js 24 downloads
🛠 Download, verify, and extract
Identify the filename
Copy the archive link directly from the official download directory and note its filename. The example uses node-v24.22.2-linux-x64.tar.xz: v24.22.2 is the version and linux-x64 is the architecture. If you choose ARM64 or another 24.x version, use that filename consistently for downloading and extracting.
Download into your home directory
Create a dedicated directory for downloads.
mkdir -p "$HOME/linux-lab/downloads"
Enter it with cd so subsequent downloads are saved there.
cd "$HOME/linux-lab/downloads"
Download with curl. -f reports HTTP errors as failures, -L follows redirects, and -O saves using the final filename in the supplied URL.
curl -fLO https://nodejs.org/dist/v24.22.2/node-v24.22.2-linux-x64.tar.xz
After downloading, use ls to confirm that the chosen .tar.xz file is present.
Verify the downloaded file
The official SHASUMS256.txt lists a checksum for each file. A checksum is computed from file contents and lets you check that the download matches the list. Download the list for the same version. Verify Node.js binaries
curl -fLO https://nodejs.org/dist/v24.22.2/SHASUMS256.txt
If you chose another version, replace v24.22.2 in the URL accordingly. Check the download with sha256sum: -c checks against the list, and --ignore-missing skips other archives listed there that are not present.
sha256sum --ignore-missing -c SHASUMS256.txt
Extract only after OK appears next to your downloaded filename. The x64 example produces the following result. If you see FAILED or no result for your file, first check that the archive and checksum list belong to the same version.
node-v24.22.2-linux-x64.tar.xz: OK
Extract to the course runtime directory
Install Node.js in /opt/linux-course/runtime. Later, the system service will also start Node.js from here. After verification reports OK, create this directory with administrator privileges for the initial installation.
sudo mkdir -p /opt/linux-course/runtime
Extract with tar. -x extracts, -f specifies the downloaded archive, and -C selects the destination. The archive has an outer versioned directory; --strip-components=1 removes that level so node ends up in runtime/bin. --no-same-owner uses the extracting account's ownership.
sudo tar -xf node-v24.22.2-linux-x64.tar.xz --strip-components=1 --no-same-owner -C /opt/linux-course/runtime
Run this node executable by its full path to check the version.
/opt/linux-course/runtime/bin/node --version
For the example version, the output is v24.22.2. Node.js can now run. Next, make it available by its short command name.
🧰 Make node resolve to the installed executable
Environment variables are settings the shell can pass to programs. PATH contains an ordered list of directories separated by :. When you type node, the shell searches these directories in order and runs the first match.
Prepend the course's bin directory, preserving existing directories with $PATH. export passes the setting to programs launched from this terminal.
export PATH="/opt/linux-course/runtime/bin:$PATH"
Use command -v to see how the shell resolves this command. You can also use which node to inspect the file found on the search path.
command -v node
Expect this output.
/opt/linux-course/runtime/bin/node
This export applies only to the current terminal and programs it launches. To apply it to future interactive Bash sessions, open ~/.bashrc with Vim. Bash reads this file for interactive settings.
vim "$HOME/.bashrc"
Append export PATH="/opt/linux-course/runtime/bin:$PATH", save, open a new Ubuntu terminal, and verify with command -v node.
❓ Knowledge check
Q1: Why does the full path work while node reports command not found?
The full path identifies the program directly. With only node, the shell searches PATH. Check command -v node, then confirm that this terminal has the correct path setting.
Q2: Will system software updates also upgrade this Node.js installation?
sudo apt upgrade upgrades packages managed by APT. This course extracts an official Node.js archive into /opt/linux-course/runtime, so its version must be maintained separately.
🧪 Exercise
Open a new Ubuntu terminal and run command -v node, followed by node --version. The first should display /opt/linux-course/runtime/bin/node; the second should display your installed v24.x version. If the path differs, check the export line in ~/.bashrc, then open another terminal and test again.
🎉 You can now verify that the terminal runs the Node.js installation you intended!
