YouTube2Text

Linux Commands for Beginners 15 - Bash History — Transcript

by Learn Linux TV · 1,741 words · 238 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:19hey guys welcome to another video in my
  3. 0:22Linux commands for beginner series and
  4. 0:24in this video I wanted to give you guys
  5. 0:27a quick look at history it's a pretty
  6. 0:30easy concept but it's actually a very
  7. 0:33important one that as a Linux
  8. 0:35administrator you're going to be using
  9. 0:37every single day so let's go ahead and
  10. 0:39get started so here on my terminal
  11. 0:41you've probably seen me several times in
  12. 0:44previous videos using the up and down
  13. 0:46arrow to basically go through previous
  14. 0:49commands that we've run and that's great
  15. 0:52because if you want to basically act you
  16. 0:54know enter a command again you don't
  17. 0:55really have to type the entire thing you
  18. 0:58could just simply find it and then press
  19. 1:00Enter and you know you're able to
  20. 1:02execute that obviously it took me longer
  21. 1:04to find the groups command than it would
  22. 1:05have taken me to you know type that out
  23. 1:07but sometimes you have very long
  24. 1:09commands that you want to reenter so
  25. 1:12going up and down in the history of
  26. 1:14course is going to be a lot easier when
  27. 1:17you find the command than retyping it
  28. 1:18sometimes but that's really not the
  29. 1:20extent of history it goes a lot more
  30. 1:23than that in fact you can use the
  31. 1:25history command and press Enter and you
  32. 1:28can see all kinds of different things
  33. 1:30here now this is my personal laptop here
  34. 1:31so what you're going to see is a lot of
  35. 1:34the commands that we have been using for
  36. 1:36the videos that we've been doing in this
  37. 1:39series and there's quite a few commands
  38. 1:41right here and we can execute any one of
  39. 1:44these commands at any time we don't
  40. 1:47actually need to go up and down through
  41. 1:49the history to find it if we just type
  42. 1:52the history command by itself we can
  43. 1:53actually just scroll through here and
  44. 1:55find the commands we want but that's not
  45. 1:57all we can do
  46. 1:58notice that command that er actually
  47. 2:01each one of these has a number on the
  48. 2:04left hand side and we can execute that
  49. 2:06command and refer to it by number which
  50. 2:09is actually a really useful thing to do
  51. 2:12so how do we do that well remember this
  52. 2:15command is command number five nine four
  53. 2:18and the command was executed was here
  54. 2:21now I have customized my shell a little
  55. 2:23bit so you might have the output
  56. 2:25presented a little bit differently on
  57. 2:27your end
  58. 2:28but the main important thing is the
  59. 2:29number and then the command which you
  60. 2:32should have
  61. 2:33so that was command 594 so I'll clear
  62. 2:36the screen now we need to run command
  63. 2:39594 but we can't actually just type the
  64. 2:42number we actually need to put an
  65. 2:44exclamation mark in front of that and
  66. 2:46what that'll do is re-execute that
  67. 2:49command in my case it's showing me the
  68. 2:52command that you know that number refers
  69. 2:55to and then I get the output of the
  70. 2:57command which is basically just groups J
  71. 2:59so essentially it's the same as I just
  72. 3:01typed it in it's just giving me the
  73. 3:02output but you know I can go ahead and
  74. 3:05you know refer to it by number and
  75. 3:07that's really important because you know
  76. 3:09obviously none of these commands are
  77. 3:11really hard
  78. 3:11I can re-enter any of these commands
  79. 3:14just as easily as I can scroll through
  80. 3:16this list but again sometimes in Linux
  81. 3:18you have really long commands and it's
  82. 3:20just not practical to retype them and in
  83. 3:22fact you open a margin of error for
  84. 3:24possibly having a typo which is you know
  85. 3:26potentially a really bad thing that you
  86. 3:28could do so perhaps it's a good idea to
  87. 3:31go ahead and look through here and you
  88. 3:33can just execute the history or the
  89. 3:35command accordingly now notice that
  90. 3:37every time I enter a command so I just
  91. 3:39do cat that's the passwd just a random
  92. 3:43example and then I'll do history again
  93. 3:48we can see that we have the command I
  94. 3:52just entered automatically entered into
  95. 3:54the history as I do LS and we see LS is
  96. 3:59now in the history so every time we do
  97. 4:02that we actually do see the command
  98. 4:04being entered in which is great because
  99. 4:05it keeps up and it enters all the
  100. 4:07commands in there that we have run we'll
  101. 4:11get back to the video in just a moment
  102. 4:12but before we do I just wanted to
  103. 4:14mention my sponsor Linode Len ode is an
  104. 4:17awesome provider of cloud Linux servers
  105. 4:20setting up your Linux cloud servers or
  106. 4:22Lynne Oates is quick and easy with their
  107. 4:24intuitive cloud manager interface there
  108. 4:27are multiple instance types available to
  109. 4:29make any app or service flexible and
  110. 4:31scalable if it runs on Linux it runs on
  111. 4:33Linode use your Linode server to host a
  112. 4:35website set up a VPN create a next cloud
  113. 4:39instance host a game server and Moe
  114. 4:42you could set up your Leonard's in a
  115. 4:43data center nearest you with their
  116. 4:45latest opening in Mumbai in july 2019 if
  117. 4:48you need assistance 24/7 365 friendly
  118. 4:52support is available by phone or support
  119. 4:55ticket visit the URL on the screen right
  120. 4:57now to get started with twenty dollars
  121. 4:59in credit you can use towards setting up
  122. 5:01your very own Linode there are linux
  123. 5:03instance types available for as low as
  124. 5:05$5 a month so let's go ahead and get
  125. 5:07back to the video what if we don't want
  126. 5:11a command to be in the history so what
  127. 5:15I'm going to do is type a space and then
  128. 5:19I'm going to do sudo apt update to
  129. 5:22update my package repositories I'll
  130. 5:24press Enter and you know that that did
  131. 5:30that so I'll clear the screen and let's
  132. 5:32do history again wait a minute we don't
  133. 5:36see the sudo apt update command here at
  134. 5:39all I did just run it you saw me do it
  135. 5:41but it's not listed and actually that's
  136. 5:44a very common customization is that
  137. 5:47anything with us or command with a space
  138. 5:49in front of it is not actually going to
  139. 5:51show up in the history now this is
  140. 5:52dependent on the bash configuration and
  141. 5:55each distribution ships a different
  142. 5:58configuration for bash so yours might be
  143. 6:00a little different than that but most
  144. 6:02distributions will have a default
  145. 6:04customization that omits command to
  146. 6:07start with a space from the history why
  147. 6:09would you want to hide a command from
  148. 6:11your history well a couple examples
  149. 6:13include maybe you have a command that
  150. 6:16has sensitive information maybe it's a
  151. 6:18old program where you have to type a
  152. 6:20password and you know the bad thing is
  153. 6:23if you're to do you know type a password
  154. 6:26here I know this is not a good example
  155. 6:27that's going to fail but it's in the
  156. 6:29history right you know basically I just
  157. 6:35pretend I typed a command that included
  158. 6:36a password now it's in history so
  159. 6:38somebody hacks into the server now they
  160. 6:41could check the history file which is
  161. 6:42you know pretty much usually viewable by
  162. 6:44anyone and at that point they can get
  163. 6:47the password so you don't want to
  164. 6:50include a command
  165. 6:52command that might include some
  166. 6:54sensitive information you can type a
  167. 6:56space in front of that so that way you
  168. 6:58don't have to worry about a command that
  169. 7:01has sensitive information being shown in
  170. 7:03the history so a database server for
  171. 7:05example if you need to type a database
  172. 7:07password that's especially important you
  173. 7:09don't want that in the history and one
  174. 7:11way to avoid that if you can't omit the
  175. 7:14password altogether is to put a space in
  176. 7:16front so yeah I know that was a very
  177. 7:18simple concept guys and I did want to
  178. 7:21make sure that you guys understand
  179. 7:23history and know how to get the history
  180. 7:27and how to use it so yeah it's literally
  181. 7:30that simple you have the history command
  182. 7:31you can in most cases depending on the
  183. 7:33configuration hide a command from
  184. 7:35history if you put a space in front of
  185. 7:36it you can use the number in front of an
  186. 7:39item in the history to re execute that
  187. 7:41command that's pretty powerful stuff and
  188. 7:44another thing that also makes it very
  189. 7:46powerful too is if you have a you know a
  190. 7:48team of engineers and you know you want
  191. 7:51to basically see what someone else did
  192. 7:53to fix a problem history is
  193. 7:55indispensable especially when you're
  194. 7:56first starting a job at a new company
  195. 7:58you're supporting a server you never
  196. 8:00supported before you can use the history
  197. 8:02command to find out how people have
  198. 8:04solved similar problems in the past you
  199. 8:07might actually find a command that was
  200. 8:08used to resolve a problem because a lot
  201. 8:10of cases problems do repeat and you can
  202. 8:13find that information in the history it
  203. 8:15can be valuable to go through the
  204. 8:17history to see what others before you
  205. 8:19have done to solve problems and if you
  206. 8:22know there's a bad thing that happened
  207. 8:23to the server you can also check the
  208. 8:25history and it's a per-user thing but
  209. 8:27you could check the history for the
  210. 8:28users to find out it maybe if someone
  211. 8:29made a mistake maybe they removed a file
  212. 8:32that shouldn't have been removed or
  213. 8:34something like that or if a server you
  214. 8:36know went offline you might find that
  215. 8:38they rebooted it or they shut it down
  216. 8:39and then started to back up you'll see
  217. 8:42those commands in the history so it's
  218. 8:43just a good idea to know how to get to
  219. 8:46those commands and the history is
  220. 8:48indispensable so I highly recommend that
  221. 8:50you guys familiarize yourself with the
  222. 8:53history so there you go hope that was
  223. 8:54helpful for you guys and I will see you
  224. 8:57in the next video as soon as I have that
  225. 8:59uploaded see you there thank you so much
  226. 9:02for watching my video I really
  227. 9:03appreciate it if you want to help me out
  228. 9:05make sure
  229. 9:06you check out the description below this
  230. 9:07video where you'll find links to my
  231. 9:10latest book mastering of boom to server
  232. 9:12second edition as well as my patreon
  233. 9:15page if you liked this video be sure to
  234. 9:16click that like button and share it on
  235. 9:18Twitter or any other social media
  236. 9:20network and be sure to subscribe so
  237. 9:22you'll be the first to see my latest
  238. 9:24videos as they're uploaded thanks again

About this transcript

This page contains the full transcript of Linux Commands for Beginners 15 - Bash History by Learn Linux TV, generated from the public captions YouTube serves with the video. The transcript has 1,741 words across 238 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.