Error creating file from hdfs to local file system


5 Answer(s)


Hi Ritu,

You don't have sufficient permission to create file under /local.txt (root directory). Please use the command to create a file in default local directory(/home/cloudera) with full permission:

$ hadoop fs -copyToLocal /dezyre/new.txt local.txt

Note: You don't need sudo permission for this. "sudo -u hdfs" is used for provide superuser access while performing some task over hdfs.

Hope this helps.

Thanks.


Hi Ritu,

Please share the output of the following command:

  1. $ hadoop fs -ls /dezyre/
  2. $ ls -l /home/cloudera/

Now the problem is with copying file from local to hdfs

here are the steps:

cloudera@localhost ~]$ ls
datasets  Documents  hadoopFile.txt  new.txt   Templates  workspace
Desktop   Downloads  lib             Pictures  Videos
dezyre    eclipse    Music           Public    wordcount

[cloudera@localhost ~]$  hadoop fs -copyFromLocal hadoopFile.txt /dezyre

copyFromLocal: Permission denied: user=cloudera, access=WRITE, inode="/dezyre":hdfs:supergroup:drwxr-xr-x

[cloudera@localhost ~]$ sudo -u hdfs hadoop fs -copyFromLocal hadoopFile.txt /dezyre
copyFromLocal: `hadoopFile.txt': No such file or directory
[cloudera@localhost ~]$ 

 


Here is the output for commnds

  1. $ hadoop fs -ls /dezyre/
  2. $ ls -l /home/cloudera/

[cloudera@localhost ~]$ hadoop fs -ls /dezyre/
Found 1 items
drwxr-xr-x   - hdfs supergroup          0 2016-10-03 19:55 /dezyre/new.txt
[cloudera@localhost ~]$ -l /home/cloudera/
bash: -l: command not found
[cloudera@localhost ~]$ ls -l /home/cloudera/
total 64
drwxr-xr-x. 2 cloudera cloudera 4096 Oct  7  2013 datasets
drwxr-xr-x. 2 cloudera cloudera 4096 Oct  7  2013 Desktop
drwxrwxr-x  2 cloudera cloudera 4096 Oct  3 18:58 dezyre
drwxr-xr-x. 3 cloudera cloudera 4096 Oct  7  2013 Documents
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Downloads
drwxrwsr-x. 9 cloudera cloudera 4096 Feb 24  2013 eclipse
-rw-rw-r--  1 cloudera cloudera  104 Oct  4 13:10 hadoopFile.txt
drwxr-xr-x. 2 cloudera cloudera 4096 Oct  7  2013 lib
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Music
drwxrwxr-x  3 cloudera cloudera 4096 Oct  4 13:07 new.txt
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Pictures
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Public
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Templates
drwxr-xr-x  2 cloudera cloudera 4096 Sep 20 11:31 Videos
drwxrwxr-x  3 cloudera cloudera 4096 Oct  3 12:56 wordcount
drwxr-xr-x. 4 cloudera cloudera 4096 Oct  7  2013 workspace
[cloudera@localhost ~]$ 
 


Hi Ritu,

Please use the command:

$ sudo -u hdfs hadoop fs -chown -R cloudera:cloudera /dezyre 
$ hadoop fs -put hadoopFile.txt /dezyre

Hope this helps.

Thanks