hdfs_shell.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  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.17 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="menupage">
  122. <div class="menupagetitle">HDFS Shell Guide</div>
  123. </div>
  124. <div class="menuitem">
  125. <a href="hdfs_permissions_guide.html">HDFS Permissions Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="mapred_tutorial.html">Map-Reduce Tutorial</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="native_libraries.html">Native Hadoop Libraries</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="streaming.html">Streaming</a>
  135. </div>
  136. <div class="menuitem">
  137. <a href="hod.html">Hadoop On Demand</a>
  138. </div>
  139. <div class="menuitem">
  140. <a href="api/index.html">API Docs</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="http://wiki.apache.org/hadoop/">Wiki</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="http://wiki.apache.org/hadoop/FAQ">FAQ</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="http://hadoop.apache.org/core/mailing_lists.html">Mailing Lists</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="changes.html">Release Notes</a>
  153. </div>
  154. </div>
  155. <div id="credit"></div>
  156. <div id="roundbottom">
  157. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  158. <!--+
  159. |alternative credits
  160. +-->
  161. <div id="credit2"></div>
  162. </div>
  163. <!--+
  164. |end Menu
  165. +-->
  166. <!--+
  167. |start content
  168. +-->
  169. <div id="content">
  170. <div title="Portable Document Format" class="pdflink">
  171. <a class="dida" href="hdfs_shell.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  172. PDF</a>
  173. </div>
  174. <h1>Hadoop Shell Commands</h1>
  175. <div id="minitoc-area">
  176. <ul class="minitoc">
  177. <li>
  178. <a href="#DFShell"> DFShell </a>
  179. </li>
  180. <li>
  181. <a href="#cat"> cat </a>
  182. </li>
  183. <li>
  184. <a href="#chgrp"> chgrp </a>
  185. </li>
  186. <li>
  187. <a href="#chmod"> chmod </a>
  188. </li>
  189. <li>
  190. <a href="#chown"> chown </a>
  191. </li>
  192. <li>
  193. <a href="#copyFromLocal">copyFromLocal</a>
  194. </li>
  195. <li>
  196. <a href="#copyToLocal"> copyToLocal</a>
  197. </li>
  198. <li>
  199. <a href="#cp"> cp </a>
  200. </li>
  201. <li>
  202. <a href="#du">du</a>
  203. </li>
  204. <li>
  205. <a href="#dus"> dus </a>
  206. </li>
  207. <li>
  208. <a href="#expunge"> expunge </a>
  209. </li>
  210. <li>
  211. <a href="#get"> get </a>
  212. </li>
  213. <li>
  214. <a href="#getmerge"> getmerge </a>
  215. </li>
  216. <li>
  217. <a href="#ls"> ls </a>
  218. </li>
  219. <li>
  220. <a href="#lsr">lsr</a>
  221. </li>
  222. <li>
  223. <a href="#mkdir"> mkdir </a>
  224. </li>
  225. <li>
  226. <a href="#movefromLocal"> movefromLocal </a>
  227. </li>
  228. <li>
  229. <a href="#mv"> mv </a>
  230. </li>
  231. <li>
  232. <a href="#put"> put </a>
  233. </li>
  234. <li>
  235. <a href="#rm"> rm </a>
  236. </li>
  237. <li>
  238. <a href="#rmr"> rmr </a>
  239. </li>
  240. <li>
  241. <a href="#setrep"> setrep </a>
  242. </li>
  243. <li>
  244. <a href="#stat"> stat </a>
  245. </li>
  246. <li>
  247. <a href="#tail"> tail </a>
  248. </li>
  249. <li>
  250. <a href="#test"> test </a>
  251. </li>
  252. <li>
  253. <a href="#text"> text </a>
  254. </li>
  255. <li>
  256. <a href="#touchz"> touchz </a>
  257. </li>
  258. </ul>
  259. </div>
  260. <a name="N1000D"></a><a name="DFShell"></a>
  261. <h2 class="h3"> DFShell </h2>
  262. <div class="section">
  263. <p>
  264. The HDFS shell is invoked by
  265. <span class="codefrag">bin/hadoop dfs &lt;args&gt;</span>.
  266. All the HDFS shell commands take path URIs as arguments. The URI format is <em>scheme://autority/path</em>. For HDFS the scheme is <em>hdfs</em>, and for the local filesystem the scheme is <em>file</em>. 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 <em>/parent/child</em> can be specified as <em>hdfs://namenode:namenodeport/parent/child</em> or simply as <em>/parent/child</em> (given that your configuration is set to point to <em>namenode:namenodeport</em>). Most of the commands in HDFS shell behave like corresponding Unix commands. Differences are described with each of the commands. Error information is sent to <em>stderr</em> and the output is sent to <em>stdout</em>.
  267. </p>
  268. </div>
  269. <a name="N10035"></a><a name="cat"></a>
  270. <h2 class="h3"> cat </h2>
  271. <div class="section">
  272. <p>
  273. <span class="codefrag">Usage: hadoop dfs -cat URI [URI &hellip;]</span>
  274. </p>
  275. <p>
  276. Copies source paths to <em>stdout</em>.
  277. </p>
  278. <p>Example:</p>
  279. <ul>
  280. <li>
  281. <span class="codefrag"> hadoop dfs -cat hdfs://host1:port1/file1 hdfs://host2:port2/file2
  282. </span>
  283. </li>
  284. <li>
  285. <span class="codefrag">hadoop dfs -cat file:///file3 /user/hadoop/file4 </span>
  286. </li>
  287. </ul>
  288. <p>Exit Code:<br>
  289. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  290. </p>
  291. </div>
  292. <a name="N10061"></a><a name="chgrp"></a>
  293. <h2 class="h3"> chgrp </h2>
  294. <div class="section">
  295. <p>
  296. <span class="codefrag">Usage: hadoop dfs -chgrp [-R] GROUP URI [URI &hellip;]</span>
  297. </p>
  298. <p>
  299. 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>.
  300. </p>
  301. </div>
  302. <a name="N10078"></a><a name="chmod"></a>
  303. <h2 class="h3"> chmod </h2>
  304. <div class="section">
  305. <p>
  306. <span class="codefrag">Usage: hadoop dfs -chmod [-R] &lt;MODE[,MODE]... | OCTALMODE&gt; URI [URI &hellip;]</span>
  307. </p>
  308. <p>
  309. 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>.
  310. </p>
  311. </div>
  312. <a name="N1008F"></a><a name="chown"></a>
  313. <h2 class="h3"> chown </h2>
  314. <div class="section">
  315. <p>
  316. <span class="codefrag">Usage: hadoop dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]</span>
  317. </p>
  318. <p>
  319. 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>.
  320. </p>
  321. </div>
  322. <a name="N100A6"></a><a name="copyFromLocal"></a>
  323. <h2 class="h3">copyFromLocal</h2>
  324. <div class="section">
  325. <p>
  326. <span class="codefrag">Usage: hadoop dfs -copyFromLocal &lt;localsrc&gt; URI</span>
  327. </p>
  328. <p>Similar to <a href="#putlink"><strong>put</strong></a> command, except that the source is restricted to a local file reference. </p>
  329. </div>
  330. <a name="N100BB"></a><a name="copyToLocal"></a>
  331. <h2 class="h3"> copyToLocal</h2>
  332. <div class="section">
  333. <p>
  334. <span class="codefrag">Usage: hadoop dfs -copyToLocal [-ignorecrc] [-crc] URI &lt;localdst&gt;</span>
  335. </p>
  336. <p> Similar to <a href="#getlink"><strong>get</strong></a> command, except that the destination is restricted to a local file reference.</p>
  337. </div>
  338. <a name="N100D0"></a><a name="cp"></a>
  339. <h2 class="h3"> cp </h2>
  340. <div class="section">
  341. <p>
  342. <span class="codefrag">Usage: hadoop dfs -cp URI [URI &hellip;] &lt;dest&gt;</span>
  343. </p>
  344. <p>
  345. Copy files from source to destination. This command allows multiple sources as well in which case the destination must be a directory.
  346. <br>
  347. Example:</p>
  348. <ul>
  349. <li>
  350. <span class="codefrag"> hadoop dfs -cp /user/hadoop/file1 /user/hadoop/file2</span>
  351. </li>
  352. <li>
  353. <span class="codefrag"> hadoop dfs -cp /user/hadoop/file1 /user/hadoop/file2 /user/hadoop/dir </span>
  354. </li>
  355. </ul>
  356. <p>Exit Code:</p>
  357. <p>
  358. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  359. </p>
  360. </div>
  361. <a name="N100FA"></a><a name="du"></a>
  362. <h2 class="h3">du</h2>
  363. <div class="section">
  364. <p>
  365. <span class="codefrag">Usage: hadoop dfs -du URI [URI &hellip;]</span>
  366. </p>
  367. <p>
  368. Displays aggregate length of files contained in the directory or the length of a file in case its just a file.<br>
  369. Example:<br>
  370. <span class="codefrag">hadoop dfs -du /user/hadoop/dir1 /user/hadoop/file1 hdfs://host:port/user/hadoop/dir1</span>
  371. <br>
  372. Exit Code:<br>
  373. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  374. <br>
  375. </p>
  376. </div>
  377. <a name="N10115"></a><a name="dus"></a>
  378. <h2 class="h3"> dus </h2>
  379. <div class="section">
  380. <p>
  381. <span class="codefrag">Usage: hadoop dfs -dus &lt;args&gt;</span>
  382. </p>
  383. <p>
  384. Displays a summary of file lengths.
  385. </p>
  386. </div>
  387. <a name="N10125"></a><a name="expunge"></a>
  388. <h2 class="h3"> expunge </h2>
  389. <div class="section">
  390. <p>
  391. <span class="codefrag">Usage: hadoop dfs -expunge</span>
  392. </p>
  393. <p>Empty the Trash. Refer to <a href="hdfs_design.html">HDFS Design</a> for more information on Trash feature.
  394. </p>
  395. </div>
  396. <a name="N10139"></a><a name="get"></a>
  397. <h2 class="h3"> get </h2>
  398. <div class="section">
  399. <p>
  400. <span class="codefrag">Usage: hadoop dfs -get [-ignorecrc] [-crc] &lt;src&gt; &lt;localdst&gt;</span>
  401. <br>
  402. </p>
  403. <p>
  404. Copy files to the local file system. Files that fail the CRC check may be copied with the
  405. <span class="codefrag">-ignorecrc</span> option. Files and CRCs may be copied using the
  406. <span class="codefrag">-crc</span> option.
  407. </p>
  408. <p>Example:</p>
  409. <ul>
  410. <li>
  411. <span class="codefrag"> hadoop dfs -get /user/hadoop/file localfile </span>
  412. </li>
  413. <li>
  414. <span class="codefrag"> hadoop dfs -get hdfs://host:port/user/hadoop/file localfile</span>
  415. </li>
  416. </ul>
  417. <p>Exit Code:</p>
  418. <p>
  419. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  420. </p>
  421. </div>
  422. <a name="N1016D"></a><a name="getmerge"></a>
  423. <h2 class="h3"> getmerge </h2>
  424. <div class="section">
  425. <p>
  426. <span class="codefrag">Usage: hadoop dfs -getmerge &lt;src&gt; &lt;localdst&gt; [addnl]</span>
  427. </p>
  428. <p>
  429. 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.
  430. </p>
  431. </div>
  432. <a name="N10180"></a><a name="ls"></a>
  433. <h2 class="h3"> ls </h2>
  434. <div class="section">
  435. <p>
  436. <span class="codefrag">Usage: hadoop dfs -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 dfs -ls /user/hadoop/file1 /user/hadoop/file2 hdfs://host:port/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. </div>
  454. <a name="N101A3"></a><a name="lsr"></a>
  455. <h2 class="h3">lsr</h2>
  456. <div class="section">
  457. <p>
  458. <span class="codefrag">Usage: hadoop dfs -lsr &lt;args&gt;</span>
  459. <br>
  460. Recursive version of <span class="codefrag">ls</span>. Similar to Unix <span class="codefrag">ls -R</span>.
  461. </p>
  462. </div>
  463. <a name="N101B6"></a><a name="mkdir"></a>
  464. <h2 class="h3"> mkdir </h2>
  465. <div class="section">
  466. <p>
  467. <span class="codefrag">Usage: hadoop dfs -mkdir &lt;paths&gt;</span>
  468. <br>
  469. </p>
  470. <p>
  471. Takes path uri's as argument and creates directories. The behavior is much like unix mkdir -p creating parent directories along the path.
  472. </p>
  473. <p>Example:</p>
  474. <ul>
  475. <li>
  476. <span class="codefrag">hadoop dfs -mkdir /user/hadoop/dir1 /user/hadoop/dir2 </span>
  477. </li>
  478. <li>
  479. <span class="codefrag">hadoop dfs -mkdir hdfs://host1:port1/user/hadoop/dir hdfs://host2:port2/user/hadoop/dir
  480. </span>
  481. </li>
  482. </ul>
  483. <p>Exit Code:</p>
  484. <p>
  485. <span class="codefrag">Returns 0 on success and -1 on error.</span>
  486. </p>
  487. </div>
  488. <a name="N101E3"></a><a name="movefromLocal"></a>
  489. <h2 class="h3"> movefromLocal </h2>
  490. <div class="section">
  491. <p>
  492. <span class="codefrag">Usage: dfs -moveFromLocal &lt;src&gt; &lt;dst&gt;</span>
  493. </p>
  494. <p>Displays a "not implemented" message.
  495. </p>
  496. </div>
  497. <a name="N101F3"></a><a name="mv"></a>
  498. <h2 class="h3"> mv </h2>
  499. <div class="section">
  500. <p>
  501. <span class="codefrag">Usage: hadoop dfs -mv URI [URI &hellip;] &lt;dest&gt;</span>
  502. </p>
  503. <p>
  504. 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.
  505. <br>
  506. Example:
  507. </p>
  508. <ul>
  509. <li>
  510. <span class="codefrag"> hadoop dfs -mv /user/hadoop/file1 /user/hadoop/file2</span>
  511. </li>
  512. <li>
  513. <span class="codefrag"> hadoop dfs -mv hdfs://host:port/file1 hdfs://host:port/file2 hdfs://host:port/file3 hdfs://host:port/dir1</span>
  514. </li>
  515. </ul>
  516. <p>Exit Code:</p>
  517. <p>
  518. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  519. </p>
  520. </div>
  521. <a name="N1021D"></a><a name="put"></a>
  522. <h2 class="h3"> put </h2>
  523. <div class="section">
  524. <p>
  525. <span class="codefrag">Usage: hadoop dfs -put &lt;localsrc&gt; ... &lt;dst&gt;</span>
  526. </p>
  527. <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>
  528. </p>
  529. <ul>
  530. <li>
  531. <span class="codefrag"> hadoop dfs -put localfile /user/hadoop/hadoopfile</span>
  532. </li>
  533. <li>
  534. <span class="codefrag"> hadoop dfs -put localfile1 localfile2 /user/hadoop/hadoopdir</span>
  535. </li>
  536. <li>
  537. <span class="codefrag"> hadoop dfs -put localfile hdfs://host:port/hadoop/hadoopfile</span>
  538. </li>
  539. <li>
  540. <span class="codefrag">hadoop dfs -put - hdfs://host:port/hadoop/hadoopfile</span>
  541. <br>Reads the input from stdin.</li>
  542. </ul>
  543. <p>Exit Code:</p>
  544. <p>
  545. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  546. </p>
  547. </div>
  548. <a name="N10254"></a><a name="rm"></a>
  549. <h2 class="h3"> rm </h2>
  550. <div class="section">
  551. <p>
  552. <span class="codefrag">Usage: hadoop dfs -rm URI [URI &hellip;] </span>
  553. </p>
  554. <p>
  555. Delete files specified as args. Only deletes non empty directory and files. Refer to rmr for recursive deletes.<br>
  556. Example:
  557. </p>
  558. <ul>
  559. <li>
  560. <span class="codefrag"> hadoop dfs -rm hdfs://host:port/file /user/hadoop/emptydir </span>
  561. </li>
  562. </ul>
  563. <p>Exit Code:</p>
  564. <p>
  565. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  566. </p>
  567. </div>
  568. <a name="N10278"></a><a name="rmr"></a>
  569. <h2 class="h3"> rmr </h2>
  570. <div class="section">
  571. <p>
  572. <span class="codefrag">Usage: hadoop dfs -rmr URI [URI &hellip;]</span>
  573. </p>
  574. <p>Recursive version of delete.<br>
  575. Example:
  576. </p>
  577. <ul>
  578. <li>
  579. <span class="codefrag"> hadoop dfs -rmr /user/hadoop/dir </span>
  580. </li>
  581. <li>
  582. <span class="codefrag"> hadoop dfs -rmr hdfs://host:port/user/hadoop/dir </span>
  583. </li>
  584. </ul>
  585. <p>Exit Code:</p>
  586. <p>
  587. <span class="codefrag"> Returns 0 on success and -1 on error. </span>
  588. </p>
  589. </div>
  590. <a name="N102A2"></a><a name="setrep"></a>
  591. <h2 class="h3"> setrep </h2>
  592. <div class="section">
  593. <p>
  594. <span class="codefrag">Usage: hadoop dfs -setrep [-R] &lt;path&gt;</span>
  595. </p>
  596. <p>
  597. Changes the replication factor of a file. -R option is for recursively increasing the replication factor of files within a directory.
  598. </p>
  599. <p>Example:</p>
  600. <ul>
  601. <li>
  602. <span class="codefrag"> hadoop dfs -setrep -w 3 -R /user/hadoop/dir1 </span>
  603. </li>
  604. </ul>
  605. <p>Exit Code:</p>
  606. <p>
  607. <span class="codefrag">Returns 0 on success and -1 on error. </span>
  608. </p>
  609. </div>
  610. <a name="N102C7"></a><a name="stat"></a>
  611. <h2 class="h3"> stat </h2>
  612. <div class="section">
  613. <p>
  614. <span class="codefrag">Usage: hadoop dfs -stat URI [URI &hellip;]</span>
  615. </p>
  616. <p>
  617. Returns the stat information on the path.
  618. </p>
  619. <p>Example:</p>
  620. <ul>
  621. <li>
  622. <span class="codefrag"> hadoop dfs -stat path </span>
  623. </li>
  624. </ul>
  625. <p>Exit Code:<br>
  626. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  627. </p>
  628. </div>
  629. <a name="N102EA"></a><a name="tail"></a>
  630. <h2 class="h3"> tail </h2>
  631. <div class="section">
  632. <p>
  633. <span class="codefrag">Usage: hadoop dfs -tail [-f] URI </span>
  634. </p>
  635. <p>
  636. Displays last kilobyte of the file to stdout. -f option can be used as in Unix.
  637. </p>
  638. <p>Example:</p>
  639. <ul>
  640. <li>
  641. <span class="codefrag"> hadoop dfs -tail pathname </span>
  642. </li>
  643. </ul>
  644. <p>Exit Code: <br>
  645. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  646. </p>
  647. </div>
  648. <a name="N1030D"></a><a name="test"></a>
  649. <h2 class="h3"> test </h2>
  650. <div class="section">
  651. <p>
  652. <span class="codefrag">Usage: hadoop dfs -test -[ezd] URI</span>
  653. </p>
  654. <p>
  655. Options: <br>
  656. -e check to see if the file exists. Return 0 if true. <br>
  657. -z check to see if the file is zero length. Return 0 if true <br>
  658. -d check return 1 if the path is directory else return 0. <br>
  659. </p>
  660. <p>Example:</p>
  661. <ul>
  662. <li>
  663. <span class="codefrag"> hadoop dfs -test -e filename </span>
  664. </li>
  665. </ul>
  666. </div>
  667. <a name="N10330"></a><a name="text"></a>
  668. <h2 class="h3"> text </h2>
  669. <div class="section">
  670. <p>
  671. <span class="codefrag">Usage: hadoop dfs -text &lt;src&gt;</span>
  672. <br>
  673. </p>
  674. <p>
  675. Takes a source file and outputs the file in text format. The allowed formats are zip and TextRecordInputStream.
  676. </p>
  677. </div>
  678. <a name="N10342"></a><a name="touchz"></a>
  679. <h2 class="h3"> touchz </h2>
  680. <div class="section">
  681. <p>
  682. <span class="codefrag">Usage: hadoop dfs -touchz URI [URI &hellip;]</span>
  683. <br>
  684. </p>
  685. <p>
  686. Create a file of zero length.
  687. </p>
  688. <p>Example:</p>
  689. <ul>
  690. <li>
  691. <span class="codefrag"> hadoop -touchz pathname </span>
  692. </li>
  693. </ul>
  694. <p>Exit Code:<br>
  695. <span class="codefrag"> Returns 0 on success and -1 on error.</span>
  696. </p>
  697. </div>
  698. </div>
  699. <!--+
  700. |end content
  701. +-->
  702. <div class="clearboth">&nbsp;</div>
  703. </div>
  704. <div id="footer">
  705. <!--+
  706. |start bottomstrip
  707. +-->
  708. <div class="lastmodified">
  709. <script type="text/javascript"><!--
  710. document.write("Last Published: " + document.lastModified);
  711. // --></script>
  712. </div>
  713. <div class="copyright">
  714. Copyright &copy;
  715. 2007 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  716. </div>
  717. <!--+
  718. |end bottomstrip
  719. +-->
  720. </div>
  721. </body>
  722. </html>