hdfs_shell.html 23 KB

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