Shell history.
What a shell history is.
Every command that you run in your Linux operating system or in your terminal, it creates a history
of this command.
This history command, I'm telling you, is so useful that even when you are troubleshooting, you are
trying to find out what are the commands people ran that actually bring brought your system down or
crash your system or what is the command that was run that deleted a file?
All those commands that you run in Linux, just be careful.
Those commands are recorded and those commands are recorded and can be retrieved by simply running a
history command.
So it's just the history command with everything is lowercase.
When you run it, you will get all the listing of your commands that's been run by a specific user.
Let's try to run it.
I am already in here.
Who am I?
Myself.
Just confirm which directory are men and which host are men.
Awesome.
We have confirmed that we are logged into the right system.
Now I wanted to clear the screen and run history command.
Whoa.
Such a long list of history commands.
What is telling me right here that I have so far?
Since I have logged into the system, I have ran the History command 666 times.
These are the different commands I have ran since I logged in or since as many times I logged in.
Since the system is built, how do you view other commands?
Of course, if you are running putty you could just scroll up.
But what if you wanted to see all of them?
One page at a time.
Please tell me you know that history py bit more it Yes.
Now it's going to start listing all the commands one by one, one by one.
The first command when I logged into the system the very first time when I built a system was p w d
next command added exit if config.
Those are different commands is if you could see you could check every single command that we did.
You could also run this command in your shell and find out what are the commands it listed.
It's not only going to list the command that you ran successfully, it will also list the command that
you ran incorrectly or wrong, command or command that did not work.
So that's how the history command works.
Now, a coolest feature of history Command, which you're going to love that if you wanted to run any
of this command again, you could copy and paste, which you could do that.
But there are chances that it's not going to get copied or it's not going to get paste.
But if you wanted to create, if you wanted to run a command again, let's say I wanted to pick a command,
I wanted to pick a command, I wanted to run last last tell you which users are logged in and awk awk.
It's going to print out only the first column of the output last, and then it's going to sort it out
and it's going to sneak it out.
Of course, it's a long command.
There's two ways you could do it is one, you could copy paste or you could just do four or six, remember
four or six that this command, the number of this command was four or six.
And when you run it, how do you run it?
You just simply type back 406, which is 406, you run it, it ran the command and give you the output
of that command.
Isn't that cool, guys?
It is very cool.
I use it all the time and I love this because this way I don't remember a command that I typed maybe
five months ago.
If I go into a history, I look into it right away.
And if you wanted to do history command and you remember that you ran a command that had awk in it,
you were looking for something that has OC in it.
So what do you do?
You just grab flock and it will list all the commands that I ran that has awk inside of it.
If you want to do history and grub and you want to check all the commands, that has changed mod in
it, you get all those commands.
So again, try it.
Try it as many times as you want.
And please always run man on history and you will find many information and a lot more options that
you could use.