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

table of contents
Hello!
I'm Inoue, the Persian cat at Beyond Shikoku office.
, which I, as an MSP (Managed Service Provider), frequently use while dealing with system issues on a daily basishistory"
this is a command that displays a list of the execution history of the
. It's useful when you want to review 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, you
don't have to type the command manually;!" + "numbersimply by pressing
you can execute the specified command
■`mkdir`.Show only command history that includes
[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
greptomkdirfilter and display only the execution history of the
"history" followed by a pipe ("|"), then "grep", and finallythe command you want to filterby.
Is there a way to search the execution history other than the history command?
"Ctrl" + "rI discovered a feature that allows you to enter command history search mode by pressing
For example, let's search for command history containing "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.
Wow, that's easy!
The command history is displayed from the most recently entered commands, soCtrl" + "ryou can go back one by one by pressing
summary
"history," a long list of command history will be displayed, but
"grepby narrowing it down with
"This looks useful!" and have been using it frequently.
For me, who has to learn new things every day,
looking back and thinking, "Ah, what command did I type at that time?"history" command is very useful for
I will continue to experiment and learn through trial and error,
and write blog posts about my favorite commands and commands that I personally want to understand better.
Growing every day, moving forward every day.
I must update myself every single day!!!
Thank you for reading to the end.
0
