Linux Commands for Beginners 15 - Bash History — Transcript
Full transcript
- 0:00[Music]
- 0:19hey guys welcome to another video in my
- 0:22Linux commands for beginner series and
- 0:24in this video I wanted to give you guys
- 0:27a quick look at history it's a pretty
- 0:30easy concept but it's actually a very
- 0:33important one that as a Linux
- 0:35administrator you're going to be using
- 0:37every single day so let's go ahead and
- 0:39get started so here on my terminal
- 0:41you've probably seen me several times in
- 0:44previous videos using the up and down
- 0:46arrow to basically go through previous
- 0:49commands that we've run and that's great
- 0:52because if you want to basically act you
- 0:54know enter a command again you don't
- 0:55really have to type the entire thing you
- 0:58could just simply find it and then press
- 1:00Enter and you know you're able to
- 1:02execute that obviously it took me longer
- 1:04to find the groups command than it would
- 1:05have taken me to you know type that out
- 1:07but sometimes you have very long
- 1:09commands that you want to reenter so
- 1:12going up and down in the history of
- 1:14course is going to be a lot easier when
- 1:17you find the command than retyping it
- 1:18sometimes but that's really not the
- 1:20extent of history it goes a lot more
- 1:23than that in fact you can use the
- 1:25history command and press Enter and you
- 1:28can see all kinds of different things
- 1:30here now this is my personal laptop here
- 1:31so what you're going to see is a lot of
- 1:34the commands that we have been using for
- 1:36the videos that we've been doing in this
- 1:39series and there's quite a few commands
- 1:41right here and we can execute any one of
- 1:44these commands at any time we don't
- 1:47actually need to go up and down through
- 1:49the history to find it if we just type
- 1:52the history command by itself we can
- 1:53actually just scroll through here and
- 1:55find the commands we want but that's not
- 1:57all we can do
- 1:58notice that command that er actually
- 2:01each one of these has a number on the
- 2:04left hand side and we can execute that
- 2:06command and refer to it by number which
- 2:09is actually a really useful thing to do
- 2:12so how do we do that well remember this
- 2:15command is command number five nine four
- 2:18and the command was executed was here
- 2:21now I have customized my shell a little
- 2:23bit so you might have the output
- 2:25presented a little bit differently on
- 2:27your end
- 2:28but the main important thing is the
- 2:29number and then the command which you
- 2:32should have
- 2:33so that was command 594 so I'll clear
- 2:36the screen now we need to run command
- 2:39594 but we can't actually just type the
- 2:42number we actually need to put an
- 2:44exclamation mark in front of that and
- 2:46what that'll do is re-execute that
- 2:49command in my case it's showing me the
- 2:52command that you know that number refers
- 2:55to and then I get the output of the
- 2:57command which is basically just groups J
- 2:59so essentially it's the same as I just
- 3:01typed it in it's just giving me the
- 3:02output but you know I can go ahead and
- 3:05you know refer to it by number and
- 3:07that's really important because you know
- 3:09obviously none of these commands are
- 3:11really hard
- 3:11I can re-enter any of these commands
- 3:14just as easily as I can scroll through
- 3:16this list but again sometimes in Linux
- 3:18you have really long commands and it's
- 3:20just not practical to retype them and in
- 3:22fact you open a margin of error for
- 3:24possibly having a typo which is you know
- 3:26potentially a really bad thing that you
- 3:28could do so perhaps it's a good idea to
- 3:31go ahead and look through here and you
- 3:33can just execute the history or the
- 3:35command accordingly now notice that
- 3:37every time I enter a command so I just
- 3:39do cat that's the passwd just a random
- 3:43example and then I'll do history again
- 3:48we can see that we have the command I
- 3:52just entered automatically entered into
- 3:54the history as I do LS and we see LS is
- 3:59now in the history so every time we do
- 4:02that we actually do see the command
- 4:04being entered in which is great because
- 4:05it keeps up and it enters all the
- 4:07commands in there that we have run we'll
- 4:11get back to the video in just a moment
- 4:12but before we do I just wanted to
- 4:14mention my sponsor Linode Len ode is an
- 4:17awesome provider of cloud Linux servers
- 4:20setting up your Linux cloud servers or
- 4:22Lynne Oates is quick and easy with their
- 4:24intuitive cloud manager interface there
- 4:27are multiple instance types available to
- 4:29make any app or service flexible and
- 4:31scalable if it runs on Linux it runs on
- 4:33Linode use your Linode server to host a
- 4:35website set up a VPN create a next cloud
- 4:39instance host a game server and Moe
- 4:42you could set up your Leonard's in a
- 4:43data center nearest you with their
- 4:45latest opening in Mumbai in july 2019 if
- 4:48you need assistance 24/7 365 friendly
- 4:52support is available by phone or support
- 4:55ticket visit the URL on the screen right
- 4:57now to get started with twenty dollars
- 4:59in credit you can use towards setting up
- 5:01your very own Linode there are linux
- 5:03instance types available for as low as
- 5:05$5 a month so let's go ahead and get
- 5:07back to the video what if we don't want
- 5:11a command to be in the history so what
- 5:15I'm going to do is type a space and then
- 5:19I'm going to do sudo apt update to
- 5:22update my package repositories I'll
- 5:24press Enter and you know that that did
- 5:30that so I'll clear the screen and let's
- 5:32do history again wait a minute we don't
- 5:36see the sudo apt update command here at
- 5:39all I did just run it you saw me do it
- 5:41but it's not listed and actually that's
- 5:44a very common customization is that
- 5:47anything with us or command with a space
- 5:49in front of it is not actually going to
- 5:51show up in the history now this is
- 5:52dependent on the bash configuration and
- 5:55each distribution ships a different
- 5:58configuration for bash so yours might be
- 6:00a little different than that but most
- 6:02distributions will have a default
- 6:04customization that omits command to
- 6:07start with a space from the history why
- 6:09would you want to hide a command from
- 6:11your history well a couple examples
- 6:13include maybe you have a command that
- 6:16has sensitive information maybe it's a
- 6:18old program where you have to type a
- 6:20password and you know the bad thing is
- 6:23if you're to do you know type a password
- 6:26here I know this is not a good example
- 6:27that's going to fail but it's in the
- 6:29history right you know basically I just
- 6:35pretend I typed a command that included
- 6:36a password now it's in history so
- 6:38somebody hacks into the server now they
- 6:41could check the history file which is
- 6:42you know pretty much usually viewable by
- 6:44anyone and at that point they can get
- 6:47the password so you don't want to
- 6:50include a command
- 6:52command that might include some
- 6:54sensitive information you can type a
- 6:56space in front of that so that way you
- 6:58don't have to worry about a command that
- 7:01has sensitive information being shown in
- 7:03the history so a database server for
- 7:05example if you need to type a database
- 7:07password that's especially important you
- 7:09don't want that in the history and one
- 7:11way to avoid that if you can't omit the
- 7:14password altogether is to put a space in
- 7:16front so yeah I know that was a very
- 7:18simple concept guys and I did want to
- 7:21make sure that you guys understand
- 7:23history and know how to get the history
- 7:27and how to use it so yeah it's literally
- 7:30that simple you have the history command
- 7:31you can in most cases depending on the
- 7:33configuration hide a command from
- 7:35history if you put a space in front of
- 7:36it you can use the number in front of an
- 7:39item in the history to re execute that
- 7:41command that's pretty powerful stuff and
- 7:44another thing that also makes it very
- 7:46powerful too is if you have a you know a
- 7:48team of engineers and you know you want
- 7:51to basically see what someone else did
- 7:53to fix a problem history is
- 7:55indispensable especially when you're
- 7:56first starting a job at a new company
- 7:58you're supporting a server you never
- 8:00supported before you can use the history
- 8:02command to find out how people have
- 8:04solved similar problems in the past you
- 8:07might actually find a command that was
- 8:08used to resolve a problem because a lot
- 8:10of cases problems do repeat and you can
- 8:13find that information in the history it
- 8:15can be valuable to go through the
- 8:17history to see what others before you
- 8:19have done to solve problems and if you
- 8:22know there's a bad thing that happened
- 8:23to the server you can also check the
- 8:25history and it's a per-user thing but
- 8:27you could check the history for the
- 8:28users to find out it maybe if someone
- 8:29made a mistake maybe they removed a file
- 8:32that shouldn't have been removed or
- 8:34something like that or if a server you
- 8:36know went offline you might find that
- 8:38they rebooted it or they shut it down
- 8:39and then started to back up you'll see
- 8:42those commands in the history so it's
- 8:43just a good idea to know how to get to
- 8:46those commands and the history is
- 8:48indispensable so I highly recommend that
- 8:50you guys familiarize yourself with the
- 8:53history so there you go hope that was
- 8:54helpful for you guys and I will see you
- 8:57in the next video as soon as I have that
- 8:59uploaded see you there thank you so much
- 9:02for watching my video I really
- 9:03appreciate it if you want to help me out
- 9:05make sure
- 9:06you check out the description below this
- 9:07video where you'll find links to my
- 9:10latest book mastering of boom to server
- 9:12second edition as well as my patreon
- 9:15page if you liked this video be sure to
- 9:16click that like button and share it on
- 9:18Twitter or any other social media
- 9:20network and be sure to subscribe so
- 9:22you'll be the first to see my latest
- 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.