Prerequisites: Linux, Java and SSH

Hadoop is a set of Java programs that run on Linux and start each other over SSH. Miss any one of those three and nothing starts. This lesson prepares a fresh Ubuntu or WSL machine step by step, checks it with a real script (shown before and after), and explains the three error messages beginners see most often, so that installing Hadoop in Lesson 4.3 goes smoothly.

Module 4 · Setup⏱ 24 minBeginnerTested on Ubuntu 24.04Real terminal outputRuns in your browser (Python)8 practice problems
1 The story

Three things Hadoop needs before it will even start

Riya downloads Hadoop 3.5.0 onto her Windows laptop, double-clicks the file, and nothing useful happens. Kabir tries on his old Ubuntu laptop: start-dfs.sh prints ERROR: JAVA_HOME is not set and could not be found three times. Then Permission denied (publickey,password). They come to Arjun Sir, frustrated. “Hadoop is broken!”

Hadoop 3.5.0 1. LinuxUbuntu, or WSL 2 on Windowsshell, files, users, paths 2. Java 17 (JDK)every daemon is a Java programJAVA_HOME must point to it 3. SSHstart scripts log in to each nodepasswordless keys Get these three right and the install takes ten minutes. Skip one and you get cryptic errors. myphatshala.in
Arjun Sir

Hadoop isn't broken. It's standing on three legs, and each of you is missing one.

Riya

Which ones?

Arjun Sir

Riya, Hadoop is built for Linux. On Windows you'll use WSL, which gives you a real Ubuntu inside Windows. Kabir, Hadoop's daemons are Java programs, and the start scripts couldn't find your Java because JAVA_HOME wasn't set where they look. And that “Permission denied” is SSH: start-dfs.sh logs in to every node, even when the only node is your own laptop, and it needs to do that without a password.

Kabir

So: Linux, Java, SSH.

Arjun Sir

Exactly. Today we prepare all three, check them with one script, and learn just enough Linux to feel at home. In the next two lessons, the actual install will then just work. Every error message you saw today has a one-line fix, and you'll know it.

2 Definition

Hadoop's prerequisites

Formal definition (write this in exams)

Apache Hadoop requires: (1) a supported operating system, in practice Linux (GNU/Linux is the supported production platform; on Windows, WSL 2 or a virtual machine provides a Linux environment); (2) a Java Development Kit of a supported version: for Hadoop 3.5 the server daemons require JDK 17 (clients support JDK 17 and 21), while Hadoop 3.3 and 3.4 run on Java 8 or 11; the JAVA_HOME environment variable must point to it, typically set in etc/hadoop/hadoop-env.sh; and (3) SSH with an sshd service running and passwordless key-based login from the master to every node (including localhost), because the cluster start/stop scripts use SSH to launch remote daemons.

In simple words

You need a Linux machine (or Ubuntu inside Windows), Java 17 installed and its location written in Hadoop's settings, and SSH set up so your computer can log in to itself without asking for a password. Then Hadoop's start scripts can do their job.

Words you'll meet in this lesson

WSL 2Windows Subsystem for Linux: runs a real Linux (e.g. Ubuntu) inside Windows 10/11.
JDKJava Development Kit: the Java runtime plus compiler and tools like jps.
JAVA_HOMEEnvironment variable holding the Java install folder, e.g. /usr/lib/jvm/java-17-openjdk-amd64.
Environment variableA named value the shell passes to programs, set with export NAME=value.
PATHThe list of folders the shell searches for commands. Add Hadoop's bin and sbin so hdfs works anywhere.
~/.bashrcA script that runs every time you open a terminal. Put your export lines here so they persist.
SSHSecure Shell: log in to and run commands on another machine over the network.
Key pairA private key (kept secret) and public key (copied to ~/.ssh/authorized_keys) that allow login without a password.

What you need (Hadoop 3.5.0, practice setup)

