How to Install Hadoop on Ubuntu: Download & Setup Steps

โšก Smart Summary

Installing Apache Hadoop on Ubuntu takes two passes: unpack the release under a dedicated system account with passwordless SSH, then edit four XML files before formatting HDFS and starting the single-node cluster.

  • ๐Ÿ”˜ Prerequisites: A running Ubuntu machine and a supported Java Development Kit must be in place first.
  • โ˜‘๏ธ Dedicated account: Create the hadoop_ group and hduser_ account so daemons never run as your login user.
  • โœ… Passwordless SSH: Hadoop starts daemons over SSH, so ssh localhost must succeed without a password prompt.
  • ๐Ÿงช Four config files: hadoop-env.sh, core-site.xml, mapred-site.xml and hdfs-site.xml carry every setting this walkthrough changes.
  • ๐Ÿ› ๏ธ First start: Format the NameNode once, then run start-dfs.sh and start-yarn.sh and confirm five daemons with jps.
  • ๐Ÿงญ Version drift: Screenshots use Hadoop 2.2.0, so check the release, ports and property names against Hadoop 3.x.

How to Install Hadoop on Ubuntu

In this tutorial, we will take you through the step by step process to install Apache Hadoop on a Linux box (Ubuntu). This is a two-part process: first download and install the release, then configure it.

There are two prerequisites:

Hadoop 3.x Version Notes for This Setup

The screenshots in this walkthrough were captured on Hadoop 2.2.0. The sequence of steps is unchanged on current releases, but a handful of names and defaults have moved. Check the table below before copying any command verbatim.

Setting or step In this tutorial (Hadoop 2.x) Current Hadoop 3.x
Release archive hadoop-2.2.0.tar.gz hadoop-3.5.0.tar.gz, the first stable 3.5 release, published 2 April 2026
Default file system property fs.default.name in the prose, fs.defaultFS in the XML fs.defaultFS only; fs.default.name is deprecated
MapReduce property mapreduce.jobtracker.address mapreduce.framework.name set to yarn; the JobTracker no longer exists once YARN schedules the work
mapred-site.xml Copied from mapred-site.xml.template Ships in etc/hadoop already, so the copy step is unnecessary
NameNode web UI port 50070 9870
Java Java 6 or Java 7 Java 8 or Java 11

Everything else in this guide behaves the same way on Hadoop 3: the dedicated account, the SSH key, the four configuration files, and the start and stop scripts.

Part 1) Download and Install Hadoop

Step 1) Add a Hadoop system user

Add a Hadoop system user using the command below.

sudo addgroup hadoop_

Terminal running sudo addgroup hadoop_

sudo adduser --ingroup hadoop_ hduser_

adduser prompt collecting the details for hduser_

Enter your password, name and other details.

NOTE: There is a possibility of the below-mentioned error in this setup and installation process.

“hduser is not in the sudoers file. This incident will be reported.”

Error message: hduser is not in the sudoers file

This error can be resolved by logging in as the root user.

Switching to the root user in the terminal

Execute the command

sudo adduser hduser_ sudo

Adding hduser_ to the sudo group

Re-login as hduser_

Re-logging in as hduser_

Step 2) Configure SSH

In order to manage nodes in a cluster, Hadoop requires SSH access.

First, switch user, enter the following command

su - hduser_

Switching user with su - hduser_

This command will create a new key.

ssh-keygen -t rsa -P ""

ssh-keygen generating an RSA key pair for hduser_

Enable SSH access to the local machine using this key.

cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys

Appending id_rsa.pub to the authorized_keys file

Now test the SSH setup by connecting to localhost as the ‘hduser_’ user.

ssh localhost

Successful ssh localhost session for hduser_

Note: If you see the error below in response to ‘ssh localhost’, then there is a possibility that SSH is not available on this system.

ssh localhost failing with a connection refused error

To resolve this –

Purge SSH using,

sudo apt-get purge openssh-server

It is good practice to purge before starting the installation.

apt-get purge removing an existing openssh-server package

Install SSH using the command-

sudo apt-get install openssh-server

apt-get installing the openssh-server package

Step 3) Download Hadoop

The next step is to download Hadoop from the Apache Hadoop releases page.

Apache Hadoop releases page listing available versions

Select Stable

Directory listing for the stable Hadoop release

Select the tar.gz file (not the file ending in src).

Choosing the Hadoop tar.gz binary instead of the src archive

Once the download is complete, navigate to the directory containing the tar file.

Terminal opened in the directory holding the downloaded tar file

Enter,

sudo tar xzf hadoop-2.2.0.tar.gz

Extracting the Hadoop tarball with tar xzf

Now, rename hadoop-2.2.0 as hadoop.

