HADOOP HDFS COMMANDS:
1. Listing the all directory?
hduser@ubuntu:~$ hadoop fs -ls /
Found 4 items
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:56 /city
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:28 /student
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:32 /studentcity
drwxrwx--- - hduser supergroup 0 2017-02-25 03:06 /tmp
hduser@ubuntu:~$
[Link] listing with hidden files:
hduser@ubuntu:~$ hadoop fs -ls al /
ls: `al': No such file or directory
Found 4 items
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:56 /city
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:28 /student
drwxr-xr-x - hduser supergroup 0 2017-02-25 03:32 /studentcity
drwxrwx--- - hduser supergroup 0 2017-02-25 03:06 /tmp
4. make a directory ?
hduser@ubuntu:~$ hadoop fs -mkdir /niit1
5. copy file from local ?
Ans:--use copyFromLocal or copyTo
hduser@ubuntu:~$ hadoop fs -copyFromLocal file1 /niit1/
hduser@ubuntu:~$ hadoop fs -ls /niit1/
Found 1 items
-rw-r--r-- 1 hduser supergroup 0 2017-02-26 21:59 /niit1/file1
5. count the number of directories?
Ans:--- count -h,count -q (q-count quata,-h:count the)
hduser@ubuntu:~$ hadoop fs -count -h /
17 14 358.1 K /
hduser@ubuntu:~$ hadoop fs -count -q /
9223372036854775807 9223372036854775776 none inf 17 14
366666 /
[Link] the file in the hadoop ?
Ans:----
hduser@ubuntu:~$ hadoop fs -cp /niit1/file1 /niit
17/02/26 [Link] WARN [Link]: DFSInputStream has been closed already
hduser@ubuntu:~$
[Link] the size of files or directories ?
hduser@ubuntu:~$ hadoop fs -du /
53 /city
0 /niit
0 /niit1
247 /student
0 /studentcity
366366 /tmp
8. display the summary of files lengths ?
Ans:--hduser@ubuntu:~$ hadoop fs -du -s /
366666 /
9. copy file to the local files system ?
hduser@ubuntu:~$ hadoop fs -get /city/part-r-00000
17/02/26 [Link] WARN [Link]: DFSInputStream has been closed already
hduser@ubuntu:~$ ls
[Link] Documents [Link] hadoop-2.7.1 installation [Link] Music Pictures
student1 Templates
Desktop Downloads file1 [Link] jar_files part-r-00000 Public
student2 Videos
hduser@ubuntu:~$
10. to see the content of file
hduser@ubuntu:~$ hadoop fs -cat /city/part-r-00000
Bangalore
Chennai
Delhi
Hyderabad
Jaipur
Mumbai
Pune
hduser@ubuntu:~$
[Link] the file ?
Ans:---
hduser@ubuntu:~$ hadoop fs -mv /city/part-r-00000 /niit1/
hduser@ubuntu:~$
[Link] the directory ?
Ans:---hduser@ubuntu:~$ hadoop fs -mv /niit1/ /niit/
mv: `/niit': File exists
[Link] the file ?
Ans:-----
hduser@ubuntu:~$ hadoop fs -rm /niit1/file1
17/02/26 [Link] INFO [Link]: Namenode trash configuration: Deletion interval = 0
minutes, Emptier interval = 0 minutes.
Deleted /niit1/file1
[Link] the directory ?
Ans:--------if directory is empty...
hduser@ubuntu:~$ hadoop fs -rmdir /niit1
rmdir: `/niit1': Directory is not empty
[Link] the last kilobytes of file ?
Ans:----
hduser@ubuntu:~$ hadoop fs -tail /student/student1
201,Arun,85,Delhi
202,Brajesh,98,Mumbai
203,Chetan,76,Pune
204,Priti,82,Bangalore
205,Ravi,70,Pune
206,Kiran,74,Mumbai
hduser@ubuntu:~$
hadoop fs -tail -f will give appended data as file grow ….
[Link] commands usage ? Provode the information of each commands.
Ans:---
hduser@ubuntu:~$ hadoop fs -usage
Usage: hadoop fs [generic options]
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>]
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] <path> ...]
[-cp [-f] [-p | -p[topax]] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> …]]
[Link] change the permission of the file or directory?
Ans:----
hduser@ubuntu:~$ hadoop fs -chmod 777 /student/student1
[Link] the contents of file from local to the files in hdfs ?
Ans:----
hduser@ubuntu:~$ hadoop fs -appendToFile file2 /niit1/file1
hduser@ubuntu:~$