Operating systemUbuntu 22.04/24.04, or Windows 10/11 with WSL 2 + Ubuntu, or macOS (works, but less common)
JavaOpenJDK 17 for Hadoop 3.5 (the official apache/hadoop:3.5.0 Docker image also uses Java 17). For Hadoop 3.3/3.4: Java 8 or 11.
RAM8 GB minimum to run all daemons comfortably on one machine; 16 GB is pleasant
Diskabout 2 GB for Hadoop itself (0.6 GB download, 1.3 GB unpacked) plus space for your data and logs; keep 10 GB+ free
Packagesopenjdk-17-jdk-headless, openssh-server, openssh-client (and wget or curl)
Downloadhadoop-3.5.0.tar.gz from dlcdn.apache.org, about 580 MB; verify its SHA-512 checksum

Source for the Java requirement: the Apache Hadoop “Hadoop Java Versions” wiki page. Always check it before installing a new release.

Prerequisites at three levels

Pick your level. New to this? Start at Beginner and climb.

Beginner Cooking needs a kitchen, gas and a key

  • Linux is the kitchen Hadoop was designed for. Windows users borrow a Linux kitchen through WSL.
  • Java is the gas: no daemon can “cook” without it, and Hadoop must know which cylinder to use (JAVA_HOME).
  • SSH is a master key: the head chef (start script) walks into every room (node) to switch things on, without knocking each time.

Intermediate The Linux you actually need

  • Move around: pwd, ls -l, cd, mkdir -p.
  • Files: cat, less, nano (to edit XML), cp, mv, tar -xzf.
  • Install software: sudo apt update, sudo apt install ….
  • Variables: export JAVA_HOME=…, echo $JAVA_HOME, add lines to ~/.bashrc, then source ~/.bashrc.
  • Processes: jps (Java processes), ps aux | grep java, kill.
  • Logs: tail -f on files in $HADOOP_HOME/logs.

Advanced Why SSH, and when you don't need it

  • start-dfs.sh reads the workers file and runs ssh <host> hdfs --daemon start datanode for each host. On one machine, the only host is localhost, so SSH still runs.
  • You can skip SSH by starting each daemon yourself: hdfs --daemon start namenode, hdfs --daemon start datanode, yarn --daemon start resourcemanager… This is how containers and cluster managers start Hadoop.
  • Keys must be protected: ~/.ssh should be 700 and authorized_keys 600, or sshd refuses them.
  • In production, Hadoop runs as dedicated service users (hdfs, yarn, mapred), and configuration management or Cloudera Manager/Ambari handles start-up, not hand-made keys.
  • Hadoop 3.5's requirement of JDK 17 for servers is a real break from older releases; a cluster upgrade usually starts with a Java upgrade.

Exam tip: For “List the prerequisites for installing Hadoop”, write: Linux OS (or a Linux VM/WSL), Java (JDK) of a supported version with JAVA_HOME set (in hadoop-env.sh), SSH with passwordless login to all nodes, enough RAM and disk, and the Hadoop binary tarball. One line on why each is needed earns full marks.

3 Types and ways to use it

Four ways to get a Linux environment for Hadoop

Native UbuntuWSL 2 on WindowsDocker (any OS)Virtual machine
Set-up effortLow if you already use LinuxLow: one command in PowerShellLow: Docker Desktop + one fileMedium: install VirtualBox + Ubuntu
Feels likeA real serverA real Ubuntu terminal inside WindowsA ready-made multi-node clusterA separate computer
Learn installation steps?YesYesNo: images come pre-installedYes
Multi-node practiceHard on one PCHardEasy (3 DataNodes in seconds)Possible with several VMs, heavy
RAM needed8 GB+8 GB+8 GB+ (16 better)12 GB+
Used in this courseLesson 4.3Lesson 4.3Lesson 4.3 (main practice cluster)Not covered

Which Java for which Hadoop?

Hadoop 3.5.x

Servers (NameNode, DataNode, YARN…) require JDK 17. Clients support JDK 17 and 21.

This course

Hadoop 3.3 / 3.4

Java 8, and Java 11 as a runtime. Many company clusters still run these.

Common at work

Hadoop 3.0–3.2

Java 8.

