Goldi
Goldi

Reputation: 23

Hadoop mkdir and ls commands

I did fresh setup of hadoop2.9.

To create a directory, I tried:

> hadoop fs -mkdir test 
mkdir: 'test': No such file or directory

To list its content, I tried:

> hadoop fs -ls/ 
not listing directories or files

Please help me to understand the issue.

Upvotes: 2

Views: 7132

Answers (3)

ravi
ravi

Reputation: 15

For listing we can use

hadoop fs -mkdir /

e.g

hadoop fs -mkdir /hadoop/schema/test

For listing if its a file we can access hadoop fs -cat /

e.g

hadoop fs -cat /hadoop/schema/test.txt

Upvotes: 0

OneCricketeer
OneCricketeer

Reputation: 191701

Without a fully qualified path, you are required to make a user folder first

hdfs dfs -mkdir -p /user/$(whoami)
hdfs dfs -chown -R $(whoami)  /user/$(whoami)
hdfs dfs -chmod -R 750  /user/$(whoami)

Then, the first command will work so will put and ls without an otherwise fully qualified path

Upvotes: 0

Mobin Ranjbar
Mobin Ranjbar

Reputation: 1360

When you just setup hadoop, HDFS is empty. make some file and directories like below with a full path:

hadoop fs -mkdir /test

Upvotes: 1

Related Questions