sudo mv hadoop-2.2.0 hadoop

Renaming the extracted hadoop-2.2.0 folder to hadoop

Finally, hand the folder to the new account.

sudo chown -R hduser_:hadoop_ hadoop

chown assigning the hadoop folder to hduser_ and hadoop_

Substitute the version you actually downloaded for hadoop-2.2.0 in the three commands above.

Part 2) Configure Hadoop

Step 1) Modify the ~/.bashrc file

Add the following lines to the end of the file ~/.bashrc.

#Set HADOOP_HOME
export HADOOP_HOME=<Installation Directory of Hadoop>
#Set JAVA_HOME
export JAVA_HOME=<Installation Directory of Java>
# Add bin/ directory of Hadoop to PATH
export PATH=$PATH:$HADOOP_HOME/bin

bashrc file with the HADOOP_HOME, JAVA_HOME and PATH exports appended

Now, source this environment configuration using the command below.

. ~/.bashrc

Sourcing bashrc so the new environment variables take effect

Step 2) Configurations related to HDFS

Set JAVA_HOME inside the file $HADOOP_HOME/etc/hadoop/hadoop-env.sh, shown below.

The default JAVA_HOME line inside hadoop-env.sh

hadoop-env.sh opened in the editor showing the JAVA_HOME export

With

hadoop-env.sh JAVA_HOME replaced with the real Java installation path

There are two parameters in $HADOOP_HOME/etc/hadoop/core-site.xml which need to be set-

1. ‘hadoop.tmp.dir’ – Used to specify a directory which will be used by Hadoop to store its data files.

2. ‘fs.defaultFS’ – This specifies the default file system. The older name for the same property, ‘fs.default.name’, is deprecated.

To set these parameters, open core-site.xml

sudo gedit $HADOOP_HOME/etc/hadoop/core-site.xml

Opening core-site.xml with gedit

Copy the lines below in between the <configuration></configuration> tags.

<property>
<name>hadoop.tmp.dir</name>
<value>/app/hadoop/tmp</value>
<description>Parent directory for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS </name>
<value>hdfs://localhost:54310</value>
<description>The name of the default file system. </description>
</property>

core-site.xml holding the hadoop.tmp.dir and fs.defaultFS properties

Navigate to the directory $HADOOP_HOME/etc/hadoop.

Terminal inside the Hadoop etc/hadoop configuration directory

Now, create the directory mentioned in core-site.xml.

sudo mkdir -p <Path of Directory used in above setting>

mkdir -p creating the hadoop.tmp.dir path

Grant permissions to the directory.

sudo chown -R hduser_:Hadoop_ <Path of Directory created in above step>

chown granting hduser_ ownership of the temporary directory

sudo chmod 750 <Path of Directory created in above step>

chmod 750 applied to the temporary directory

Step 3) MapReduce Configuration

Before you begin with these configurations, let us set the HADOOP_HOME path.

sudo gedit /etc/profile.d/hadoop.sh

And Enter

export HADOOP_HOME=/home/guru99/Downloads/Hadoop

hadoop.sh profile script exporting HADOOP_HOME

Next enter

sudo chmod +x /etc/profile.d/hadoop.sh

chmod +x making the hadoop.sh profile script executable

Exit the Terminal and restart again.

Type echo $HADOOP_HOME to verify the path.

echo $HADOOP_HOME printing the configured installation path

Now copy files

sudo cp $HADOOP_HOME/etc/hadoop/mapred-site.xml.template $HADOOP_HOME/etc/hadoop/mapred-site.xml

Copying mapred-site.xml.template to mapred-site.xml

Open the mapred-site.xml file

sudo gedit $HADOOP_HOME/etc/hadoop/mapred-site.xml

Opening mapred-site.xml with gedit

Add the settings below in between the <configuration> and </configuration> tags.

<property>
<name>mapreduce.jobtracker.address</name>
<value>localhost:54311</value>
<description>MapReduce job tracker runs at this host and port.
</description>
</property>

mapred-site.xml holding the MapReduce job tracker property

Open $HADOOP_HOME/etc/hadoop/hdfs-site.xml as below,

sudo gedit $HADOOP_HOME/etc/hadoop/hdfs-site.xml

Opening hdfs-site.xml with gedit

Add the settings below between the <configuration> and </configuration> tags.

<property>
<name>dfs.replication</name>
<value>1</value>
<description>Default block replication.</description>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/home/hduser_/hdfs</value>
</property>

hdfs-site.xml holding the dfs.replication and dfs.datanode.data.dir properties

Create the directory specified in the setting above.

sudo mkdir -p <Path of Directory used in above setting>
sudo mkdir -p /home/hduser_/hdfs