Older

Hadoop 2.x

Java 7 or 8. Out of maintenance: upgrade.

Legacy

Install the JDK (with jps and javac), not just a JRE. jps is your most-used Hadoop debugging command, and you'll compile Java MapReduce jobs from Module 8.

4 Step by step

Prepare a fresh Ubuntu (or WSL) for Hadoop

  1. Windows only: install WSL 2 with Ubuntu

    wsl --install -d Ubuntu-24.04
    Restart when asked, open “Ubuntu” from the Start menu and create a Linux user name and password. From now on, every command runs in that Ubuntu terminal.
  2. Install Java 17 and SSH

    sudo apt update
    sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client wget
    headless means no graphical parts, which servers don't need. openssh-server provides sshd, which the start scripts connect to.
  3. Find where Java lives

    java -version
    readlink -f $(which java)
    openjdk version "17.0.20.1" 2026-08-18 OpenJDK Runtime Environment (build 17.0.20.1+1-1-24.04-Ubuntu) OpenJDK 64-Bit Server VM (build 17.0.20.1+1-1-24.04-Ubuntu, mixed mode, sharing) /usr/lib/jvm/java-17-openjdk-amd64/bin/java
    JAVA_HOME is that path without /bin/java: /usr/lib/jvm/java-17-openjdk-amd64. The exact update number on your machine will differ.
  4. Set variables permanently

    export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
    export HADOOP_HOME=$HOME/hadoop-3.5.0
    export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
    Then run source ~/.bashrc. HADOOP_HOME points to where you'll unpack Hadoop in Lesson 4.3; adding bin and sbin to PATH lets you type hdfs and start-dfs.sh from any folder.
  5. Start the SSH server

    sudo service ssh start
    On WSL, services don't always start automatically: run this each time you open Ubuntu (or enable systemd in WSL). Passwordless keys are set up in Lesson 4.3, right before the first start-dfs.sh.
5 See it happen

Kabir's three errors: what he sees, and what is really missing

Every message on the left is real output from Hadoop 3.5.0 on Ubuntu 24.04. On the right: which leg was missing.

From errors to a ready machine 6 steps
What you see kabir@laptop : ~ $ java -versionCommand 'java' not found, but can beinstalled with: sudo apt install … $ sudo apt install -y openjdk-17-jdk-headless$ java -versionopenjdk version "17.0.20.1" … $ start-dfs.shStarting namenodes on [localhost]localhost: ERROR: JAVA_HOME is not setand could not be found. $ echo "export JAVA_HOME=/usr/lib/jvm/ java-17-openjdk-amd64" >> \ $HADOOP_HOME/etc/hadoop/hadoop-env.shTell Hadoop itself where Java is. $ ssh localhostkabir@localhost: Permission denied(publickey,password). $ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys$ ssh localhost "echo connected"connectedAll three legs ready. myphatshala.in
Behind the screen Hadoop 3.5.0 Linux✓ Ubuntu Java 17 SSH ✕ missing? ✓ installed JAVA_HOME unknown daemons start in a fresh shell over SSHand don't see your terminal's variables ✓ installed✓ in hadoop-env.sh every daemon now reads JAVA_HOME from Hadoop's own file ✕ no keysshd refuses: no authorised key, no password for scripts ✓ key authorisedthree legs ready: install Hadoop (Lesson 4.3) myphatshala.in
6 Real-world use

Prerequisites at work

JDK 8 → 17upgrade first

1. Upgrades start with Java

Moving a cluster to Hadoop 3.5 means moving every server to JDK 17 first, and checking that Hive, Spark and custom jobs work on it. Java versions are often the longest part of an upgrade plan.

Old JDK→Test on JDK 17→Then upgrade Hadoop
Ansible200 servers

2. Automating prerequisites on hundreds of servers

Platform teams don't install Java and SSH keys by hand. Tools like Ansible (or the cluster manager) install the same JDK, users, keys and kernel settings on every node, so all nodes are identical.

Playbook→Same setup on every node→No surprises
WinWSL

3. Laptops of data engineers

