Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between "hadoop fs" shell commands and "hdfs dfs" shell commands?

Tags:

hadoop

hdfs

People also ask

What is the difference between Hadoop FS and HDFS dfs?

Yes, there's a difference between hadoop fs and hdfs dfs. hadoop fs is used to communicate with any file system. hdfs dfs is used to communicate particularly with hadoop distributed file system.

What is HDFS dfs commands?

Basic HDFS DFS Commands. ls – List Files and Folder. mkdir – Make Directory. rm – Remove File or Directory. rmr – Remove Directory Recursively.

What is difference between HDFS and regular file system?

Normal file systems have small block size of data. (Around 512 bytes) while HDFS has larger block sizes at around 64 MB) Multiple disks seek for larger files in normal file systems while in HDFS, data is read sequentially after every individual seek.

What is HDFS shell?

GitHub - avast/hdfs-shell: HDFS Shell is a HDFS manipulation tool to work with functions integrated in Hadoop DFS. Product. Actions. Copilot. Packages.


Following are the three commands which appears same but have minute differences

  1. hadoop fs {args}
  2. hadoop dfs {args}
  3. hdfs dfs {args}

  hadoop fs <args>

FS relates to a generic file system which can point to any file systems like local, HDFS etc. So this can be used when you are dealing with different file systems such as Local FS, (S)FTP, S3, and others


  hadoop dfs <args>

dfs is very specific to HDFS. would work for operation relates to HDFS. This has been deprecated and we should use hdfs dfs instead.


  hdfs dfs <args>

same as 2nd i.e would work for all the operations related to HDFS and is the recommended command instead of hadoop dfs

below is the list categorized as hdfs commands.

  namenode|secondarynamenode|datanode|dfs|dfsadmin|fsck|balancer|fetchdt|oiv|dfsgroups

So even if you use hadoop dfs , it will look locate hdfs and delegate that command to hdfs dfs


enter image description here

https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/FileSystemShell.html

The File System (FS) shell includes various shell-like commands that directly interact with the Hadoop Distributed File System (HDFS) as well as other file systems that Hadoop supports, such as Local FS, WebHDFS, S3 FS, and others.

bin/hadoop fs <args>

All FS shell commands take path URIs as arguments. The URI format is scheme://authority/path. For HDFS the scheme is hdfs, and for the Local FS the scheme is file. The scheme and authority are optional. If not specified, the default scheme specified in the configuration is used. An HDFS file or directory such as /parent/child can be specified as hdfs://namenodehost/parent/child or simply as /parent/child (given that your configuration is set to point to hdfs://namenodehost).

Most of the commands in FS shell behave like corresponding Unix commands. Differences are described with each of the commands. Error information is sent to stderr and the output is sent to stdout.

If HDFS is being used,

hdfs dfs

is a synonym.


fs refers to any file system, it could be local or HDFS but dfs refers to only HDFS file system. So if you need to perform access/transfer data between different filesystems, fs is the way to go.


From what I can tell, there is no difference between hdfs dfs and hadoop fs. They're simply different naming conventions based on which version of Hadoop you're using. For example, the notes in 1.2.1 use hdfs dfs while 0.19 uses hadoop fs. Notice that the separate commands are described verbatim. They are used identically.

Also note that both commands can refer to different file systems depending on what you specify (hdfs, file, s3, etc). If no file system is listed, they fall back to the default which is specified in your configuration.

You're using Hadoop 2.0.0 and it looks like (based on 2.0.5 documentation) that Alpha versions use hadoop fs and is set to use the HDFS as the default scheme in your configuration. The hdfs dfs command might be left in from before, and since not specified in the configuration, could just be defaulting to the local file system.

So I would just stick with hadoop fs and not worry too much since in documentation, they are identical.


fs = file system
dfs = distributed file system

fs = other file systems + distributed file systems

FS relates to a generic file system which can point to any file systems like local, HDFS etc. But dfs is very specific to HDFS. So when we use FS it can perform operation with from/to local or hadoop distributed file system to destination . But specifying DFS operation relates to HDFS.

It all depends upon the scheme configure. When using this two command with absolute URI, i.e. scheme://a/b the behavior shall be identical. Only its the default configured scheme value for file:// and hdfs:// for fs and dfs respectively which is the cause for difference in behavior.


FS relates to a generic file system which can point to any file systems like local, HDFS etc., but dfs is very specific to HDFS. So when we use FS it can perform operation with from/to local or hadoop distributed file system to destination, but specifying DFS operation relates to HDFS.

Below are the excerpts from Hadoop documentation which describe these two as different shells.

FS Shell:

The FileSystem (FS) shell is invoked by bin/hadoop fs. All the FS shell commands take path URIs as arguments. The URI format is scheme://autority/path. For HDFS the scheme is hdfs, and for the local filesystem the scheme is file. The scheme and authority are optional. If not specified, the default scheme specified in the configuration is used. An HDFS file or directory such as /parent/child can be specified as hdfs://namenodehost/parent/child or simply as /parent/child (given that your configuration is set to point to hdfs://namenodehost). Most of the commands in FS shell behave like corresponding Unix commands.

DFShell:

The HDFS shell is invoked by bin/hadoop dfs. All the HDFS shell commands take path URIs as arguments. The URI format is scheme://autority/path. For HDFS the scheme is hdfs, and for the local filesystem the scheme is file. The scheme and authority are optional. If not specified, the default scheme specified in the configuration is used. An HDFS file or directory such as /parent/child can be specified as hdfs://namenode:namenodeport/parent/child or simply as /parent/child (given that your configuration is set to point to namenode:namenodeport). Most of the commands in HDFS shell behave like corresponding Unix commands.

From the above it can be concluded that it all depends upon the scheme configure. When using this two command with absolute URI, i.e. scheme://a/b the behavior shall be identical. Only its the default configured scheme value for file and hdfs for fs and dfs respectively which is the cause for the difference in behavior.