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
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
Deleting all the history:
You can clear all the history data. Go to terminal and type:
history -c
Searching using keyword using Ctrl+R:
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.
0 comments:
Post a Comment