1
votes

I'm trying to copy a local file called 'afile' to the HDFS. So I ran the following command:

'hadoop fs -copyFromLocal /home/neo/afile in' or 'hadoop fs -put /home/neo/afile in'

However, it says: 'File /home/neo/afile does not exist'

Then I put the file 'afile' into the directory under hadoop. Now the copyFromLocal succeeded. However, the file 'in' is empty, since I run 'hadoop fs - ls', it shows

'-rw-r--r--' 1 neo supergroup 0 2015-04-06 17:45 /user/neo/in

I also tried 'hadoop fs -cat in', nothing returned.

Could someone please help?

Thanks!

1
Share the output of the command " ls -ltr /home/neo/afile " - SachinJ
What does the afile contain? Also post the result for ls -l /home/neo/. - Rajesh N
@h4ck3r The result for command 'ls -ltr /home/neo/afile' is: '-rw-rw-r-- 1 neo neo 19 Apr 6 17:17 /home/neo/afile - Neo XU
@RajeshN The contents of a file is a simple text: 'to be or not to be' The result for 'ls -l /home/neo' is : -rw-rw-r-- 1 neo neo 19 Apr 6 17:17 afile -rw-rw-r-- 1 neo neo 0 Apr 6 17:17 afile~ -rw-rw-r-- 1 neo neo 20 Apr 6 17:31 afile2 -rw-rw-r-- 1 neo neo 0 Apr 6 17:31 afile2~ drwxr-xr-x 2 neo neo 4096 Mar 30 12:12 Desktop drwxr-xr-x 2 neo neo 4096 Mar 30 12:12 Documents drwxr-xr-x 5 neo neo 4096 Mar 30 21:47 Downloads -rw-r--r-- 1 neo neo 8445 Mar 30 11:24 examples.desktop - Neo XU

1 Answers

2
votes
  1. Create a new file in local filesystem named test.txt in /home/neo/

  2. Add content to test.txt: echo "sample text for wordcount" > /home/neo/test.txt

  3. Create a new directory in hdfs using: hadoop fs -mkdir /user/neo/in/

  4. Copy file from local directory to HDFS: hadoop fs -copyFromLocal /home/neo/test.txt /user/neo/in/test.txt