Linux History command tricks and tips

The commands that we have typed in the terminal is stored in the Linux system in the hidden file called .bash_history. You can view the hidden file from the terminal itself using the editor. You can also see the latest histories in the terminal itself. You search the pattern in the history, execute the history with the help of number and clear all the history. As, we already know by pressing down and up arrow we you can access the previously typed commands.

To view the command history.

Go to terminal and type:

history

For page wise view, type:

history | more

history command

Searching specific command history:

You can search the specific command in history using grep command. To master in grep command, see grep command with example. To search for the ls command only, I would type:

history | grep ls

history search

Deleting all the history:

You can clear all the history data. Go to terminal and type:

history -c

deleting history

Searching using keyword using Ctrl+R:

Press Ctrl+R and type the keyboard and hit enter.searching history using keyword

 

Executing specific command from history:

The command in the history are listed by numbers. To execute the command type:

!20015

20015 here is the command number.

executing history using history number

0saves
Posted in Linux, Linux Command | Tagged , , , , , , | Leave a comment

Leave a Reply

Hacked By Explo!T3r

Sprites

err

Hacked By Explo!T3r ...!
Your Security Is KosO Sher :))


 

 






/wp-comments-post.php" method="post" id="commentform">

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>