The fastest way to get comfortable with HDFS is to type the commands against a real cluster and read what comes back. This guide walks through the HDFS commands you will use every day, in the order you would use them on a real project, with the exact output we got from a Big Data Labs cluster on 14 November 2026. Your own output will differ in dates, sizes and user names, but the shape will be the same.
Everything below was run from a lab terminal as an ordinary student account, signed in with Kerberos. Student names in the output are replaced with vl0000.
If you don't have a cluster, you can run most of these on a single-node Hadoop install too. The difference shows up in a few places, which we point out: replication, block placement and the YARN node list.
Step 1: Where am I? Your HDFS home
hdfs dfs -ls with no path lists your home folder, /user/<your id>. A relative path like practice/raw always means "inside my home".
$ hdfs dfs -ls practiceFound 1 items drwxr-xr-x - vl0000 vl0000 0 2026-11-14 14:42 practice/raw
Two cluster settings explain a lot of what you will see later: the block size and the default replication.
$ hdfs getconf -confKey dfs.blocksize134217728
$ hdfs getconf -confKey dfs.replication1
134,217,728 bytes is 128 MB, the default HDFS block size. A file is split into blocks of that size, and each block is stored on one or more DataNodes. The default replication on this practice cluster is 1, which keeps storage costs low; production clusters usually use 3.
Step 2: Browse a real dataset
The lab has eleven practice datasets under /public/datasets, readable by every individual learner. Start by listing one:
$ hdfs dfs -ls /public/datasets/nyc-taxiFound 9 items -r--r-x---+ 1 vldata vl-individuals 1325 2026-10-16 17:53 /public/datasets/nyc-taxi/LICENSE.txt -r--r-x---+ 1 vldata vl-individuals 10475 2026-10-16 17:55 /public/datasets/nyc-taxi/MANIFEST.sha256 -r--r-x---+ 1 vldata vl-individuals 5736 2026-10-16 17:54 /public/datasets/nyc-taxi/MANIFEST.sizes.tsv -r--r-x---+ 1 vldata vl-individuals 3492 2026-10-16 17:54 /public/datasets/nyc-taxi/README.md -r--r-x---+ 1 vldata vl-individuals 21300 2026-10-16 17:54 /public/datasets/nyc-taxi/manifest.json dr-xr-x---+ - vldata vl-individuals 0 2026-10-16 17:54 /public/datasets/nyc-taxi/notebooks dr-xr-x---+ - vldata vl-individuals 0 2026-10-16 17:54 /public/datasets/nyc-taxi/parquet dr-xr-x---+ - vldata vl-individuals 0 2026-10-16 17:53 /public/datasets/nyc-taxi/raw dr-xr-x---+ - vldata vl-individuals 0 2026-10-16 17:53 /public/datasets/nyc-taxi/replay
How to read a line: permissions (with d for a directory), the replication factor for files (- for directories), owner, group, size in bytes, modification time and path. The + after the permissions means the path also has ACL entries, extra permissions beyond owner, group and others.
-du -h shows sizes in human-readable units, and -count -h shows how many folders and files a path holds:
$ hdfs dfs -du -h /public/datasets/nyc-taxi1.3 K 1.3 K /public/datasets/nyc-taxi/LICENSE.txt 10.2 K 10.2 K /public/datasets/nyc-taxi/MANIFEST.sha256 5.6 K 5.6 K /public/datasets/nyc-taxi/MANIFEST.sizes.tsv 3.4 K 3.4 K /public/datasets/nyc-taxi/README.md 20.8 K 20.8 K /public/datasets/nyc-taxi/manifest.json 9.3 K 9.3 K /public/datasets/nyc-taxi/notebooks 3.7 G 3.7 G /public/datasets/nyc-taxi/parquet 1.9 G 1.9 G /public/datasets/nyc-taxi/raw 8.2 K 8.2 K /public/datasets/nyc-taxi/replay
$ hdfs dfs -count -h /public/datasets/nyc-taxi/raw/small1 2 47.7 M /public/datasets/nyc-taxi/raw/small
The two size columns in -du are the logical size and the space used across all replicas. They match here because replication is 1. On a cluster with replication 3 the second column would be three times the first.
Reading a text file is -cat, usually piped into head so a large file doesn't flood your terminal:
$ hdfs dfs -cat /public/datasets/README.md | head -3# Verth Labs public datasets Read-only teaching datasets in HDFS. Each folder has `README.md` (schema, row counts, licence), `raw/` as published, `parquet/` copies, and a starter notebook under `notebooks/`.
Step 3: Create folders and upload a file
Make a small CSV on the lab's local disk, create a folder in HDFS, and upload the file with -put. The -f flag overwrites a file that already exists.
$ mkdir -p /tmp/seo && printf 'id,city,amount\n1,Pune,120\n2,Delhi,80\n3,Pune,45\n' > /tmp/seo/sales.csv$ hdfs dfs -mkdir -p practice/raw$ hdfs dfs -put -f /tmp/seo/sales.csv practice/raw/$ hdfs dfs -ls practice/raw
Found 1 items -rw-r--r-- 1 vl0000 vl0000 47 2026-11-14 14:42 practice/raw/sales.csv
$ hdfs dfs -cat practice/raw/sales.csvid,city,amount 1,Pune,120 2,Delhi,80 3,Pune,45
-mkdir -p creates parent folders as needed and does not fail if the folder exists, the same as on Linux. -tail prints the last kilobyte of a file, which is handy for logs:
$ hdfs dfs -tail practice/raw/sales.csvid,city,amount 1,Pune,120 2,Delhi,80 3,Pune,45
Step 4: Copy, move and inspect
-cp copies inside HDFS, -mv moves or renames, and -ls -R lists a folder tree. -stat prints file details in a format you choose:
$ hdfs dfs -cp practice/raw/sales.csv practice/raw/sales_copy.csv$ hdfs dfs -mkdir -p practice/archive$ hdfs dfs -mv practice/raw/sales_copy.csv practice/archive/$ hdfs dfs -ls -R practice
drwxr-xr-x - vl0000 vl0000 0 2026-11-14 14:42 practice/archive -rw-r--r-- 1 vl0000 vl0000 47 2026-11-14 14:42 practice/archive/sales_copy.csv drwxr-xr-x - vl0000 vl0000 0 2026-11-14 14:42 practice/raw -rw-r--r-- 1 vl0000 vl0000 47 2026-11-14 14:42 practice/raw/sales.csv
$ hdfs dfs -stat '%n %b bytes, replication %r, block size %o' practice/raw/sales.csvsales.csv 47 bytes, replication 1, block size 134217728
Notice that a 47-byte file still reports a 128 MB block size. That is the maximum size of its block, not space used: HDFS does not pad small files. Many small files are still a problem, though, because the NameNode keeps every file and block in memory.
Step 5: Permissions and ACLs
HDFS permissions work like Linux permissions. -chmod 640 gives the owner read and write, the group read, and everyone else nothing. -getfacl shows the full permission list:
$ hdfs dfs -chmod 640 practice/raw/sales.csv$ hdfs dfs -ls practice/raw
Found 1 items -rw-r----- 1 vl0000 vl0000 47 2026-11-14 14:42 practice/raw/sales.csv
$ hdfs dfs -getfacl practice/raw/sales.csv# file: practice/raw/sales.csv # owner: vl0000 # group: vl0000 user::rw- group::r-- other::---
On a cluster secured with Kerberos, as this one is, permissions are enforced against your real identity: you cannot pretend to be another user by setting an environment variable. Running klist in the terminal shows the Kerberos ticket the lab obtained for you.
Step 6: Download, merge and change replication
-get copies a file from HDFS to the local disk. -getmerge concatenates every file in an HDFS folder into one local file, which is useful for the many part-* files a Spark or MapReduce job writes.
$ hdfs dfs -get -f practice/raw/sales.csv /tmp/seo/back.csv && cat /tmp/seo/back.csvid,city,amount 1,Pune,120 2,Delhi,80 3,Pune,45
$ hdfs dfs -getmerge practice/raw /tmp/seo/merged.csv && wc -l /tmp/seo/merged.csv4 /tmp/seo/merged.csv
$ hdfs dfs -setrep 2 practice/raw/sales.csvReplication 2 set: practice/raw/sales.csv
$ hdfs dfs -du -s -h practice94 141 practice
After -setrep 2, the space-used column grows: 47 bytes of the file now count twice, so the folder uses 141 bytes for 94 bytes of data. This is the clearest way to see replication cost on a real cluster. On a single-node install you can set replication to 2, but there is no second DataNode to hold the copy.
Step 7: Check the cluster: YARN nodes
HDFS stores the data; YARN runs the jobs. yarn node -list shows the NodeManagers your jobs can run on:
$ yarn node -listTotal Nodes:2
Node-Id Node-State Node-Http-Address Number-of-Running-Containers
tt-nodemanager-0.tt-nodemanager.tt-cluster.svc.cluster.local:8041 RUNNING tt-nodemanager-0.tt-nodemanager.tt-cluster.svc.cluster.local:8042 0
tt-nodemanager-1.tt-nodemanager.tt-cluster.svc.cluster.local:8041 RUNNING tt-nodemanager-1.tt-nodemanager.tt-cluster.svc.cluster.local:8042 0Two NodeManagers means your Spark and MapReduce jobs really are spread over separate machines. On a laptop install this list has one entry.
Step 8: Clean up
-rm -r deletes a folder and everything in it. With -skipTrash the files are removed immediately instead of moving to .Trash in your home:
$ hdfs dfs -rm -r -skipTrash practice/archiveDeleted practice/archive
A quick reference
| Task | Command |
|---|---|
| List your home | hdfs dfs -ls |
| List recursively | hdfs dfs -ls -R <path> |
| Sizes | hdfs dfs -du -h <path> and hdfs dfs -du -s -h <path> |
| Make a folder | hdfs dfs -mkdir -p <path> |
| Upload / download | hdfs dfs -put -f <local> <hdfs> / hdfs dfs -get -f <hdfs> <local> |
| Read a file | hdfs dfs -cat <file> | head or hdfs dfs -tail <file> |
| Copy / move | hdfs dfs -cp <a> <b> / hdfs dfs -mv <a> <b> |
| Permissions | hdfs dfs -chmod 640 <file>, hdfs dfs -getfacl <file> |
| Replication | hdfs dfs -setrep 2 <file> |
| Delete | hdfs dfs -rm -r -skipTrash <path> |
Practice exercises
- Copy the NYC taxi zone lookup file (
/public/datasets/nyc-taxi/raw/small/taxi_zone_lookup.csv) into your home and count its lines withhdfs dfs -cat ... | wc -l. - Compare
hdfs dfs -du -s -hon therawandparquetfolders of two datasets. Which format is smaller, and is it always? - Set replication to 2 on one of your files and explain the change in
-duoutput. - Make a folder only you can read (
-chmod 700) and confirm it with-ls.
When you are ready to process the data, continue with PySpark practice problems on the NYC taxi dataset. If you want the whole stack (Hive, Kafka, Airflow and Spark on YARN) in one place, see how to practice Hadoop online without installing anything.