【问题标题】:Difference between 'hdfs dfs -ls' and 'hdfs dfs -ls /'“hdfs dfs -ls”和“hdfs dfs -ls /”之间的区别
【发布时间】:2016-06-13 12:06:07
【问题描述】:

为什么hdfs dfs -ls 指向的位置与hdfs dfs -ls / 不同?

从下面两个命令的屏幕截图可以清楚地看到给出不同的输出:

以上输出的主要原因是什么?

【问题讨论】:

  • 我猜它指向某种主文件夹?

标签: hadoop hdfs


【解决方案1】:

来自官方源代码org.apache.hadoop.fs.shell.Ls.java。只需搜索DESCRIPTION 字。它将列出以下语句:-

public static final String DESCRIPTION =
 "List the contents that match the specified file pattern. If " +
 "path is not specified, the contents of /user/<currentUser> " +
 "will be listed. For a directory a list of its direct children " +
 "is returned (unless -" + OPTION_DIRECTORY +
 " option is specified)" 

hadoop fs -ls 将列出当前用户的主目录内容。

hadoop fs -ls / 将列出根目录的直接子目录。

【讨论】:

    【解决方案2】:

    -ls 在 Hadoop 中的默认位置是用户的主目录,在本例中为 /user/root。

    添加/ 使-ls 命令指向文件系统的根目录。

    【讨论】:

      【解决方案3】:

      / 查找 Hdfs 的根文件夹

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-21
        • 1970-01-01
        相关资源
        最近更新 更多