Many engineers on Windows laptops use WSL 2 for daily data work: Hadoop and Spark clients, Python, Git, Docker. It gives the same Linux commands as the servers they deploy to.

Windows laptop→Ubuntu on WSL→Same as servers
hdfs · yarnmapred users

4. Service users instead of personal accounts

In production, NameNode and DataNodes run as the hdfs user, YARN as yarn, and history as mapred. Each has only the permissions it needs, which limits damage if one is compromised.

One daemon→Its own Linux user→Least privilege

Simplified; organisations differ in tools and policies.

7 Run the code

A prerequisite checker in Python

Real tools such as Ambari and Cloudera Manager run host checks before installing anything. This small version reads facts about a machine (here typed in as a dictionary) and reports what is missing. Run it, then try the challenges.

machine = {
    "os": "Ubuntu 24.04.5 LTS",
    "java": 'openjdk version "17.0.20.1" 2026-08-18',
    "java_home": "/usr/lib/jvm/java-17-openjdk-amd64",
    "ram_gb": 7.8,
    "disk_free_gb": 19,
    "ssh_server": True,
    "passwordless_ssh": False,
}

def java_major(line):
    version = line.split('"')[1]          # 17.0.20.1
    first = version.split(".")[0]          # 17
    return int(first)

problems = []
if java_major(machine["java"]) < 17:
    problems.append("Hadoop 3.5 needs Java 17")
if not machine["java_home"]:
    problems.append("JAVA_HOME is not set")
if machine["ram_gb"] < 8:
    problems.append("less than 8 GB RAM: run fewer daemons")
if machine["disk_free_gb"] < 10:
    problems.append("less than 10 GB free disk")
if not machine["ssh_server"]:
    problems.append("install openssh-server")
if not machine["passwordless_ssh"]:
    problems.append("set up passwordless SSH keys")

print("Java major version:", java_major(machine["java"]))
for p in problems:
    print("FIX:", p)
print("Ready!" if not problems else f"{len(problems)} thing(s) to fix")
Java major version: 17 FIX: less than 8 GB RAM: run fewer daemons FIX: set up passwordless SSH keys 2 thing(s) to fix
  • "java": 'openjdk version "17.0.20.1" 2026-08-18',This is the exact first line that java -version printed on our test machine.
  • version = line.split('"')[1] # 17.0.20.1Splitting on the double quote gives three pieces; the version is the middle one.
  • first = version.split(".")[0] # 17The major version is the part before the first dot. (Old Java 8 printed 1.8.0_…; challenge 3 handles that.)
  • if machine["ram_gb"] < 8:7.8 GB shows up as “less than 8” because the operating system reserves a little memory. Hadoop still runs; you just run fewer things at once.
  • print("Ready!" if not problems else f"{len(problems)} thing(s) to fix")An empty list counts as False in Python, so not problems means “nothing to fix”.

Run it on your machine: is it ready for Hadoop?

This shell script checks everything from Part 4 in one go. Save it in your Ubuntu or WSL home folder as check_prereqs.sh and run it before and after the install steps. Both outputs below are from a real run on a fresh Ubuntu 24.04 machine.

Before: a fresh Ubuntu 24.04

#!/usr/bin/env bash
# check_prereqs.sh: is this Linux / WSL machine ready for Hadoop 3.5?
echo "== Operating system";  grep PRETTY_NAME /etc/os-release | cut -d= -f2
echo "== CPU cores";         nproc
echo "== Memory";            free -h | awk '/Mem:/ {print $2 " total, " $7 " available"}'
echo "== Free disk in HOME"; df -h "$HOME" | awk 'NR==2 {print $4 " free"}'
echo "== Java";              if command -v java >/dev/null; then java -version 2>&1 | head -1; else echo "NOT INSTALLED"; fi
echo "== JAVA_HOME";         echo "${JAVA_HOME:-not set}"
echo "== SSH client";        command -v ssh >/dev/null && echo "installed" || echo "NOT INSTALLED"
echo "== SSH server";        (command -v sshd >/dev/null || [ -x /usr/sbin/sshd ]) && echo "installed" || echo "NOT INSTALLED"
echo "== Passwordless SSH to localhost"
if ssh -o BatchMode=yes -o ConnectTimeout=3 localhost true 2>/dev/null; then echo "OK"; else echo "NOT YET (set up keys in Lesson 4.3)"; fi

