You can do `sudo -u hdfs` or `not_if "hdfs dfs -test -d /mr-history", :user => "hdfs"`; however, please use the `hdfs` command instead of `hadoop` command as `hadoop` reports a deprecation message for filesystem actions.