hdfs_shell.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.8">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>Hadoop Shell Commands</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://hadoop.apache.org/">Hadoop</a> &gt; <a href="http://hadoop.apache.org/core/">Core</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://hadoop.apache.org/core/"><img class="logoImage" alt="Hadoop" src="images/core-logo.gif" title="Scalable Computing Platform"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="hadoop.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://hadoop.apache.org/core/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">Hadoop 0.18 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Documentation</div>
  105. <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
  106. <div class="menuitem">
  107. <a href="index.html">Overview</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="quickstart.html">Quickstart</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="cluster_setup.html">Cluster Setup</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="hdfs_design.html">HDFS Architecture</a>
  117. </div>
  118. <div class="menuitem">
  119. <a href="hdfs_user_guide.html">HDFS User Guide</a>
  120. </div>
  121. <div class="menuitem">
  122. <a href="hdfs_permissions_guide.html">HDFS Permissions Guide</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="hdfs_quota_admin_guide.html">HDFS Quotas Administrator Guide</a>
  126. </div>
  127. <div class="menupage">
  128. <div class="menupagetitle">FS Shell Guide</div>
  129. </div>
  130. <div class="menuitem">
  131. <a href="distcp.html">DistCp Guide</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="mapred_tutorial.html">Map-Reduce Tutorial</a>
  135. </div>
  136. <div class="menuitem">
  137. <a href="native_libraries.html">Native Hadoop Libraries</a>
  138. </div>
  139. <div class="menuitem">
  140. <a href="streaming.html">Streaming</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="hadoop_archives.html">Hadoop Archives</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="hod.html">Hadoop On Demand</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="api/index.html">API Docs</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="http://wiki.apache.org/hadoop/">Wiki</a>
  153. </div>
  154. <div class="menuitem">
  155. <a href="http://wiki.apache.org/hadoop/FAQ">FAQ</a>
  156. </div>
  157. <div class="menuitem">
  158. <a href="http://hadoop.apache.org/core/mailing_lists.html">Mailing Lists</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="releasenotes.html">Release Notes</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="changes.html">All Changes</a>
  165. </div>
  166. </div>
  167. <div id="credit"></div>
  168. <div id="roundbottom">
  169. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  170. <!--+
  171. |alternative credits
  172. +-->
  173. <div id="credit2"></div>
  174. </div>
  175. <!--+
  176. |end Menu
  177. +-->
  178. <!--+
  179. |start content
  180. +-->
  181. <div id="content">
  182. <div title="Portable Document Format" class="pdflink">
  183. <a class="dida" href="hdfs_shell.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  184. PDF</a>
  185. </div>
  186. <h1>Hadoop Shell Commands</h1>
  187. <div id="minitoc-area">
  188. <ul class="minitoc">
  189. <li>
  190. <a href="#FS+Shell"> FS Shell </a>
  191. <ul class="minitoc">
  192. <li>
  193. <a href="#cat"> cat </a>
  194. </li>
  195. <li>
  196. <a href="#chgrp"> chgrp </a>
  197. </li>
  198. <li>
  199. <a href="#chmod"> chmod </a>
  200. </li>
  201. <li>
  202. <a href="#chown"> chown </a>
  203. </li>
  204. <li>
  205. <a href="#copyFromLocal">copyFromLocal</a>
  206. </li>
  207. <li>
  208. <a href="#copyToLocal"> copyToLocal</a>
  209. </li>
  210. <li>
  211. <a href="#cp"> cp </a>
  212. </li>
  213. <li>
  214. <a href="#du">du</a>
  215. </li>
  216. <li>
  217. <a href="#dus"> dus </a>
  218. </li>
  219. <li>
  220. <a href="#expunge"> expunge </a>
  221. </li>
  222. <li>
  223. <a href="#get"> get </a>
  224. </li>
  225. <li>
  226. <a href="#getmerge"> getmerge </a>
  227. </li>
  228. <li>
  229. <a href="#ls"> ls </a>
  230. </li>
  231. <li>
  232. <a href="#lsr">lsr</a>
  233. </li>
  234. <li>
  235. <a href="#mkdir"> mkdir </a>
  236. </li>
  237. <li>
  238. <a href="#movefromLocal"> movefromLocal </a>
  239. </li>
  240. <li>
  241. <a href="#mv"> mv </a>
  242. </li>
  243. <li>
  244. <a href="#put"> put </a>
  245. </li>
  246. <li>
  247. <a href="#rm"> rm </a>
  248. </li>
  249. <li>
  250. <a href="#rmr"> rmr </a>
  251. </li>
  252. <li>
  253. <a href="#setrep"> setrep </a>
  254. </li>
  255. <li>
  256. <a href="#stat"> stat </a>
  257. </li>
  258. <li>
  259. <a href="#tail"> tail </a>
  260. </li>
  261. <li>
  262. <a href="#test"> test </a>
  263. </li>
  264. <li>
  265. <a href="#text"> text </a>
  266. </li>
  267. <li>
  268. <a href="#touchz"> touchz </a>
  269. </li>
  270. </ul>
  271. </li>
  272. </ul>
  273. </div>
  274. <a name="N1000D"></a><a name="FS+Shell"></a>
  275. <h2 class="h3"> FS Shell </h2>
  276. <div class="section">
  277. <p>
  278. The FileSystem (FS) shell is invoked by
  279. <span class="codefrag">bin/hadoop fs &lt;args&gt;</span>.
  280. All the FS shell commands take path URIs as arguments. The URI
  281. format is <em>scheme://autority/path</em>. For HDFS the scheme
  282. is <em>hdfs</em>, and for the local filesystem the scheme
  283. is <em>file</em>. The scheme and authority are optional. If not
  284. specified, the default scheme specified in the configuration is
  285. used. An HDFS file or directory such as <em>/parent/child</em>
  286. can be specified as <em>hdfs://namenodehost/parent/child</em> or
  287. simply as <em>/parent/child</em> (given that your configuration
  288. is set to point to <em>hdfs://namenodehost</em>). Most of the
  289. commands in FS shell behave like corresponding Unix
  290. commands. Differences are described with each of the
  291. commands. Error information is sent to <em>stderr</em> and the
  292. output is sent to <em>stdout</em>.
  293. </p>
  294. <a name="N10034"></a><a name="cat"></a>
  295. <h3 class="h4"> cat </h3>
  296. <p>
  297. <span class="codefrag">Usage: hadoop fs -cat URI [URI &hellip;]</span>
  298. </p>
  299. <p>
  300. Copies source paths to <em>stdout</em>.
  301. </p>
  302. <p>Example:</p>
  303. <ul>
  304. <li>
  305. <span class="codefrag"> hadoop fs -cat hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
  306. </span>
  307. </li>
  308. <li>
  309. <span class="codefrag">hadoop fs -cat file:///file3 /user/hadoop/file4 </span>
  310. </li>
  311. </ul>
  312. <p>Exit Code:<br>
  313. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  314. </p>
  315. <a name="N10060"></a><a name="chgrp"></a>
  316. <h3 class="h4"> chgrp </h3>
  317. <p>
  318. <span class="codefrag">Usage: hadoop fs -chgrp [-R] GROUP URI [URI &hellip;]</span>
  319. </p>
  320. <p>
  321. Change group association of files. With <span class="codefrag">-R</span>, make the change recursively through the directory structure. The user must be the owner of files, or else a super-user. Additional information is in the <a href="hdfs_permissions_guide.html">Permissions User Guide</a>.
  322. </p>
  323. <a name="N10077"></a><a name="chmod"></a>
  324. <h3 class="h4"> chmod </h3>
  325. <p>
  326. <span class="codefrag">Usage: hadoop fs -chmod [-R] &lt;MODE[,MODE]... | OCTALMODE&gt; URI [URI &hellip;]</span>
  327. </p>
  328. <p>
  329. Change the permissions of files. With <span class="codefrag">-R</span>, 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="hdfs_permissions_guide.html">Permissions User Guide</a>.
  330. </p>
  331. <a name="N1008E"></a><a name="chown"></a>
  332. <h3 class="h4"> chown </h3>
  333. <p>
  334. <span class="codefrag">Usage: hadoop fs -chown [-R] [OWNER][:[GROUP]] URI [URI ]</span>
  335. </p>
  336. <p>
  337. Change the owner of files. With <span class="codefrag">-R</span>, make the change recursively through the directory structure. The user must be a super-user. Additional information is in the <a href="hdfs_permissions_guide.html">Permissions User Guide</a>.
  338. </p>
  339. <a name="N100A5"></a><a name="copyFromLocal"></a>
  340. <h3 class="h4">copyFromLocal</h3>
  341. <p>
  342. <span class="codefrag">Usage: hadoop fs -copyFromLocal &lt;localsrc&gt; URI</span>
  343. </p>
  344. <p>Similar to <a href="#putlink"><strong>put</strong></a> command, except that the source is restricted to a local file reference. </p>
  345. <a name="N100BA"></a><a name="copyToLocal"></a>
  346. <h3 class="h4"> copyToLocal</h3>
  347. <p>
  348. <span class="codefrag">Usage: hadoop fs -copyToLocal [-ignorecrc] [-crc] URI &lt;localdst&gt;</span>
  349. </p>
  350. <p> Similar to <a href="#getlink"><strong>get</strong></a> command, except that the destination is restricted to a local file reference.</p>
  351. <a name="N100CF"></a><a name="cp"></a>
  352. <h3 class="h4"> cp </h3>
  353. <p>
  354. <span class="codefrag">Usage: hadoop fs -cp URI [URI &hellip;] &lt;dest&gt;</span>
  355. </p>
  356. <p>
  357. Copy files from source to destination. This command allows multiple sources as well in which case the destination must be a directory.
  358. <br>
  359. Example:</p>
  360. <ul>
  361. <li>
  362. <span class="codefrag"> hadoop fs -cp /user/hadoop/file1 /user/hadoop/file2</span>
  363. </li>
  364. <li>
  365. <span class="codefrag"> hadoop fs -cp /user/hadoop/file1 /user/hadoop/file2 /user/hadoop/dir </span>
  366. </li>
  367. </ul>
  368. <p>Exit Code:</p>
  369. <p>
  370. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  371. </p>
  372. <a name="N100F9"></a><a name="du"></a>
  373. <h3 class="h4">du</h3>
  374. <p>
  375. <span class="codefrag">Usage: hadoop fs -du URI [URI &hellip;]</span>
  376. </p>
  377. <p>
  378. Displays aggregate length of files contained in the directory or the length of a file in case its just a file.<br>
  379. Example:<br>
  380. <span class="codefrag">hadoop fs -du /user/hadoop/dir1 /user/hadoop/file1 hdfs://nn.example.com/user/hadoop/dir1</span>
  381. <br>
  382. Exit Code:<br>
  383. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  384. <br>
  385. </p>
  386. <a name="N10114"></a><a name="dus"></a>
  387. <h3 class="h4"> dus </h3>
  388. <p>
  389. <span class="codefrag">Usage: hadoop fs -dus &lt;args&gt;</span>
  390. </p>
  391. <p>
  392. Displays a summary of file lengths.
  393. </p>
  394. <a name="N10124"></a><a name="expunge"></a>
  395. <h3 class="h4"> expunge </h3>
  396. <p>
  397. <span class="codefrag">Usage: hadoop fs -expunge</span>
  398. </p>
  399. <p>Empty the Trash. Refer to <a href="hdfs_design.html">HDFS Design</a> for more information on Trash feature.
  400. </p>
  401. <a name="N10138"></a><a name="get"></a>
  402. <h3 class="h4"> get </h3>
  403. <p>
  404. <span class="codefrag">Usage: hadoop fs -get [-ignorecrc] [-crc] &lt;src&gt; &lt;localdst&gt;</span>
  405. <br>
  406. </p>
  407. <p>
  408. Copy files to the local file system. Files that fail the CRC check may be copied with the
  409. <span class="codefrag">-ignorecrc</span> option. Files and CRCs may be copied using the
  410. <span class="codefrag">-crc</span> option.
  411. </p>
  412. <p>Example:</p>
  413. <ul>
  414. <li>
  415. <span class="codefrag"> hadoop fs -get /user/hadoop/file localfile </span>
  416. </li>
  417. <li>
  418. <span class="codefrag"> hadoop fs -get hdfs://nn.example.com/user/hadoop/file localfile</span>
  419. </li>
  420. </ul>
  421. <p>Exit Code:</p>
  422. <p>
  423. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  424. </p>
  425. <a name="N1016C"></a><a name="getmerge"></a>
  426. <h3 class="h4"> getmerge </h3>
  427. <p>
  428. <span class="codefrag">Usage: hadoop fs -getmerge &lt;src&gt; &lt;localdst&gt; [addnl]</span>
  429. </p>
  430. <p>
  431. Takes a source directory and a destination file as input and concatenates files in src into the destination local file. Optionally <span class="codefrag">addnl</span> can be set to enable adding a newline character at the end of each file.
  432. </p>
  433. <a name="N1017F"></a><a name="ls"></a>
  434. <h3 class="h4"> ls </h3>
  435. <p>
  436. <span class="codefrag">Usage: hadoop fs -ls &lt;args&gt;</span>
  437. </p>
  438. <p>
  439. For a file returns stat on the file with the following format:<br>
  440. <span class="codefrag">filename &lt;number of replicas&gt; filesize modification_date modification_time permissions userid groupid</span>
  441. <br>
  442. For a directory it returns list of its direct children as in unix.
  443. A directory is listed as: <br>
  444. <span class="codefrag">dirname &lt;dir&gt; modification_time modification_time permissions userid groupid</span>
  445. <br>
  446. Example:<br>
  447. <span class="codefrag">hadoop fs -ls /user/hadoop/file1 /user/hadoop/file2 hdfs://nn.example.com/user/hadoop/dir1 /nonexistentfile</span>
  448. <br>
  449. Exit Code:<br>
  450. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  451. <br>
  452. </p>
  453. <a name="N101A2"></a><a name="lsr"></a>
  454. <h3 class="h4">lsr</h3>
  455. <p>
  456. <span class="codefrag">Usage: hadoop fs -lsr &lt;args&gt;</span>
  457. <br>
  458. Recursive version of <span class="codefrag">ls</span>. Similar to Unix <span class="codefrag">ls -R</span>.
  459. </p>
  460. <a name="N101B5"></a><a name="mkdir"></a>
  461. <h3 class="h4"> mkdir </h3>
  462. <p>
  463. <span class="codefrag">Usage: hadoop fs -mkdir &lt;paths&gt;</span>
  464. <br>
  465. </p>
  466. <p>
  467. Takes path uri's as argument and creates directories. The behavior is much like unix mkdir -p creating parent directories along the path.
  468. </p>
  469. <p>Example:</p>
  470. <ul>
  471. <li>
  472. <span class="codefrag">hadoop fs -mkdir /user/hadoop/dir1 /user/hadoop/dir2 </span>
  473. </li>
  474. <li>
  475. <span class="codefrag">hadoop fs -mkdir hdfs://nn1.example.com/user/hadoop/dir hdfs://nn2.example.com/user/hadoop/dir
  476. </span>
  477. </li>
  478. </ul>
  479. <p>Exit Code:</p>
  480. <p>
  481. <span class="codefrag">Returns 0 on success and -1 on error.</span>
  482. </p>
  483. <a name="N101E2"></a><a name="movefromLocal"></a>
  484. <h3 class="h4"> movefromLocal </h3>
  485. <p>
  486. <span class="codefrag">Usage: dfs -moveFromLocal &lt;src&gt; &lt;dst&gt;</span>
  487. </p>
  488. <p>Displays a "not implemented" message.
  489. </p>
  490. <a name="N101F2"></a><a name="mv"></a>
  491. <h3 class="h4"> mv </h3>
  492. <p>
  493. <span class="codefrag">Usage: hadoop fs -mv URI [URI &hellip;] &lt;dest&gt;</span>
  494. </p>
  495. <p>
  496. 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 filesystems is not permitted.
  497. <br>
  498. Example:
  499. </p>
  500. <ul>
  501. <li>
  502. <span class="codefrag"> hadoop fs -mv /user/hadoop/file1 /user/hadoop/file2</span>
  503. </li>
  504. <li>
  505. <span class="codefrag"> hadoop fs -mv hdfs://nn.example.com/file1 hdfs://nn.example.com/file2 hdfs://nn.example.com/file3 hdfs://nn.example.com/dir1</span>
  506. </li>
  507. </ul>
  508. <p>Exit Code:</p>
  509. <p>
  510. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  511. </p>
  512. <a name="N1021C"></a><a name="put"></a>
  513. <h3 class="h4"> put </h3>
  514. <p>
  515. <span class="codefrag">Usage: hadoop fs -put &lt;localsrc&gt; ... &lt;dst&gt;</span>
  516. </p>
  517. <p>Copy single src, or multiple srcs from local file system to the destination filesystem. Also reads input from stdin and writes to destination filesystem.<br>
  518. </p>
  519. <ul>
  520. <li>
  521. <span class="codefrag"> hadoop fs -put localfile /user/hadoop/hadoopfile</span>
  522. </li>
  523. <li>
  524. <span class="codefrag"> hadoop fs -put localfile1 localfile2 /user/hadoop/hadoopdir</span>
  525. </li>
  526. <li>
  527. <span class="codefrag"> hadoop fs -put localfile hdfs://nn.example.com/hadoop/hadoopfile</span>
  528. </li>
  529. <li>
  530. <span class="codefrag">hadoop fs -put - hdfs://nn.example.com/hadoop/hadoopfile</span>
  531. <br>Reads the input from stdin.</li>
  532. </ul>
  533. <p>Exit Code:</p>
  534. <p>
  535. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  536. </p>
  537. <a name="N10253"></a><a name="rm"></a>
  538. <h3 class="h4"> rm </h3>
  539. <p>
  540. <span class="codefrag">Usage: hadoop fs -rm URI [URI &hellip;] </span>
  541. </p>
  542. <p>
  543. Delete files specified as args. Only deletes non empty directory and files. Refer to rmr for recursive deletes.<br>
  544. Example:
  545. </p>
  546. <ul>
  547. <li>
  548. <span class="codefrag"> hadoop fs -rm hdfs://nn.example.com/file /user/hadoop/emptydir </span>
  549. </li>
  550. </ul>
  551. <p>Exit Code:</p>
  552. <p>
  553. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  554. </p>
  555. <a name="N10277"></a><a name="rmr"></a>
  556. <h3 class="h4"> rmr </h3>
  557. <p>
  558. <span class="codefrag">Usage: hadoop fs -rmr URI [URI &hellip;]</span>
  559. </p>
  560. <p>Recursive version of delete.<br>
  561. Example:
  562. </p>
  563. <ul>
  564. <li>
  565. <span class="codefrag"> hadoop fs -rmr /user/hadoop/dir </span>
  566. </li>
  567. <li>
  568. <span class="codefrag"> hadoop fs -rmr hdfs://nn.example.com/user/hadoop/dir </span>
  569. </li>
  570. </ul>
  571. <p>Exit Code:</p>
  572. <p>
  573. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  574. </p>
  575. <a name="N102A1"></a><a name="setrep"></a>
  576. <h3 class="h4"> setrep </h3>
  577. <p>
  578. <span class="codefrag">Usage: hadoop fs -setrep [-R] &lt;path&gt;</span>
  579. </p>
  580. <p>
  581. Changes the replication factor of a file. -R option is for recursively increasing the replication factor of files within a directory.
  582. </p>
  583. <p>Example:</p>
  584. <ul>
  585. <li>
  586. <span class="codefrag"> hadoop fs -setrep -w 3 -R /user/hadoop/dir1 </span>
  587. </li>
  588. </ul>
  589. <p>Exit Code:</p>
  590. <p>
  591. <span class="codefrag">Returns 0 on success and -1 on error. </span>
  592. </p>
  593. <a name="N102C6"></a><a name="stat"></a>
  594. <h3 class="h4"> stat </h3>
  595. <p>
  596. <span class="codefrag">Usage: hadoop fs -stat URI [URI &hellip;]</span>
  597. </p>
  598. <p>
  599. Returns the stat information on the path.
  600. </p>
  601. <p>Example:</p>
  602. <ul>
  603. <li>
  604. <span class="codefrag"> hadoop fs -stat path </span>
  605. </li>
  606. </ul>
  607. <p>Exit Code:<br>
  608. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  609. </p>
  610. <a name="N102E9"></a><a name="tail"></a>
  611. <h3 class="h4"> tail </h3>
  612. <p>
  613. <span class="codefrag">Usage: hadoop fs -tail [-f] URI </span>
  614. </p>
  615. <p>
  616. Displays last kilobyte of the file to stdout. -f option can be used as in Unix.
  617. </p>
  618. <p>Example:</p>
  619. <ul>
  620. <li>
  621. <span class="codefrag"> hadoop fs -tail pathname </span>
  622. </li>
  623. </ul>
  624. <p>Exit Code: <br>
  625. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  626. </p>
  627. <a name="N1030C"></a><a name="test"></a>
  628. <h3 class="h4"> test </h3>
  629. <p>
  630. <span class="codefrag">Usage: hadoop fs -test -[ezd] URI</span>
  631. </p>
  632. <p>
  633. Options: <br>
  634. -e check to see if the file exists. Return 0 if true. <br>
  635. -z check to see if the file is zero length. Return 0 if true <br>
  636. -d check return 1 if the path is directory else return 0. <br>
  637. </p>
  638. <p>Example:</p>
  639. <ul>
  640. <li>
  641. <span class="codefrag"> hadoop fs -test -e filename </span>
  642. </li>
  643. </ul>
  644. <a name="N1032F"></a><a name="text"></a>
  645. <h3 class="h4"> text </h3>
  646. <p>
  647. <span class="codefrag">Usage: hadoop fs -text &lt;src&gt;</span>
  648. <br>
  649. </p>
  650. <p>
  651. Takes a source file and outputs the file in text format. The allowed formats are zip and TextRecordInputStream.
  652. </p>
  653. <a name="N10341"></a><a name="touchz"></a>
  654. <h3 class="h4"> touchz </h3>
  655. <p>
  656. <span class="codefrag">Usage: hadoop fs -touchz URI [URI &hellip;]</span>
  657. <br>
  658. </p>
  659. <p>
  660. Create a file of zero length.
  661. </p>
  662. <p>Example:</p>
  663. <ul>
  664. <li>
  665. <span class="codefrag"> hadoop -touchz pathname </span>
  666. </li>
  667. </ul>
  668. <p>Exit Code:<br>
  669. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  670. </p>
  671. </div>
  672. </div>
  673. <!--+
  674. |end content
  675. +-->
  676. <div class="clearboth">&nbsp;</div>
  677. </div>
  678. <div id="footer">
  679. <!--+
  680. |start bottomstrip
  681. +-->
  682. <div class="lastmodified">
  683. <script type="text/javascript"><!--
  684. document.write("Last Published: " + document.lastModified);
  685. // --></script>
  686. </div>
  687. <div class="copyright">
  688. Copyright &copy;
  689. 2007 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  690. </div>
  691. <!--+
  692. |end bottomstrip
  693. +-->
  694. </div>
  695. </body>
  696. </html>