HakTip - Linux Terminal 101: How to Use History

preview_player
Показать описание
Hak5 -- Cyber Security Education, Inspiration, News & Community since 2005:
____________________________________________
Today we're learning and using the history command.

All of your old commands are stored in this file called .bash_history, which you can search via the terminal. We're going to use lots of tools we've learned up til now to really get into the history.

First off, check out that file with: history | less

This will store the last 500 commands. If you want to check a specific listing, you can change this with grep: history | grep /usr/bin

n this example, the number at the beginning is where it falls in the history list. To shorten this line, you can type !thenumber. Bash expands this line item for you.

To search incrementally, which kind of reminds me of a Google search, you can hit CTRL-R, then type in your search query. For /usr/bin we get a result. You can use this result by pressing enter, or copy with CTRL-J. You can also search farther back in history with CTRL-R. To quit, use CTRL-G or C.

We're back with history! There are some expansion commands that you can use for history, and they start with a !. Some include: !! to repeat the last command, !number to run that listing item number, !string to repeat a list starting with string, and !?string to repeat a list containing string. Don't use the last two unless you are sure you know what you're doing. Check out the bash man page for history expansion for more!

____________________________________________
Founded in 2005, Hak5's mission is to advance the InfoSec industry. We do this through our award winning educational podcasts, leading pentest gear, and inclusive community – where all hackers belong.
Рекомендации по теме
Комментарии
Автор

Thanks! That's the whole point of HakTip. Short tips for users who want to watch Hak5 but don't know where to start.

ShannonMorse
Автор

I'm enjoying it...Since I've only been running Linux for a year or so, it's great to get to know additional terminal commands. You can't do everything through a GUI...Keep it up Shannon!

msven
Автор

I've learned so much here. Great vid.

BenTaylorPostProduction
Автор

Thanks, I'm new to Linux so I really appreciate these short helpful tips, good work!

PurpleReignUWdawgs
Автор

Actually, this show is called HakTip. If you don't like it, don't watch. We still do Hak5 too, which will always be for advanced segments.

ShannonMorse
Автор

If you don't like it, watch Hak5 instead. :)

ShannonMorse
Автор

Agreed. I miss what Matt did in his segment.

UltimateArco
Автор

Depends what you need it for. I mean really you can download all the tools that BT has on any distro but it's just easier to have them all together in one OS.

mdkwlan
Автор

What software do you use to add the computer screen to the background. That's awsome.

wesleyjmorales
Автор

How do you clear the history? This thing looks like it goes back to the beginning of time!!

DaeOh
Автор

bt5 is ubuntu, its just preloaded with hacking tools installed on it. Unless you need those tools for some reason, you should just use the standard version of ubuntu.

choomatt
Автор

Say for example I have ~500 lines in my history. I want lines 320 to 430. What would be the command? 

roughryder
Автор

history -c is good fore clean session, then history comes back on start-up...

CyrusBrinkworthRAS
Автор

All I use is
sudo !!
When I forgot to use sudo for the last command.

JoakimBidebo
Автор

Just here to delete my history on another platform

Xefer
Автор

I need to know.... are they real? If they are then she's legit.

Russian-Troll
welcome to shbcf.ru