Blog links

Tricks and tips For Linux



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
history1 Linux History command  tricks and tips

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
historysearch Linux History command  tricks and tips

Deleting all the history:

You can clear all the history data. Go to terminal and type:
history -c
deletehistory Linux History command  tricks and tips

Searching using keyword using Ctrl+R:

Press Ctrl+R and type the keyboard and hit enter.historysearchusingkeyword Linux History command  tricks and tips

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.
executehistory Linux History command  tricks and tips


0 comments:

Post a Comment

2leep.com