filmov
tv
HakTip - Linux Terminal 101: How to Use History

Показать описание
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.
____________________________________________
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.
Комментарии