# In the Ubuntu / WSL terminal:
#   bash check_prereqs.sh
== Operating system "Ubuntu 24.04.5 LTS" == CPU cores 2 == Memory 7.8Gi total, 7.1Gi available == Free disk in HOME 19G free == Java NOT INSTALLED == JAVA_HOME not set == SSH client NOT INSTALLED == SSH server NOT INSTALLED == Passwordless SSH to localhost NOT YET (set up keys in Lesson 4.3)

A brand-new Ubuntu has no Java and no SSH. The memory and disk lines will show your own machine's numbers.

After: the steps from Part 4 done

sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client
source ~/.bashrc
sudo service ssh start
# keys from Lesson 4.3, then:
bash check_prereqs.sh
== Operating system "Ubuntu 24.04.5 LTS" == CPU cores 2 == Memory 7.8Gi total, 7.1Gi available == Free disk in HOME 19G free == Java openjdk version "17.0.20.1" 2026-08-18 == JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 == SSH client installed == SSH server installed == Passwordless SSH to localhost OK

Every line is now green. The last line needs the SSH keys from Lesson 4.3; it is included here so you can re-use the same script later. Your Java patch number may be newer than 17.0.20.1.

8 Line by line

Reading a version string, one step at a time

Follow the real java -version line through the parser and watch each variable change in memory.

Worked examples: real problems, solved and traced in memory

Three jobs a Hadoop admin really does before installing: checking a list of machines, sizing memory for the daemons, and generating the environment lines every node needs. Each runs live and is traced in memory.

Example 1BeginnerAdmin · host check

Which lab machines are ready?

Problem statement

A college lab has four machines. Each needs Java 17 or newer, at least 8 GB RAM and 20 GB of free disk to join the Hadoop practice cluster. List which are ready and what each of the others is missing.

Input
lab1: Java 17, 16 GB, 120 GB · lab2: Java 11, 16 GB, 80 GB · lab3: Java 17, 4 GB, 50 GB · lab4: Java 21, 32 GB, 10 GB
Expected output
lab1: ready
lab2: needs Java 17
lab3: needs RAM
lab4: needs disk

Approach

  1. Store each machine as a tuple of (java, ram, disk).
  2. Check the three rules and collect what fails.
  3. Print “ready” or the list of problems.

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

Example 2IntermediateAdmin · memory sizing

Will the daemons fit in RAM?

Problem statement

A pseudo-distributed setup runs NameNode, DataNode, SecondaryNameNode, ResourceManager, NodeManager and the JobHistory Server on one 8 GB laptop. Each daemon is given a 1 GB Java heap, the operating system needs 2 GB, and each task container needs 1 GB. How many containers can run at once?

Input
8 GB RAM · 6 daemons × 1 GB · OS 2 GB · 1 GB per container
Expected output
Daemons + OS use 8 GB, 0 GB left -> 0 containers at a time

Approach

  1. Add up daemon heaps and the OS.
  2. Subtract from total RAM.
  3. Whole containers that fit = floor(left / 1 GB).

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

Example 3AdvancedAutomation · config

Generate the environment lines for every node

Problem statement

A team sets up 5 worker nodes. Each node's ~/.bashrc needs JAVA_HOME, HADOOP_HOME and a PATH line, and the Java folder differs by CPU type: amd64 on Intel/AMD machines, arm64 on ARM machines. Generate the lines for each node from a table, the way automation tools do.

Input
w1–w3: amd64 · w4–w5: arm64 · Hadoop in /opt/hadoop-3.5.0
Expected output
# w1
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export HADOOP_HOME=/opt/hadoop-3.5.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# w2
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export HADOOP_HOME=/opt/hadoop-3.5.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# w3
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export HADOOP_HOME=/opt/hadoop-3.5.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# w4
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64
export HADOOP_HOME=/opt/hadoop-3.5.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# w5
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64
export HADOOP_HOME=/opt/hadoop-3.5.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

Approach

  1. Keep the per-node difference (CPU type) in data.
  2. Build the lines from one template.
  3. Print them per node so they can be copied or pushed by a tool.

Solution: run it live

What happens in memory, step by step

Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.

9 Quiz and revision

Check yourself

Quick revision

Lesson 4.1 in one screen

  • Hadoop needs three things: Linux, Java and SSH.
  • Java: Hadoop 3.5 servers need JDK 17 (clients 17 or 21); Hadoop 3.3/3.4 run on Java 8 or 11.
  • JAVA_HOME = the folder above bin/java, e.g. /usr/lib/jvm/java-17-openjdk-amd64.
  • Set JAVA_HOME in ~/.bashrc and in etc/hadoop/hadoop-env.sh (SSH sessions skip your shell settings).
  • SSH: start scripts log in to every host in workers, even localhost. Keys must be passwordless.
  • Windows: use WSL 2 + Ubuntu or Docker. Linux PC: Ubuntu LTS directly.
  • Install: sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client wget.
  • Practical minimum: 8 GB RAM (16 GB comfortable), ~20 GB free disk.
  • Check with java -version, echo $JAVA_HOME, ssh localhost, and jps after start-up.

Interview and viva questions

Can Hadoop run on Windows?

Hadoop can be built for Windows, but it needs extra native files (winutils) and is not how companies run it. For learning, use WSL 2 with Ubuntu or Docker on Windows; in production, Hadoop runs on Linux.

Which Java should I install for Hadoop?

Match the Hadoop version. Hadoop 3.5 requires JDK 17 on the server side (clients may use 17 or 21). Hadoop 3.3 and 3.4 support Java 8 and 11 at runtime. Check the “Hadoop Java Versions” page on the Apache wiki for the version you install.

Why does Hadoop need SSH?

Only the convenience start and stop scripts (start-dfs.sh, start-yarn.sh) use it: they SSH into every host listed in the workers file to start or stop the daemons. Daemons can also be started on each node directly with “hdfs --daemon start datanode”, which is what service managers and containers do.

What is the difference between the JDK and the JRE?

The JRE only runs Java programs. The JDK adds development and diagnostic tools such as javac, jps and jstack. Install the JDK: jps is used constantly to check Hadoop daemons, and some tools need javac.

How do I find JAVA_HOME on Ubuntu?

Run readlink -f $(which java). It prints something like /usr/lib/jvm/java-17-openjdk-amd64/bin/java; JAVA_HOME is that path without the final /bin/java.

How much RAM do I need to practise Hadoop?

8 GB is a practical minimum for a single-machine (pseudo-distributed) setup with small jobs; 16 GB is comfortable. Each daemon is a separate Java process with its own heap, and each task runs in its own container.

Why “headless” Java?

The headless package leaves out graphical (desktop) libraries. Servers have no screen, so headless is smaller and has fewer security updates to track.

How do companies prepare hundreds of nodes?

They do not type commands by hand. A standard operating-system image, configuration management (Ansible, Puppet, Chef) or a cluster manager (Cloudera Manager, Ambari historically) installs the same Java, users, SSH keys, limits and settings on every node, and runs host checks before adding a node.

Practice problems

Small, practical exercises around versions, paths, memory and checks. Each can be run in the browser.

P1Easy

Strip /bin/java

Given the path /usr/lib/jvm/java-17-openjdk-amd64/bin/java, print JAVA_HOME.

Input
/usr/lib/jvm/java-17-openjdk-amd64/bin/java
Expected output
/usr/lib/jvm/java-17-openjdk-amd64
Show solution and explanation
p = "/usr/lib/jvm/java-17-openjdk-amd64/bin/java"
print(p.removesuffix("/bin/java"))
/usr/lib/jvm/java-17-openjdk-amd64

How it works: JAVA_HOME is /usr/lib/jvm/java-17-openjdk-amd64: the folder that contains bin/java.

P2Easy

Major version

Print the major version from the line openjdk version "17.0.20.1" 2026-08-18.

Input
openjdk version "17.0.20.1" 2026-08-18
Expected output
17
Show solution and explanation
line = 'openjdk version "17.0.20.1" 2026-08-18'
print(int(line.split('"')[1].split(".")[0]))
17

How it works: 17: the text between the quotes is 17.0.20.1, and the part before the first dot is 17.

P3Easy

Java for the version

Write a function that returns the server-side Java versions for Hadoop "3.4" and "3.5".

Input
"3.4" · "3.5"
Expected output
3.4 -> [8, 11]
3.5 -> [17]
Show solution and explanation
def java_for(hadoop):
    return {"3.3": [8, 11], "3.4": [8, 11], "3.5": [17]}[hadoop]
print("3.4 ->", java_for("3.4"))
print("3.5 ->", java_for("3.5"))
3.4 -> [8, 11] 3.5 -> [17]

How it works: Hadoop 3.4 runs on Java 8 or 11; Hadoop 3.5 servers require JDK 17.

P4Medium

Parse free -h

The memory line from free -h is "Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi". Print the total and available values (columns 2 and 7).

Input
Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi
Expected output
total 7.8Gi available 7.1Gi
Show solution and explanation
cols = "Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi".split()
print("total", cols[1], "available", cols[6])
total 7.8Gi available 7.1Gi

How it works: total 7.8Gi, available 7.1Gi. Python counts from 0, so column 2 is index 1 and column 7 is index 6, exactly what the awk in check_prereqs.sh prints.

P5Medium

Check a bashrc

Given the lines of a ~/.bashrc, report which of JAVA_HOME, HADOOP_HOME and PATH are exported.

Input
export JAVA_HOME=… · alias ll=…
Expected output
JAVA_HOME set
HADOOP_HOME MISSING
PATH MISSING
Show solution and explanation
bashrc = ["alias ll='ls -l'",
          "export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"]
for var in ["JAVA_HOME", "HADOOP_HOME", "PATH"]:
    found = any(l.startswith(f"export {var}=") for l in bashrc)
    print(var, "set" if found else "MISSING")
JAVA_HOME set HADOOP_HOME MISSING PATH MISSING

How it works: JAVA_HOME is set; HADOOP_HOME and PATH are missing. Add them as in Part 4, step 4.

P6Medium

Free-disk rule

A machine has 19 GB free. The Hadoop 3.5.0 download (0.6 GB) plus the unpacked folder (1.3 GB) plus at least 10 GB for HDFS data and logs are needed. Is there enough space, and how much is left over?

Input
19 GB free · 0.6 + 1.3 + 10 GB
Expected output
need 11.9 GB, enough: True, spare 7.1 GB
Show solution and explanation
need = 0.6 + 1.3 + 10
print(f"need {need:.1f} GB, enough: {19 >= need}, spare {19 - need:.1f} GB")
need 11.9 GB, enough: True, spare 7.1 GB

How it works: About 11.9 GB is needed, so 19 GB is enough with about 7.1 GB to spare. (The sizes are from the real 3.5.0 tarball and its unpacked folder.)

P7Business problem

Setup time saved by automation

Setting up one node by hand takes 45 minutes. An automated image takes 2 hours to build once and 5 minutes per node. For 40 nodes, how many hours does automation save?

Input
45 min/node by hand · 2 h + 5 min/node automated · 40 nodes
Expected output
by hand 30.0 h, automated 5.3 h, saved 24.7 h
Show solution and explanation
by_hand = 40 * 45 / 60
auto = 2 + 40 * 5 / 60
print(f"by hand {by_hand:.1f} h, automated {auto:.1f} h, saved {by_hand - auto:.1f} h")
by hand 30.0 h, automated 5.3 h, saved 24.7 h

How it works: By hand 30 h, automated about 5.3 h: about 24.7 hours saved, and every node is identical, which matters more than the time.

P8Advanced

Mixed-version cluster check

An upgrade plan to Hadoop 3.5 lists nodes and their Java versions. Print the nodes that would fail to start as servers and those that may only be clients.

Input
nn1: 17 · dn1: 11 · dn2: 17 · edge1: 21
Expected output
nn1    server Java 17: OK
dn1    server Java 11: UPGRADE JAVA
dn2    server Java 17: OK
edge1  client Java 21: OK
Show solution and explanation
nodes = {"nn1": ("server", 17), "dn1": ("server", 11),
         "dn2": ("server", 17), "edge1": ("client", 21)}
for name, (role, java) in nodes.items():
    ok = java == 17 if role == "server" else java in (17, 21)
    print(f"{name:6} {role:6} Java {java}: {'OK' if ok else 'UPGRADE JAVA'}")
nn1 server Java 17: OK dn1 server Java 11: UPGRADE JAVA dn2 server Java 17: OK edge1 client Java 21: OK

How it works: Only dn1 (a server on Java 11) must be upgraded before moving to 3.5. The edge node on Java 21 is fine as a client.

Real-world scenario questions (asked in company interviews)

Setup problems are a favourite in support and admin interviews: the interviewer shows an error and asks what you would check.

Admin · troubleshootingFresher

“java -version works, but start-dfs.sh says JAVA_HOME is not set”

A new team member runs start-dfs.sh and gets “localhost: ERROR: JAVA_HOME is not set and could not be found.” three times. In the same terminal, java -version prints Java 17.

The interviewer is checking: do you know that the daemons are started through SSH sessions that may not read your shell settings?

Show a strong answer
  • java being on the PATH is not the same as JAVA_HOME being set, and the start script runs commands over SSH, which may not load ~/.bashrc.
  • Find the folder with readlink -f $(which java) and remove /bin/java.
  • Set export JAVA_HOME=… in $HADOOP_HOME/etc/hadoop/hadoop-env.sh, so every daemon gets it.
  • Re-run start-dfs.sh and confirm with jps.
Admin · SSHFresher

“Permission denied (publickey,password)”

start-dfs.sh prints “localhost: Permission denied (publickey,password).” for the NameNode, DataNode and SecondaryNameNode.

The interviewer is checking: do you understand passwordless SSH and the files involved?

Show a strong answer
  • The script tried to log in to localhost without a password and was refused.
  • Check the SSH server is running (sudo service ssh status).
  • Create a key with ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa and append the public key to ~/.ssh/authorized_keys; set chmod 600 on that file.
  • Test with ssh localhost true: it must return without asking anything.
Platform · upgradeExperienced

Planning a move from Hadoop 3.4 to 3.5

Your company runs Hadoop 3.4 on Java 11 across 60 nodes and wants to upgrade to 3.5.

The interviewer is checking: do you know that 3.5 changes the Java requirement, and do you plan for it?

Show a strong answer
  • Hadoop 3.5 servers require JDK 17, so Java must be upgraded on every server node first; clients can use 17 or 21.
  • Check every application and library that runs inside the cluster (UDFs, custom jars, Spark/Hive versions) for Java 17 compatibility.
  • Upgrade a test cluster first, then roll out with the standard image or configuration management, so no node is missed.
  • Keep a rollback plan and run host checks before and after.
Learning · environmentFresher

“I only have a Windows laptop. How do I practise?”

A student with an 8 GB Windows laptop asks how to set up Hadoop for practice.

The interviewer is checking: can you suggest a realistic, low-cost setup?

Show a strong answer
  • Install WSL 2 with Ubuntu 24.04 (wsl --install -d Ubuntu-24.04); it is a real Linux kernel on Windows.
  • Inside Ubuntu, install JDK 17 and SSH, set JAVA_HOME, and run Hadoop in pseudo-distributed mode.
  • With 8 GB, keep jobs small and stop daemons you are not using; Docker images are an alternative if Docker Desktop is available.
  • Native Windows Hadoop is not worth the trouble for learning.