[Super beginner's guide in 3 minutes] Done! Displaying the command execution history of Linux OS

table of contents
Hello!
This is Inoue, a Persian cat from Beyond Shikoku Office.
history "
command is one I use often as an MSP when dealing with issues on a daily basis It displays a list of the command execution history.
It's useful when you want to look back at the commands you've executed.
history command
■Displays a list of command execution history
[root@test-aws-harukainoue ~]# history 5 ls -l 6 cd dir1 7 ls -l 8 touch haruka{1..10} ・ ・ ・ 995 netstat 996 netstat -l 997 netstat -t 998 netstat -p 999 netstat -nltp 1000 history
■Shows the last five commands executed
[root@test-aws-harukainoue ~]# history 5 999 netstat -nltp 1000 history 1001 history 5 1002 history 1003 history 5
■Execute a command by history number
[root@test-aws-harukainoue kadai2]# !855 df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 475M 0 475M 0% /dev tmpfs 492M 0 492M 0% /dev/shm tmpfs 492M 400K 492M 1% /run tmpfs 492M 0 492M 0% /sys/fs/cgroup /dev/xvda1 8.0G 2.8G 5.3G 35% / tmpfs 99M 0 99M 0% /run/user/1000
If you want to execute command number 855
don't have to type the command, just type " ! " + " number (855)" to execute the command with
the specified number! Convenient!
■Show only command history containing mkdir
[root@test-aws-harukainoue ~]# history | grep mkdir 194 mkdir haruka 197 mkdir dir3 291 mkdir test1 298 mkdir txt.1 txt.2 385 mkdir haruka 820 mkdir haruka 836 mkdir sntax 842 mkdir syntax 965 mkdir test 1003 history | grep mkdir
You can also use
grep to the mkdir | (pipe)" + " grep " + the command you want to narrow down after " history .
Is there a way to search the execution history other than the history command?
" Ctrl " + " r " simultaneously in the terminal will put you into command history search mode!
For example, you can search for command history that contains "w".
(reverse-i-search)`w': pwd
" Ctrl " + " r " to enter search mode, then enter the alphanumeric characters you want to search for.
" Enter " to execute the command.
It's that easy!
The most recent command history will be displayed, so you can go back one by one with Ctrl " + " r
summary
" history ", a long command history will be displayed, but
by narrowing it down with
" grep " This looks useful! " I find myself using it frequently.
As someone who learns new things every day,
history " command is very useful as it allows me to look back and think, "Ah, what command was I typing at that time?"
continue to experiment and
write blogs about my favorite commands and commands that I personally want to understand better.
Growing every day, moving forward every day.
I have to update myself every day! ! !
Thank you for reading to the end.
0