index.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>๐Ÿญ Bye Bye Mouse</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <style>
  8. :root {
  9. --primary: #4f8cff;
  10. --accent: #ffb86c;
  11. --bg-light: #f7f8fa;
  12. --bg-dark: #181a1b;
  13. --text-light: #222;
  14. --text-dark: #f7f8fa;
  15. --card-light: #fff;
  16. --card-dark: #23272e;
  17. --border-light: #e0e0e0;
  18. --border-dark: #333;
  19. --code-bg-light: #f4f4f4;
  20. --code-bg-dark: #23272e;
  21. --kbd-bg-light: #eaeaea;
  22. --kbd-bg-dark: #333;
  23. --kbd-text-light: #222;
  24. --kbd-text-dark: #f7f8fa;
  25. }
  26. html {
  27. scroll-behavior: smooth;
  28. }
  29. body {
  30. font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  31. background: var(--bg-light);
  32. color: var(--text-light);
  33. margin: 0;
  34. padding: 0;
  35. transition: background 0.3s, color 0.3s;
  36. }
  37. body.dark {
  38. background: var(--bg-dark);
  39. color: var(--text-dark);
  40. }
  41. header {
  42. background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  43. color: #fff;
  44. padding: 2rem 0 1rem 0;
  45. text-align: center;
  46. position: relative;
  47. }
  48. .toggle-mode {
  49. position: absolute;
  50. top: 1.5rem;
  51. right: 2rem;
  52. background: rgba(255,255,255,0.15);
  53. border: none;
  54. border-radius: 2rem;
  55. padding: 0.5rem 1.2rem;
  56. color: #fff;
  57. font-size: 1rem;
  58. cursor: pointer;
  59. transition: background 0.2s;
  60. }
  61. .toggle-mode:hover {
  62. background: rgba(0,0,0,0.15);
  63. }
  64. h1 {
  65. font-size: 2.5rem;
  66. margin: 0 0 0.5rem 0;
  67. letter-spacing: -1px;
  68. }
  69. .marquee {
  70. font-size: 1.1rem;
  71. color: #fff;
  72. background: rgba(0,0,0,0.08);
  73. padding: 0.5rem 0;
  74. border-radius: 1rem;
  75. margin: 0 auto 1rem auto;
  76. max-width: 600px;
  77. overflow: hidden;
  78. white-space: nowrap;
  79. box-sizing: border-box;
  80. animation: marquee 15s linear infinite;
  81. }
  82. @keyframes marquee {
  83. 0% { text-indent: 100% }
  84. 100% { text-indent: -100% }
  85. }
  86. main {
  87. max-width: 900px;
  88. margin: 2rem auto;
  89. padding: 2rem;
  90. background: var(--card-light);
  91. border-radius: 1.5rem;
  92. box-shadow: 0 4px 32px 0 rgba(0,0,0,0.07);
  93. border: 1px solid var(--border-light);
  94. transition: background 0.3s, border 0.3s;
  95. }
  96. body.dark main {
  97. background: var(--card-dark);
  98. border: 1px solid var(--border-dark);
  99. }
  100. h2, h3 {
  101. color: var(--primary);
  102. margin-top: 2.5rem;
  103. margin-bottom: 1rem;
  104. font-weight: 700;
  105. }
  106. h3 {
  107. font-size: 1.3rem;
  108. margin-top: 2rem;
  109. }
  110. p {
  111. line-height: 1.7;
  112. margin: 1rem 0;
  113. }
  114. ul, ol {
  115. margin: 1rem 0 1rem 2rem;
  116. }
  117. a {
  118. color: var(--primary);
  119. text-decoration: none;
  120. transition: color 0.2s;
  121. }
  122. a:hover {
  123. color: var(--accent);
  124. text-decoration: underline;
  125. }
  126. .toc {
  127. background: var(--code-bg-light);
  128. border-radius: 1rem;
  129. padding: 1.2rem 1.5rem;
  130. margin-bottom: 2rem;
  131. border: 1px solid var(--border-light);
  132. font-size: 1.05rem;
  133. box-shadow: 0 2px 8px 0 rgba(0,0,0,0.03);
  134. }
  135. body.dark .toc {
  136. background: var(--code-bg-dark);
  137. border: 1px solid var(--border-dark);
  138. }
  139. .toc ol {
  140. margin: 0;
  141. padding-left: 1.2rem;
  142. }
  143. .toc li {
  144. margin-bottom: 0.3rem;
  145. }
  146. code, pre {
  147. font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
  148. background: var(--code-bg-light);
  149. color: #2d2d2d;
  150. border-radius: 0.5rem;
  151. padding: 0.2em 0.5em;
  152. font-size: 1em;
  153. transition: background 0.3s, color 0.3s;
  154. }
  155. pre {
  156. display: block;
  157. padding: 1em;
  158. margin: 1.2em 0;
  159. overflow-x: auto;
  160. background: var(--code-bg-light);
  161. color: #2d2d2d;
  162. border: 1px solid var(--border-light);
  163. }
  164. body.dark code, body.dark pre {
  165. background: var(--code-bg-dark);
  166. color: #f7f8fa;
  167. border-color: var(--border-dark);
  168. }
  169. .note {
  170. background: var(--accent);
  171. color: #222;
  172. padding: 0.7em 1em;
  173. border-radius: 0.7em;
  174. margin: 1em 0;
  175. font-size: 1.05em;
  176. font-weight: 500;
  177. display: inline-block;
  178. }
  179. .table-wrap {
  180. overflow-x: auto;
  181. margin: 2em 0;
  182. }
  183. table {
  184. width: 100%;
  185. border-collapse: collapse;
  186. margin: 1.5em 0;
  187. font-size: 1em;
  188. background: var(--code-bg-light);
  189. border-radius: 1em;
  190. overflow: hidden;
  191. box-shadow: 0 2px 8px 0 rgba(0,0,0,0.03);
  192. transition: background 0.3s;
  193. }
  194. body.dark table {
  195. background: var(--code-bg-dark);
  196. }
  197. th, td {
  198. padding: 0.7em 1em;
  199. border-bottom: 1px solid var(--border-light);
  200. text-align: left;
  201. }
  202. body.dark th, body.dark td {
  203. border-bottom: 1px solid var(--border-dark);
  204. }
  205. th {
  206. background: var(--primary);
  207. color: #fff;
  208. font-weight: 700;
  209. }
  210. kbd {
  211. background: var(--kbd-bg-light);
  212. color: var(--kbd-text-light);
  213. border-radius: 0.3em;
  214. padding: 0.2em 0.5em;
  215. font-size: 1em;
  216. font-family: inherit;
  217. border: 1px solid var(--border-light);
  218. box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04);
  219. margin: 0 0.1em;
  220. display: inline-block;
  221. transition: background 0.3s, color 0.3s, border 0.3s;
  222. }
  223. body.dark kbd {
  224. background: var(--kbd-bg-dark);
  225. color: var(--kbd-text-dark);
  226. border: 1px solid var(--border-dark);
  227. }
  228. .back-to-top {
  229. display: inline-block;
  230. margin-top: 1.5em;
  231. font-size: 0.95em;
  232. color: var(--primary);
  233. text-decoration: none;
  234. border-bottom: 1px dashed var(--primary);
  235. transition: color 0.2s, border 0.2s;
  236. }
  237. .back-to-top:hover {
  238. color: var(--accent);
  239. border-bottom: 1px dashed var(--accent);
  240. }
  241. @media (max-width: 700px) {
  242. main {
  243. padding: 1rem;
  244. }
  245. .toc {
  246. padding: 1rem;
  247. }
  248. header {
  249. padding: 1.5rem 0 0.7rem 0;
  250. }
  251. .toggle-mode {
  252. right: 1rem;
  253. top: 1rem;
  254. }
  255. }
  256. </style>
  257. </head>
  258. <body>
  259. <header>
  260. <button class="toggle-mode" id="toggleModeBtn" aria-label="Toggle light/dark mode">๐ŸŒ™ Dark</button>
  261. <h1>๐Ÿญ Bye Bye Mouse</h1>
  262. <div class="marquee">Because real power users donโ€™t double-clickโ€”they type :)</div>
  263. <p style="margin:0.5em 0 0 0; font-size:1.1em; font-weight:500;">Escape the tyranny of the GUI one command at a time! This repo is your golden ticket to slick shell tricks, terminal wizardry, and keyboard-fueled productivity. Unplug that mouse and watch your workflow sprint.</p>
  264. </header>
  265. <main>
  266. <section class="toc" id="quick-links">
  267. <h2 style="margin-top:0;">Quick Links</h2>
  268. <ol>
  269. <li><a href="#copy-a-file">copy a file</a></li>
  270. <li><a href="#duplicate-a-file">duplicate a file</a></li>
  271. <li><a href="#copy-a-directory">copy a directory</a></li>
  272. <li><a href="#duplicate-a-directory">duplicate a directory</a></li>
  273. <li><a href="#move-a-file">move a file</a></li>
  274. <li><a href="#rename-a-file">rename a file</a></li>
  275. <li><a href="#move-a-directory">move a directory</a></li>
  276. <li><a href="#rename-a-directory">rename a directory</a></li>
  277. <li><a href="#merge-directories">merge directories</a></li>
  278. <li><a href="#create-a-new-file">create a new file</a></li>
  279. <li><a href="#create-a-new-directory">create a new directory</a></li>
  280. <li><a href="#show-filedirectory-size">show file/directory size</a></li>
  281. <li><a href="#show-filedirectory-info">show file/directory info</a></li>
  282. <li><a href="#open-a-file-with-the-default-program">open a file with the default program</a></li>
  283. <li><a href="#open-a-file-in-any-application">open a file in any application</a></li>
  284. <li><a href="#zip-a-directory">zip a directory</a></li>
  285. <li><a href="#unzip-a-directory">unzip a directory</a></li>
  286. <li><a href="#peek-files-in-a-zip-file">peek files in a zip file</a></li>
  287. <li><a href="#remove-a-file">remove a file</a></li>
  288. <li><a href="#remove-a-directory">remove a directory</a></li>
  289. <li><a href="#remove-all-files-of-certain-criteria">remove all files of certain criteria</a></li>
  290. <li><a href="#list-directory-contents">list directory contents</a></li>
  291. <li><a href="#tree-view-a-directory-and-its-subdirectories">tree view a directory and its subdirectories</a></li>
  292. <li><a href="#find-a-stale-file">find a stale file</a></li>
  293. <li><a href="#show-a-calendar">show a calendar</a></li>
  294. <li><a href="#find-a-future-date">find a future date</a></li>
  295. <li><a href="#use-a-calculator">use a calculator</a></li>
  296. <li><a href="#force-quit-a-program">force quit a program</a></li>
  297. <li><a href="#check-server-response">check server response</a></li>
  298. <li><a href="#view-content-of-a-file">view content of a file</a></li>
  299. <li><a href="#search-for-a-text-in-a-file">search for a text in a file</a></li>
  300. <li><a href="#search-in-all-files-in-current-working-directory-quickly-entire-disk-in-less-than-15-minutes">search in all files in current working directory, quickly (entire disk in less than 15 minutes)</a></li>
  301. <li><a href="#view-an-image">view an image</a></li>
  302. <li><a href="#show-disk-size">show disk size</a></li>
  303. <li><a href="#check-cpu-usage-processes-and-ram">check cpu usage, processes and RAM</a></li>
  304. <li><a href="#know-whether-your-computer-is-under-load-and-whether-its-due-to-memory-or-cpu">know whether your computer is under load, and whether it's due to memory or CPU</a></li>
  305. <li><a href="#poweroff-or-reboot-your-computer">poweroff or reboot your computer</a></li>
  306. <li><a href="#locate-usb-drives">locate USB drives</a></li>
  307. <li><a href="#unmount-usb-drives">unmount USB drives</a></li>
  308. <li><a href="#format-usb-drives">format USB drives</a></li>
  309. <li><a href="#check-usb-format">check USB format</a></li>
  310. <li><a href="#run-command-on-all-files-of-a-directory">run command on all files of a directory</a></li>
  311. <li><a href="#check-network-connectivity-to-a-remote-address-and-port">check network connectivity to a remote address and port</a></li>
  312. <li><a href="#check-dns-config-of-a-domain">check DNS config of a domain</a></li>
  313. <li><a href="#check-the-ownership-and-registration-of-a-domain">check the ownership and registration of a domain</a></li>
  314. <li><a href="#hotkeys">Hotkeys</a></li>
  315. <li><a href="#i-cant-remember-these-cryptic-commands">I can't remember these cryptic commands</a></li>
  316. </ol>
  317. </section>
  318. <!-- All sections below, one after another, with anchors for each -->
  319. <section id="copy-a-file">
  320. <h3>copy a file</h3>
  321. <div class="note">STOP DRAG AND DROPPING A FILE, OR CMD/CTRL + C, CMD/CTRL + V A FILE ๐Ÿ‘Ž</div>
  322. <p>Copy <code>readme.txt</code> to the <code>documents</code> directory</p>
  323. <pre><code>$ cp readme.txt documents/</code></pre>
  324. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  325. </section>
  326. <section id="duplicate-a-file">
  327. <h3>duplicate a file</h3>
  328. <div class="note">STOP RIGHT CLICKING AND DUPLICATE A FILE ๐Ÿ‘Ž</div>
  329. <pre><code>$ cp readme.txt readme.bak.txt</code></pre>
  330. <p>More advanced:</p>
  331. <pre><code>$ cp readme{,.bak}.txt
  332. # Note: learn how the {} works with touch foo{1,2,3}.txt and see what happens.</code></pre>
  333. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  334. </section>
  335. <section id="copy-a-directory">
  336. <h3>copy a directory</h3>
  337. <div class="note">STOP DRAG AND DROPPING A DIRECTORY, OR CMD/CTRL + C, CMD/CTRL + V A DIRECTORY ๐Ÿ‘Ž</div>
  338. <p>Copy <code>myMusic</code> directory to the <code>myMedia</code> directory</p>
  339. <pre><code>$ cp -a myMusic myMedia/
  340. # or
  341. $ cp -a myMusic/ myMedia/myMusic/</code></pre>
  342. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  343. </section>
  344. <section id="duplicate-a-directory">
  345. <h3>duplicate a directory</h3>
  346. <div class="note">STOP RIGHT CLICKING AND DUPLICATE A DIRECTORY ๐Ÿ‘Ž</div>
  347. <pre><code>$ cp -a myMusic/ myMedia/
  348. # or if `myMedia` folder doesn't exist
  349. $ cp -a myMusic myMedia/</code></pre>
  350. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  351. </section>
  352. <section id="move-a-file">
  353. <h3>move a file</h3>
  354. <div class="note">STOP DRAG AND DROPPING A FILE, OR CMD/CTRL + X, CMD/CTRL + V A FILE ๐Ÿ‘Ž</div>
  355. <pre><code>$ mv readme.txt documents/</code></pre>
  356. <p><b>Always</b> use a trailing slash when moving files, <a href="http://unix.stackexchange.com/a/50533" target="_blank">for this reason</a>.</p>
  357. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  358. </section>
  359. <section id="rename-a-file">
  360. <h3>rename a file</h3>
  361. <div class="note">STOP RIGHT CLICKING AND RENAME A FILE ๐Ÿ‘Ž</div>
  362. <pre><code>$ mv readme.txt README.md</code></pre>
  363. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  364. </section>
  365. <section id="move-a-directory">
  366. <h3>move a directory</h3>
  367. <div class="note">STOP DRAG AND DROPPING A DIRECTORY, OR CMD/CTRL + X, CMD/CTRL + V A DIRECTORY ๐Ÿ‘Ž</div>
  368. <pre><code>$ mv myMedia myMusic/
  369. # or
  370. $ mv myMedia/ myMusic/myMedia</code></pre>
  371. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  372. </section>
  373. <section id="rename-a-directory">
  374. <h3>rename a directory</h3>
  375. <div class="note">STOP RIGHT CLICKING AND RENAME A DIRECTORY ๐Ÿ‘Ž</div>
  376. <pre><code>$ mv myMedia/ myMusic/</code></pre>
  377. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  378. </section>
  379. <section id="merge-directories">
  380. <h3>merge directories</h3>
  381. <div class="note">STOP DRAG AND DROPPING TO MERGE DIRECTORIES ๐Ÿ‘Ž</div>
  382. <pre><code>$ rsync -a /images/ /images2/ # note: may over-write files with the same name, so be careful!</code></pre>
  383. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  384. </section>
  385. <section id="create-a-new-file">
  386. <h3>create a new file</h3>
  387. <div class="note">STOP RIGHT CLICKING AND CREATE A NEW FILE ๐Ÿ‘Ž</div>
  388. <pre><code>$ touch 'new file' # updates the file's access and modification timestamp if it already exists
  389. # or
  390. $ > 'new file' # note: erases the content if it already exists</code></pre>
  391. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  392. </section>
  393. <section id="create-a-new-directory">
  394. <h3>create a new directory</h3>
  395. <div class="note">STOP RIGHT CLICKING AND CREATE A NEW DIRECTORY ๐Ÿ‘Ž</div>
  396. <pre><code>$ mkdir 'untitled folder'
  397. # or
  398. $ mkdir -p 'path/may/not/exist/untitled folder'</code></pre>
  399. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  400. </section>
  401. <section id="show-filedirectory-size">
  402. <h3>show file/directory size</h3>
  403. <div class="note">STOP RIGHT CLICKING AND SHOW FILE/directory INFO ๐Ÿ‘Ž</div>
  404. <pre><code>$ du -sh node_modules/</code></pre>
  405. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  406. </section>
  407. <section id="show-filedirectory-info">
  408. <h3>show file/directory info</h3>
  409. <div class="note">STOP RIGHT CLICKING AND SHOW FILE/DIRECTORY INFO ๐Ÿ‘Ž</div>
  410. <pre><code>$ stat -x readme.md # on macOS
  411. $ stat readme.md # on Linux</code></pre>
  412. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  413. </section>
  414. <section id="open-a-file-with-the-default-program">
  415. <h3>open a file with the default program</h3>
  416. <div class="note">STOP DOUBLE CLICKING ON A FILE ๐Ÿ‘Ž</div>
  417. <pre><code>$ xdg-open file # on Linux
  418. $ open file # on MacOS
  419. $ start file # on Windows</code></pre>
  420. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  421. </section>
  422. <section id="open-a-file-in-any-application">
  423. <h3>open a file in any application</h3>
  424. <div class="note">STOP RIGHT CLICKING AND OPEN WITH ๐Ÿ‘Ž</div>
  425. <pre><code>$ open -a appName file</code></pre>
  426. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  427. </section>
  428. <section id="zip-a-directory">
  429. <h3>zip a directory</h3>
  430. <div class="note">STOP RIGHT CLICKING AND COMPRESS DIRECTORY ๐Ÿ‘Ž</div>
  431. <pre><code>$ zip -r archive_name.zip folder_to_compress</code></pre>
  432. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  433. </section>
  434. <section id="unzip-a-directory">
  435. <h3>unzip a directory</h3>
  436. <div class="note">STOP RIGHT CLICKING AND UNCOMPRESS DIRECTORY ๐Ÿ‘Ž</div>
  437. <pre><code>$ unzip archive_name.zip</code></pre>
  438. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  439. </section>
  440. <section id="peek-files-in-a-zip-file">
  441. <h3>peek files in a zip file</h3>
  442. <div class="note">STOP USING WinRAR ๐Ÿ‘Ž</div>
  443. <pre><code>$ zipinfo archive_name.zip
  444. # or
  445. $ unzip -l archive_name.zip</code></pre>
  446. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  447. </section>
  448. <section id="remove-a-file">
  449. <h3>remove a file</h3>
  450. <div class="note">STOP RIGHT CLICKING AND DELETE A FILE PERMANENTLY ๐Ÿ‘Ž</div>
  451. <pre><code>$ rm my_useless_file</code></pre>
  452. <p><b>IMPORTANT</b>: The <code>rm</code> command deletes <code>my_useless_file</code> permanently, which is equivalent to move <code>my_useless_file</code> to Recycle Bin and hit Empty Recycle Bin.</p>
  453. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  454. </section>
  455. <section id="remove-a-directory">
  456. <h3>remove a directory</h3>
  457. <div class="note">STOP RIGHT CLICKING AND DELETE A DIRECTORY PERMANENTLY ๐Ÿ‘Ž</div>
  458. <pre><code>$ rm -r my_useless_folder</code></pre>
  459. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  460. </section>
  461. <section id="remove-all-files-of-certain-criteria">
  462. <h3>remove all files of certain criteria</h3>
  463. <pre><code>$ find . -name "*.bak" -type f -delete</code></pre>
  464. <p><b>IMPORTANT</b>: run <code>find . -name "*.bak" -type f</code> first to see exactly which files you will remove.</p>
  465. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  466. </section>
  467. <section id="list-directory-contents">
  468. <h3>list directory contents</h3>
  469. <div class="note">STOP OPENING YOUR FINDER OR FILE EXPLORER ๐Ÿ‘Ž</div>
  470. <pre><code>$ ls my_folder # Simple
  471. $ ls -la my_folder # -l: show in list format. -a: show all files, including hidden. -la combines those options.
  472. $ ls -ltrha my_folder # -r: reverse output. -t: sort by time (modified). -h: output human-readable sizes.</code></pre>
  473. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  474. </section>
  475. <section id="tree-view-a-directory-and-its-subdirectories">
  476. <h3>tree view a directory and its subdirectories</h3>
  477. <div class="note">STOP OPENING YOUR FINDER OR FILE EXPLORER ๐Ÿ‘Ž</div>
  478. <pre><code>$ tree # on Linux
  479. $ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' # on MacOS
  480. # Note: install homebrew (https://brew.sh) to be able to use (some) Linux utilities such as tree.
  481. # brew install tree</code></pre>
  482. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  483. </section>
  484. <section id="find-a-stale-file">
  485. <h3>find a stale file</h3>
  486. <div class="note">STOP USING YOUR FILE EXPLORER TO FIND A FILE ๐Ÿ‘Ž</div>
  487. <p>Find all files modified more than 5 days ago</p>
  488. <pre><code>$ find my_folder -mtime +5</code></pre>
  489. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  490. </section>
  491. <section id="show-a-calendar">
  492. <h3>show a calendar</h3>
  493. <div class="note">STOP LOOKING UP WHAT THIS MONTH LOOKS LIKE BY CALENDAR WIDGETS ๐Ÿ‘Ž</div>
  494. <p>Display a text calendar</p>
  495. <pre><code>$ cal</code></pre>
  496. <p>Display selected month and year calendar</p>
  497. <pre><code>$ cal 11 2018</code></pre>
  498. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  499. </section>
  500. <section id="find-a-future-date">
  501. <h3>find a future date</h3>
  502. <div class="note">STOP USING WEBAPPS TO CALCULATE FUTURE DATES ๐Ÿ‘Ž</div>
  503. <p>What is today's date?</p>
  504. <pre><code>$ date +%m/%d/%Y</code></pre>
  505. <p>What about a week from now?</p>
  506. <pre><code>$ date -d "+7 days" # on Linux
  507. $ date -j -v+7d # on MacOS</code></pre>
  508. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  509. </section>
  510. <section id="use-a-calculator">
  511. <h3>use a calculator</h3>
  512. <div class="note">STOP USING CALCULATOR WIDGET ๐Ÿ‘Ž</div>
  513. <pre><code>$ bc -l</code></pre>
  514. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  515. </section>
  516. <section id="force-quit-a-program">
  517. <h3>force quit a program</h3>
  518. <div class="note">STOP CTRL + ALT + DELETE and choose the program to kill ๐Ÿ‘Ž</div>
  519. <pre><code>$ killall -9 program_name</code></pre>
  520. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  521. </section>
  522. <section id="check-server-response">
  523. <h3>check server response</h3>
  524. <div class="note">STOP OPENING A BROWSER ๐Ÿ‘Ž</div>
  525. <pre><code>$ curl -i rbtreevi.web.app
  526. # curl's -i (--include) option includes HTTP response headers in its output.</code></pre>
  527. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  528. </section>
  529. <section id="view-content-of-a-file">
  530. <h3>view content of a file</h3>
  531. <div class="note">STOP DOUBLE CLICKING A FILE ๐Ÿ‘Ž</div>
  532. <pre><code>$ cat apps/settings.py
  533. # if the file is too big to fit on one page, you can use a 'pager' (less) which shows you one page at a time.
  534. $ less apps/settings.py</code></pre>
  535. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  536. </section>
  537. <section id="search-for-a-text-in-a-file">
  538. <h3>search for a text in a file</h3>
  539. <div class="note">STOP CMD/CTRL + F IN A FILE ๐Ÿ‘Ž</div>
  540. <pre><code>$ grep -i "Query" file.txt</code></pre>
  541. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  542. </section>
  543. <section id="search-in-all-files-in-current-working-directory-quickly-entire-disk-in-less-than-15-minutes">
  544. <h3>search in all files in current working directory, quickly (entire disk in less than 15 minutes)</h3>
  545. <div class="note">STOP CMD/CTRL + F IN A DIRECTORY ๐Ÿ‘Ž</div>
  546. <pre><code>$ ripgrep -i "Query"
  547. # brew install ripgrep</code></pre>
  548. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  549. </section>
  550. <section id="view-an-image">
  551. <h3>view an image</h3>
  552. <div class="note">STOP USING PREVIEW ๐Ÿ‘Ž</div>
  553. <pre><code>$ imgcat image.png
  554. # Note: requires iTerm2 terminal.</code></pre>
  555. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  556. </section>
  557. <section id="show-disk-size">
  558. <h3>show disk size</h3>
  559. <div class="note">STOP RIGHT CLICKING DISK ICON OR OPENING DISK UTILITY ๐Ÿ‘Ž</div>
  560. <pre><code>$ df -h</code></pre>
  561. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  562. </section>
  563. <section id="check-cpu-usage-processes-and-ram">
  564. <h3>check cpu usage, processes and RAM</h3>
  565. <div class="note">STOP OPENING YOUR ACTIVITY MONITOR OR TASK MANAGER ๐Ÿ‘Ž</div>
  566. <pre><code>$ top</code></pre>
  567. <p>if you want some more details:</p>
  568. <pre><code>$ htop</code></pre>
  569. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  570. </section>
  571. <section id="know-whether-your-computer-is-under-load-and-whether-its-due-to-memory-or-cpu">
  572. <h3>know whether your computer is under load, and whether it's due to memory or CPU</h3>
  573. <pre><code>$ glances
  574. # brew install glances
  575. # pip install --user 'glances[all]'</code></pre>
  576. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  577. </section>
  578. <section id="poweroff-or-reboot-your-computer">
  579. <h3>poweroff or reboot your computer</h3>
  580. <p>This can be useful when you're patching a server that is accessed via SSH and you don't have a GUI.</p>
  581. <pre><code># poweroff
  582. $ sudo shutdown -h now
  583. # reboot
  584. $ sudo shutdown -r now</code></pre>
  585. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  586. </section>
  587. <section id="locate-usb-drives">
  588. <h3>locate USB drives</h3>
  589. <pre><code>$ df</code></pre>
  590. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  591. </section>
  592. <section id="unmount-usb-drives">
  593. <h3>unmount USB drives</h3>
  594. <pre><code>$ sudo umount /dev/sdb1</code></pre>
  595. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  596. </section>
  597. <section id="format-usb-drives">
  598. <h3>format USB drives</h3>
  599. <pre><code># FAT32
  600. $ sudo mkfs.vfat /dev/sdb1
  601. # NTFS
  602. $ sudo mkfs.ntfs /dev/sdb1
  603. # exFAT
  604. $ sudo mkfs.exfat /dev/sdb1</code></pre>
  605. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  606. </section>
  607. <section id="check-usb-format">
  608. <h3>check USB format</h3>
  609. <pre><code>$ sudo fsck /dev/sdb1</code></pre>
  610. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  611. </section>
  612. <section id="run-command-on-all-files-of-a-directory">
  613. <h3>run command on all files of a directory</h3>
  614. <div class="note">STOP CLICKING THE FILES ONE BY ONE ๐Ÿ‘Ž</div>
  615. <pre><code>$ for FILE in *; do echo $FILE; done</code></pre>
  616. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  617. </section>
  618. <section id="check-network-connectivity-to-a-remote-address-and-port">
  619. <h3>check network connectivity to a remote address and port</h3>
  620. <div class="note">STOP USING NETWORK UTILITY</div>
  621. <pre><code>$ nc -vz www.google.com 443
  622. $ nc -vz 1.1.1.1 53</code></pre>
  623. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  624. </section>
  625. <section id="check-dns-config-of-a-domain">
  626. <h3>check DNS config of a domain</h3>
  627. <div class="note">STOP USING NETWORK UTILITY</div>
  628. <pre><code>$ dig www.google.com</code></pre>
  629. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  630. </section>
  631. <section id="check-the-ownership-and-registration-of-a-domain">
  632. <h3>check the ownership and registration of a domain</h3>
  633. <div class="note">STOP USING NETWORK UTILITY AND THE WEBSITE OF DOMAIN REGISTRATION PROVIDERS</div>
  634. <pre><code>$ whois www.google.com</code></pre>
  635. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  636. </section>
  637. <section id="hotkeys">
  638. <h3>Hotkeys</h3>
  639. <div class="table-wrap">
  640. <table>
  641. <thead>
  642. <tr>
  643. <th>Hotkey</th>
  644. <th>Description</th>
  645. </tr>
  646. </thead>
  647. <tbody>
  648. <tr><td><kbd>Ctrl</kbd>+<kbd>A</kbd></td><td>Go to the beginning of the line you are currently typing on</td></tr>
  649. <tr><td><kbd>Ctrl</kbd>+<kbd>E</kbd></td><td>Go to the end of the line you are currently typing on</td></tr>
  650. <tr><td><kbd>Ctrl</kbd>+<kbd>L</kbd></td><td>Clears the Screen, similar to the clear command</td></tr>
  651. <tr><td><kbd>Ctrl</kbd>+<kbd>U</kbd></td><td>Clears the line before the cursor position. If you are at the end of the line, clears the entire line.</td></tr>
  652. <tr><td><kbd>Ctrl</kbd>+<kbd>H</kbd></td><td>Same as backspace</td></tr>
  653. <tr><td><kbd>Ctrl</kbd>+<kbd>R</kbd></td><td>Lets you search through previously used commands</td></tr>
  654. <tr><td><kbd>Ctrl</kbd>+<kbd>C</kbd></td><td>Kill whatever you are running</td></tr>
  655. <tr><td><kbd>Ctrl</kbd>+<kbd>D</kbd></td><td>Exit the current shell</td></tr>
  656. <tr><td><kbd>Ctrl</kbd>+<kbd>Z</kbd></td><td>Puts whatever you are running into a suspended background process. fg restores it.</td></tr>
  657. <tr><td><kbd>Ctrl</kbd>+<kbd>W</kbd></td><td>Delete the word before the cursor</td></tr>
  658. <tr><td><kbd>Ctrl</kbd>+<kbd>K</kbd></td><td>Clear the line after the cursor</td></tr>
  659. <tr><td><kbd>Ctrl</kbd>+<kbd>T</kbd></td><td>Swap the last two characters before the cursor</td></tr>
  660. <tr><td><kbd>Ctrl</kbd>+<kbd>F</kbd></td><td>Move cursor forward one character</td></tr>
  661. <tr><td><kbd>Ctrl</kbd>+<kbd>B</kbd></td><td>Move cursor backward one character</td></tr>
  662. <tr><td><kbd>Esc</kbd>+<kbd>T</kbd></td><td>Swap the last two words before the cursor</td></tr>
  663. <tr><td><kbd>Alt</kbd>+<kbd>T</kbd></td><td>Same as <kbd>Esc</kbd> + <kbd>T</kbd></td></tr>
  664. <tr><td><kbd>Alt</kbd>+<kbd>F</kbd></td><td>Move cursor forward one word on the current line</td></tr>
  665. <tr><td><kbd>Alt</kbd>+<kbd>B</kbd></td><td>Move cursor backward one word on the current line</td></tr>
  666. <tr><td><kbd>Esc</kbd>+<kbd>F</kbd></td><td>Same as <kbd>Alt</kbd> + <kbd>F</kbd></td></tr>
  667. <tr><td><kbd>Esc</kbd>+<kbd>B</kbd></td><td>Same as <kbd>Alt</kbd> + <kbd>B</kbd></td></tr>
  668. <tr><td><kbd>Alt</kbd>+<kbd>.</kbd></td><td>Paste the last word of the most recently command</td></tr>
  669. <tr><td><kbd>Tab</kbd></td><td>Auto-complete files and directory names</td></tr>
  670. </tbody>
  671. </table>
  672. </div>
  673. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  674. </section>
  675. <section id="i-cant-remember-these-cryptic-commands">
  676. <h3>I can't remember these cryptic commands</h3>
  677. <p>You can always google or <code>man</code> the commands you are not familiar with. Or, checkout <a href="https://github.com/tldr-pages/tldr" target="_blank">tldr</a>, a collection of simplified and community-driven man pages.</p>
  678. <a class="back-to-top" href="#quick-links">Go to table of contents ๐Ÿ”ผ</a>
  679. </section>
  680. </main>
  681. <script>
  682. // Light/Dark mode toggle
  683. const btn = document.getElementById('toggleModeBtn');
  684. const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
  685. function setMode(dark) {
  686. document.body.classList.toggle('dark', dark);
  687. btn.textContent = dark ? 'โ˜€๏ธ Light' : '๐ŸŒ™ Dark';
  688. localStorage.setItem('theme', dark ? 'dark' : 'light');
  689. }
  690. // On load
  691. (() => {
  692. const saved = localStorage.getItem('theme');
  693. if (saved) setMode(saved === 'dark');
  694. else setMode(prefersDark);
  695. })();
  696. btn.onclick = () => setMode(!document.body.classList.contains('dark'));
  697. </script>
  698. </body>
  699. </html>