Page MenuHomec4science

FileSystemShell.html
No OneTemporary

File Metadata

Created
Tue, Feb 25, 12:23

FileSystemShell.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia at 2014-02-11 -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Apache Hadoop 2.3.0 - File System Shell Guide</title>
<style type="text/css" media="all">
@import url("./css/maven-base.css");
@import url("./css/maven-theme.css");
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta name="Date-Revision-yyyymmdd" content="20140211" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="composite">
<div id="banner">
<a href="http://hadoop.apache.org/" id="bannerLeft">
<img src="http://hadoop.apache.org/images/hadoop-logo.jpg" alt="" />
</a>
<a href="http://www.apache.org/" id="bannerRight">
<img src="http://www.apache.org/images/asf_logo_wide.png" alt="" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
<a href="http://www.apache.org/" class="externalLink">Apache</a>
&gt;
<a href="http://hadoop.apache.org/" class="externalLink">Hadoop</a>
&gt;
<a href="../">Apache Hadoop Project Dist POM</a>
&gt;
Apache Hadoop 2.3.0
</div>
<div class="xright"> <a href="http://wiki.apache.org/hadoop" class="externalLink">Wiki</a>
|
<a href="https://svn.apache.org/repos/asf/hadoop/" class="externalLink">SVN</a>
|
<a href="http://hadoop.apache.org/" class="externalLink">Apache Hadoop</a>
&nbsp;| Last Published: 2014-02-11
&nbsp;| Version: 2.3.0
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>General</h5>
<ul>
<li class="none">
<a href="../../index.html">Overview</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/SingleCluster.html">Single Node Setup</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/ClusterSetup.html">Cluster Setup</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/CommandsManual.html">Hadoop Commands Reference</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/FileSystemShell.html">File System Shell</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/Compatibility.html">Hadoop Compatibility</a>
</li>
</ul>
<h5>Common</h5>
<ul>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/CLIMiniCluster.html">CLI Mini Cluster</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/NativeLibraries.html">Native Libraries</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/Superusers.html">Superusers</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/SecureMode.html">Secure Mode</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/ServiceLevelAuth.html">Service Level Authorization</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/HttpAuthentication.html">HTTP Authentication</a>
</li>
</ul>
<h5>HDFS</h5>
<ul>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsUserGuide.html">HDFS User Guide</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/HDFSHighAvailabilityWithQJM.html">High Availability With QJM</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/HDFSHighAvailabilityWithNFS.html">High Availability With NFS</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/Federation.html">Federation</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsSnapshots.html">HDFS Snapshots</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsDesign.html">HDFS Architecture</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsEditsViewer.html">Edits Viewer</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsImageViewer.html">Image Viewer</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsPermissionsGuide.html">Permissions and HDFS</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsQuotaAdminGuide.html">Quotas and HDFS</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/Hftp.html">HFTP</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/LibHdfs.html">C API libhdfs</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/WebHDFS.html">WebHDFS REST API</a>
</li>
<li class="none">
<a href="../../hadoop-hdfs-httpfs/index.html">HttpFS Gateway</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/ShortCircuitLocalReads.html">Short Circuit Local Reads</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/CentralizedCacheManagement.html">Centralized Cache Management</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/HdfsNfsGateway.html">HDFS NFS Gateway</a>
</li>
</ul>
<h5>MapReduce</h5>
<ul>
<li class="none">
<a href="../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduce_Compatibility_Hadoop1_Hadoop2.html">Compatibilty between Hadoop 1.x and Hadoop 2.x</a>
</li>
<li class="none">
<a href="../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/EncryptedShuffle.html">Encrypted Shuffle</a>
</li>
<li class="none">
<a href="../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/PluggableShuffleAndPluggableSort.html">Pluggable Shuffle/Sort</a>
</li>
<li class="none">
<a href="../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/DistributedCacheDeploy.html">Distributed Cache Deploy</a>
</li>
</ul>
<h5>YARN</h5>
<ul>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/YARN.html">YARN Architecture</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/WritingYarnApplications.html">Writing YARN Applications</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html">Capacity Scheduler</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/FairScheduler.html">Fair Scheduler</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/WebApplicationProxy.html">Web Application Proxy</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/YarnCommands.html">YARN Commands</a>
</li>
<li class="none">
<a href="../../hadoop-sls/SchedulerLoadSimulator.html">Scheduler Load Simulator</a>
</li>
</ul>
<h5>YARN REST APIs</h5>
<ul>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/WebServicesIntro.html">Introduction</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html">Resource Manager</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/NodeManagerRest.html">Node Manager</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/MapredAppMasterRest.html">MR Application Master</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-site/HistoryServerRest.html">History Server</a>
</li>
</ul>
<h5>Auth</h5>
<ul>
<li class="none">
<a href="../../hadoop-auth/index.html">Overview</a>
</li>
<li class="none">
<a href="../../hadoop-auth/Examples.html">Examples</a>
</li>
<li class="none">
<a href="../../hadoop-auth/Configuration.html">Configuration</a>
</li>
<li class="none">
<a href="../../hadoop-auth/BuildingIt.html">Building</a>
</li>
</ul>
<h5>Reference</h5>
<ul>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/releasenotes.html">Release Notes</a>
</li>
<li class="none">
<a href="../../api/index.html">API docs</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/CHANGES.txt">Common CHANGES.txt</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/CHANGES.txt">HDFS CHANGES.txt</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-mapreduce/CHANGES.txt">MapReduce CHANGES.txt</a>
</li>
</ul>
<h5>Configuration</h5>
<ul>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/core-default.xml">core-default.xml</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-hdfs/hdfs-default.xml">hdfs-default.xml</a>
</li>
<li class="none">
<a href="../../hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml">mapred-default.xml</a>
</li>
<li class="none">
<a href="../../hadoop-yarn/hadoop-yarn-common/yarn-default.xml">yarn-default.xml</a>
</li>
<li class="none">
<a href="../../hadoop-project-dist/hadoop-common/DeprecatedProperties.html">Deprecated Properties</a>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img alt="Built by Maven" src="./images/logos/maven-feather.png"/>
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements. See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License. You may obtain a copy of the License at --><!-- --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!-- --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#appendToFile">appendToFile</a></li>
<li><a href="#cat">cat</a></li>
<li><a href="#chgrp">chgrp</a></li>
<li><a href="#chmod">chmod</a></li>
<li><a href="#chown">chown</a></li>
<li><a href="#copyFromLocal">copyFromLocal</a></li>
<li><a href="#copyToLocal">copyToLocal</a></li>
<li><a href="#count">count</a></li>
<li><a href="#cp">cp</a></li>
<li><a href="#du">du</a></li>
<li><a href="#dus">dus</a></li>
<li><a href="#expunge">expunge</a></li>
<li><a href="#get">get</a></li>
<li><a href="#getmerge">getmerge</a></li>
<li><a href="#ls">ls</a></li>
<li><a href="#lsr">lsr</a></li>
<li><a href="#mkdir">mkdir</a></li>
<li><a href="#moveFromLocal">moveFromLocal</a></li>
<li><a href="#moveToLocal">moveToLocal</a></li>
<li><a href="#mv">mv</a></li>
<li><a href="#put">put</a></li>
<li><a href="#rm">rm</a></li>
<li><a href="#rmr">rmr</a></li>
<li><a href="#setrep">setrep</a></li>
<li><a href="#stat">stat</a></li>
<li><a href="#tail">tail</a></li>
<li><a href="#test">test</a></li>
<li><a href="#text">text</a></li>
<li><a href="#touchz">touchz</a></li></ul>
<div class="section">
<h2>Overview<a name="Overview"></a></h2>
<p>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, HFTP FS, S3 FS, and others. The FS shell is invoked by:</p>
<div class="source">
<pre>bin/hadoop fs &lt;args&gt;</pre></div>
<p>All FS shell commands take path URIs as arguments. The URI format is <tt>scheme://authority/path</tt>. For HDFS the scheme is <tt>hdfs</tt>, and for the Local FS the scheme is <tt>file</tt>. 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 <tt>hdfs://namenodehost/parent/child</tt> or simply as <tt>/parent/child</tt> (given that your configuration is set to point to <tt>hdfs://namenodehost</tt>).</p>
<p>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.</p></div>
<div class="section">
<h2>appendToFile<a name="appendToFile"></a></h2>
<p>Usage: <tt>hdfs dfs -appendToFile &lt;localsrc&gt; ... &lt;dst&gt; </tt></p>
<p>Append single src, or multiple srcs from local file system to the destination file system. Also reads input from stdin and appends to destination file system.</p>
<ul>
<li><tt>hdfs dfs -appendToFile localfile /user/hadoop/hadoopfile</tt></li>
<li><tt>hdfs dfs -appendToFile localfile1 localfile2 /user/hadoop/hadoopfile</tt></li>
<li><tt>hdfs dfs -appendToFile localfile hdfs://nn.example.com/hadoop/hadoopfile</tt></li>
<li><tt>hdfs dfs -appendToFile - hdfs://nn.example.com/hadoop/hadoopfile</tt> Reads the input from stdin.</li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and 1 on error.</p></div>
<div class="section">
<h2>cat<a name="cat"></a></h2>
<p>Usage: <tt>hdfs dfs -cat URI [URI ...]</tt></p>
<p>Copies source paths to stdout.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -cat hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2</tt></li>
<li><tt>hdfs dfs -cat file:///file3 /user/hadoop/file4</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>chgrp<a name="chgrp"></a></h2>
<p>Usage: <tt>hdfs dfs -chgrp [-R] GROUP URI [URI ...]</tt></p>
<p>Change group association of files. The user must be the owner of files, or else a super-user. Additional information is in the <a href="../hadoop-hdfs/HdfsPermissionsGuide.html">Permissions Guide</a>.</p>
<p>Options</p>
<ul>
<li>The -R option will make the change recursively through the directory structure.</li></ul></div>
<div class="section">
<h2>chmod<a name="chmod"></a></h2>
<p>Usage: <tt>hdfs dfs -chmod [-R] &lt;MODE[,MODE]... | OCTALMODE&gt; URI [URI ...]</tt></p>
<p>Change the permissions of files. With -R, make the change recursively through the directory structure. The user must be the owner of the file, or else a super-user. Additional information is in the <a href="../hadoop-hdfs/HdfsPermissionsGuide.html">Permissions Guide</a>.</p>
<p>Options</p>
<ul>
<li>The -R option will make the change recursively through the directory structure.</li></ul></div>
<div class="section">
<h2>chown<a name="chown"></a></h2>
<p>Usage: <tt>hdfs dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]</tt></p>
<p>Change the owner of files. The user must be a super-user. Additional information is in the <a href="../hadoop-hdfs/HdfsPermissionsGuide.html">Permissions Guide</a>.</p>
<p>Options</p>
<ul>
<li>The -R option will make the change recursively through the directory structure.</li></ul></div>
<div class="section">
<h2>copyFromLocal<a name="copyFromLocal"></a></h2>
<p>Usage: <tt>hdfs dfs -copyFromLocal &lt;localsrc&gt; URI</tt></p>
<p>Similar to put command, except that the source is restricted to a local file reference.</p>
<p>Options:</p>
<ul>
<li>The -f option will overwrite the destination if it already exists.</li></ul></div>
<div class="section">
<h2>copyToLocal<a name="copyToLocal"></a></h2>
<p>Usage: <tt>hdfs dfs -copyToLocal [-ignorecrc] [-crc] URI &lt;localdst&gt; </tt></p>
<p>Similar to get command, except that the destination is restricted to a local file reference.</p></div>
<div class="section">
<h2>count<a name="count"></a></h2>
<p>Usage: <tt>hdfs dfs -count [-q] &lt;paths&gt; </tt></p>
<p>Count the number of directories, files and bytes under the paths that match the specified file pattern. The output columns with -count are: DIR_COUNT, FILE_COUNT, CONTENT_SIZE FILE_NAME</p>
<p>The output columns with -count -q are: QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA, DIR_COUNT, FILE_COUNT, CONTENT_SIZE, FILE_NAME</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -count hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2</tt></li>
<li><tt>hdfs dfs -count -q hdfs://nn1.example.com/file1</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>cp<a name="cp"></a></h2>
<p>Usage: <tt>hdfs dfs -cp [-f] URI [URI ...] &lt;dest&gt; </tt></p>
<p>Copy files from source to destination. This command allows multiple sources as well in which case the destination must be a directory.</p>
<p>Options:</p>
<ul>
<li>The -f option will overwrite the destination if it already exists.</li></ul>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -cp /user/hadoop/file1 /user/hadoop/file2</tt></li>
<li><tt>hdfs dfs -cp /user/hadoop/file1 /user/hadoop/file2 /user/hadoop/dir</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>du<a name="du"></a></h2>
<p>Usage: <tt>hdfs dfs -du [-s] [-h] URI [URI ...]</tt></p>
<p>Displays sizes of files and directories contained in the given directory or the length of a file in case its just a file.</p>
<p>Options:</p>
<ul>
<li>The -s option will result in an aggregate summary of file lengths being displayed, rather than the individual files.</li>
<li>The -h option will format file sizes in a &quot;human-readable&quot; fashion (e.g 64.0m instead of 67108864)</li></ul>
<p>Example:</p>
<ul>
<li>hdfs dfs -du /user/hadoop/dir1 /user/hadoop/file1 hdfs://nn.example.com/user/hadoop/dir1</li></ul>
<p>Exit Code: Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>dus<a name="dus"></a></h2>
<p>Usage: <tt>hdfs dfs -dus &lt;args&gt; </tt></p>
<p>Displays a summary of file lengths. This is an alternate form of hdfs dfs -du -s.</p></div>
<div class="section">
<h2>expunge<a name="expunge"></a></h2>
<p>Usage: <tt>hdfs dfs -expunge</tt></p>
<p>Empty the Trash. Refer to the <a href="../hadoop-hdfs/HdfsDesign.html"> HDFS Architecture Guide</a> for more information on the Trash feature.</p></div>
<div class="section">
<h2>get<a name="get"></a></h2>
<p>Usage: <tt>hdfs dfs -get [-ignorecrc] [-crc] &lt;src&gt; &lt;localdst&gt; </tt></p>
<p>Copy files to the local file system. Files that fail the CRC check may be copied with the -ignorecrc option. Files and CRCs may be copied using the -crc option.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -get /user/hadoop/file localfile</tt></li>
<li><tt>hdfs dfs -get hdfs://nn.example.com/user/hadoop/file localfile</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>getmerge<a name="getmerge"></a></h2>
<p>Usage: <tt>hdfs dfs -getmerge &lt;src&gt; &lt;localdst&gt; [addnl]</tt></p>
<p>Takes a source directory and a destination file as input and concatenates files in src into the destination local file. Optionally addnl can be set to enable adding a newline character at the end of each file.</p></div>
<div class="section">
<h2>ls<a name="ls"></a></h2>
<p>Usage: <tt>hdfs dfs -ls &lt;args&gt; </tt></p>
<p>For a file returns stat on the file with the following format:</p>
<div class="source">
<pre>permissions number_of_replicas userid groupid filesize modification_date modification_time filename</pre></div>
<p>For a directory it returns list of its direct children as in Unix. A directory is listed as:</p>
<div class="source">
<pre>permissions userid groupid modification_date modification_time dirname</pre></div>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -ls /user/hadoop/file1</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>lsr<a name="lsr"></a></h2>
<p>Usage: <tt>hdfs dfs -lsr &lt;args&gt; </tt></p>
<p>Recursive version of ls. Similar to Unix ls -R.</p></div>
<div class="section">
<h2>mkdir<a name="mkdir"></a></h2>
<p>Usage: <tt>hdfs dfs -mkdir [-p] &lt;paths&gt; </tt></p>
<p>Takes path uri's as argument and creates directories.</p>
<p>Options:</p>
<ul>
<li>The -p option behavior is much like Unix mkdir -p, creating parent directories along the path.</li></ul>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -mkdir /user/hadoop/dir1 /user/hadoop/dir2</tt></li>
<li><tt>hdfs dfs -mkdir hdfs://nn1.example.com/user/hadoop/dir hdfs://nn2.example.com/user/hadoop/dir</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>moveFromLocal<a name="moveFromLocal"></a></h2>
<p>Usage: <tt>dfs -moveFromLocal &lt;localsrc&gt; &lt;dst&gt; </tt></p>
<p>Similar to put command, except that the source localsrc is deleted after it's copied.</p></div>
<div class="section">
<h2>moveToLocal<a name="moveToLocal"></a></h2>
<p>Usage: <tt>hdfs dfs -moveToLocal [-crc] &lt;src&gt; &lt;dst&gt; </tt></p>
<p>Displays a &quot;Not implemented yet&quot; message.</p></div>
<div class="section">
<h2>mv<a name="mv"></a></h2>
<p>Usage: <tt>hdfs dfs -mv URI [URI ...] &lt;dest&gt; </tt></p>
<p>Moves files from source to destination. This command allows multiple sources as well in which case the destination needs to be a directory. Moving files across file systems is not permitted.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -mv /user/hadoop/file1 /user/hadoop/file2</tt></li>
<li><tt>hdfs dfs -mv hdfs://nn.example.com/file1 hdfs://nn.example.com/file2 hdfs://nn.example.com/file3 hdfs://nn.example.com/dir1</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>put<a name="put"></a></h2>
<p>Usage: <tt>hdfs dfs -put &lt;localsrc&gt; ... &lt;dst&gt; </tt></p>
<p>Copy single src, or multiple srcs from local file system to the destination file system. Also reads input from stdin and writes to destination file system.</p>
<ul>
<li><tt>hdfs dfs -put localfile /user/hadoop/hadoopfile</tt></li>
<li><tt>hdfs dfs -put localfile1 localfile2 /user/hadoop/hadoopdir</tt></li>
<li><tt>hdfs dfs -put localfile hdfs://nn.example.com/hadoop/hadoopfile</tt></li>
<li><tt>hdfs dfs -put - hdfs://nn.example.com/hadoop/hadoopfile</tt> Reads the input from stdin.</li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>rm<a name="rm"></a></h2>
<p>Usage: <tt>hdfs dfs -rm [-skipTrash] URI [URI ...]</tt></p>
<p>Delete files specified as args. Only deletes non empty directory and files. If the -skipTrash option is specified, the trash, if enabled, will be bypassed and the specified file(s) deleted immediately. This can be useful when it is necessary to delete files from an over-quota directory. Refer to rmr for recursive deletes.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -rm hdfs://nn.example.com/file /user/hadoop/emptydir</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>rmr<a name="rmr"></a></h2>
<p>Usage: <tt>hdfs dfs -rmr [-skipTrash] URI [URI ...]</tt></p>
<p>Recursive version of delete. If the -skipTrash option is specified, the trash, if enabled, will be bypassed and the specified file(s) deleted immediately. This can be useful when it is necessary to delete files from an over-quota directory.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -rmr /user/hadoop/dir</tt></li>
<li><tt>hdfs dfs -rmr hdfs://nn.example.com/user/hadoop/dir</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>setrep<a name="setrep"></a></h2>
<p>Usage: <tt>hdfs dfs -setrep [-R] [-w] &lt;numReplicas&gt; &lt;path&gt; </tt></p>
<p>Changes the replication factor of a file. If <i>path</i> is a directory then the command recursively changes the replication factor of all files under the directory tree rooted at <i>path</i>.</p>
<p>Options:</p>
<ul>
<li>The -w flag requests that the command wait for the replication to complete. This can potentially take a very long time.</li>
<li>The -R flag is accepted for backwards compatibility. It has no effect.</li></ul>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -setrep -w 3 /user/hadoop/dir1</tt></li></ul>
<p>Exit Code:</p>
<p>Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>stat<a name="stat"></a></h2>
<p>Usage: <tt>hdfs dfs -stat URI [URI ...]</tt></p>
<p>Returns the stat information on the path.</p>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -stat path</tt></li></ul>
<p>Exit Code: Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>tail<a name="tail"></a></h2>
<p>Usage: <tt>hdfs dfs -tail [-f] URI</tt></p>
<p>Displays last kilobyte of the file to stdout.</p>
<p>Options:</p>
<ul>
<li>The -f option will output appended data as the file grows, as in Unix.</li></ul>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -tail pathname</tt></li></ul>
<p>Exit Code: Returns 0 on success and -1 on error.</p></div>
<div class="section">
<h2>test<a name="test"></a></h2>
<p>Usage: <tt>hdfs dfs -test -[ezd] URI</tt></p>
<p>Options:</p>
<ul>
<li>The -e option will check to see if the file exists, returning 0 if true.</li>
<li>The -z option will check to see if the file is zero length, returning 0 if true.</li>
<li>The -d option will check to see if the path is directory, returning 0 if true.</li></ul>
<p>Example:</p>
<ul>
<li><tt>hdfs dfs -test -e filename</tt></li></ul></div>
<div class="section">
<h2>text<a name="text"></a></h2>
<p>Usage: <tt>hdfs dfs -text &lt;src&gt; </tt></p>
<p>Takes a source file and outputs the file in text format. The allowed formats are zip and TextRecordInputStream.</p></div>
<div class="section">
<h2>touchz<a name="touchz"></a></h2>
<p>Usage: <tt>hdfs dfs -touchz URI [URI ...]</tt></p>
<p>Create a file of zero length.</p>
<p>Example:</p>
<ul>
<li><tt>hadoop -touchz pathname</tt></li></ul>
<p>Exit Code: Returns 0 on success and -1 on error.</p></div>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">&#169; 2014
Apache Software Foundation
- <a href="http://maven.apache.org/privacy-policy.html">Privacy Policy</a></div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>

Event Timeline