Thursday 4 October 2012

Hadoop Distributed File System (HDFS) Command Reference - Hadoop Online Training


There are many more commands in bin/hadoop dfs than were demonstrated here, although these basic operations will get you started. Running bin/hadoop dfs with no additional arguments will list all commands which can be run with the FsShell system. Furthermore, bin/hadoop dfs -helpcommandName will display a short usage summary for the operation in question, if you are stuck.
A table of all operations is reproduced below. The following conventions are used for parameters:
  • italics denote variables to be filled out by the user.
  • "path" means any file or directory name.
  • "path..." means one or more file or directory names.
  • "file" means any filename.
  • "src" and "dest" are path names in a directed operation.
  • "localSrc" and "localDest" are paths as above, but on the local file system. All other file and path names refer to objects inside HDFS.
  • Parameters in [brackets] are optional.
CommandOperation
-ls pathLists the contents of the directory specified by path, showing the names, permissions, owner, size and modification date for each entry.
-lsr pathBehaves like -ls, but recursively displays entries in all subdirectories of path.
-du pathShows disk usage, in bytes, for all files which match path; filenames are reported with the full HDFS protocol prefix.
-dus pathLike -du, but prints a summary of disk usage of all files/directories in the path.
-mv src destMoves the file or directory indicated by src to dest, within HDFS.
-cp src destCopies the file or directory identified by src to dest, within HDFS.
-rm pathRemoves the file or empty directory identified by path.
-rmr pathRemoves the file or directory identified by path. Recursively deletes any child entries (i.e., files or subdirectories of path).
-put localSrcdestCopies the file or directory from the local file system identified by localSrc to destwithin the DFS.
-copyFromLocallocalSrc destIdentical to -put
-moveFromLocallocalSrc destCopies the file or directory from the local file system identified by localSrc to destwithin HDFS, then deletes the local copy on success.
-get [-crc] srclocalDestCopies the file or directory in HDFS identified by src to the local file system path identified by localDest.
-getmerge srclocalDest[addnl]Retrieves all files that match the path src in HDFS, and copies them to a single, merged file in the local file system identified by localDest.
-cat filenameDisplays the contents of filename on stdout.
-copyToLocal [-crc] srclocalDestIdentical to -get
-moveToLocal [-crc] srclocalDestWorks like -get, but deletes the HDFS copy on success.
-mkdir pathCreates a directory named path in HDFS. Creates any parent directories in path that are missing (e.g., like mkdir -p in Linux).
-setrep [-R] [-w]rep pathSets the target replication factor for files identified by path to rep. (The actual replication factor will move toward the target over time)
-touchz pathCreates a file at path containing the current time as a timestamp. Fails if a file already exists at path, unless the file is already size 0.
-test -[ezd]pathReturns 1 if path exists; has zero length; or is a directory, or 0 otherwise.
-stat [format]pathPrints information about pathformat is a string which accepts file size in blocks (%b), filename (%n), block size (%o), replication (%r), and modification date (%y, %Y).
-tail [-f] fileShows the lats 1KB of file on stdout.
-chmod [-R]mode,mode,...path...Changes the file permissions associated with one or more objects identified bypath.... Performs changes recursively with -Rmode is a 3-digit octal mode, or{augo}+/-{rwxX}. Assumes a if no scope is specified and does not apply a umask.
-chown [-R] [owner][:[group]] path...Sets the owning user and/or group for files or directories identified by path.... Sets owner recursively if -R is specified.
-chgrp [-R]group path...Sets the owning group for files or directories identified by path.... Sets group recursively if -R is specified.
-help cmdReturns usage information for one of the commands listed above. You must omit the leading '-' character in cmd

1 comment:

  1. Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks!!


    Big Data Course in Chennai

    ReplyDelete