mkdir -p creating the DataNode data directory

Then grant ownership and permissions on it.

sudo chown -R hduser_:hadoop_ <Path of Directory created in above step>
sudo chown -R hduser_:hadoop_ /home/hduser_/hdfs

chown granting hduser_ ownership of the DataNode data directory

sudo chmod 750 <Path of Directory created in above step>
sudo chmod 750 /home/hduser_/hdfs

chmod 750 applied to the DataNode data directory

Step 4) Format HDFS

Before we start Hadoop for the first time, format HDFS using the command below.

$HADOOP_HOME/bin/hdfs namenode -format

hdfs namenode -format output formatting the new file system

Step 5) Start the Hadoop single node cluster

Start the Hadoop single node cluster using the command below.

$HADOOP_HOME/sbin/start-dfs.sh

The output of the command above is shown below.

start-dfs.sh output starting the NameNode and DataNode

Then start the YARN daemons.

$HADOOP_HOME/sbin/start-yarn.sh

start-yarn.sh output starting ResourceManager and NodeManager

Using the ‘jps’ tool, verify whether all the Hadoop-related processes are running.

jps output listing the five running Hadoop daemons

If Hadoop has started successfully, the jps output should list NameNode, NodeManager, ResourceManager, SecondaryNameNode, and DataNode.

Step 6) Stopping Hadoop

Shut the cluster down in the reverse order.

$HADOOP_HOME/sbin/stop-dfs.sh

stop-dfs.sh output shutting down the HDFS daemons

$HADOOP_HOME/sbin/stop-yarn.sh

stop-yarn.sh output shutting down the YARN daemons

How to Verify Hadoop Is Running and Fix Common Errors

The jps output confirms that processes started, but not that the cluster is usable. Four extra checks settle that question.

  • Open the NameNode web interface at http://localhost:9870 (port 50070 on Hadoop 2.x) and confirm the summary reports one live node.
  • Open the ResourceManager interface at http://localhost:8088 to confirm YARN accepted the NodeManager.
  • Run hdfs dfsadmin -report for capacity, live DataNodes and any under-replicated blocks.
  • Write something: hdfs dfs -mkdir /test followed by hdfs dfs -ls / proves the namespace accepts changes.

Most first-time failures fall into one of five buckets.

Symptom Cause Fix
JAVA_HOME is not set and could not be found The variable is exported in .bashrc but not in hadoop-env.sh Set the absolute JDK path inside hadoop-env.sh as well
Permission denied (publickey,password) on ssh localhost authorized_keys is missing or too permissive Re-append id_rsa.pub, then run chmod 600 on ~/.ssh/authorized_keys
Connection refused on port 22 openssh-server is not installed or not running Install openssh-server and start the ssh service
DataNode missing from jps after a re-format Cluster ID mismatch between the formatted NameNode and the old DataNode directory Empty the dfs.datanode.data.dir folder, then format once more
start-dfs.sh: command not found HADOOP_HOME and PATH were never sourced in the current shell Run . ~/.bashrc or open a fresh terminal

FAQs

Any actively supported Ubuntu LTS release works, including 22.04 and 24.04. Hadoop 3.x is built and tested against Java 8 and Java 11, so install one of those JDKs; newer JDKs are not fully supported and older Java 7 builds no longer apply.

The start-dfs.sh and start-yarn.sh scripts launch every daemon through SSH, even when the only host is localhost. Without a passwordless key the scripts stall on a password prompt and no daemon comes up.

hadoop.tmp.dir is the base scratch path Hadoop derives other temporary locations from. dfs.datanode.data.dir is where a DataNode keeps real block files. Point the second at durable storage, never at /tmp, or blocks vanish on reboot.

Format once, before the first start. Re-running the format wipes the namespace and leaves existing DataNode directories carrying an older cluster ID, which is why the DataNode then refuses to register and disappears from the jps output.

Yes, though Windows needs the winutils.exe and hadoop.dll native binaries for the matching release. Most people avoid that by running the same Ubuntu steps inside WSL 2, which behaves like a normal Linux host.

For learning, yes: a prebuilt image skips user creation, SSH keys and XML editing. Installing by hand is still worth doing once, because it shows which file controls each setting when a real cluster misbehaves.

Machine learning models over NameNode and YARN metrics forecast capacity limits, spot skewed jobs and flag failing disks early. Several platforms also recommend container sizes automatically, replacing much of the manual tuning this configuration once required.

Copilot drafts core-site.xml and hdfs-site.xml property blocks quickly and remembers exact spellings. Verify each suggestion against the documentation for your release, because it often proposes retired properties such as mapreduce.jobtracker.address or fs.default.name.

Summarize this post with: