[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[Super introductory 3 minutes] Done! Display Linux OS command execution history

Hello!
This is Inoue, a Persian cat from Beyond Shikoku Office.


it is a command that displays a list of the execution history of the
history " , which I, as an MSP, often use when dealing with problems on a daily basis. You can use it when you want to look back at the commands you executed.

history command

Display 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

Display the 5 most recently executed commands

[root@test-aws-harukainoue ~]# history 5 999 netstat -nltp 1000 history 1001 history 5 1002 history 1003 history 5

Execute 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 can execute the command with the specified number ! " + " number (855)" without having to enter the command convenience!

Show only command history including 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 mk dir test 1003 history | grep mkdir

You can also narrow down and display only the execution history of the
mkdir using grep This can be done by typing | (pipe)" + " grep " + " command you want to narrow down after " history

Is there a way to search the execution history other than the history command? !

There was a feature where you could press
" Ctrl " + " r discovery! For example, 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.
How easy it is!
The history of the most recently used commands will be displayed, so you can go back one by one by pressing Ctrl " + " r

summary

If you use only
`` history ` `grep '', only the execution history that includes the target command will be displayed, which is likely to save time.
This looks like it will work! ” I end up using it frequently.
As someone like me who is always learning new things every day,
history " command is very useful because it allows me to look back and think, "Oh, what command did I use that time?"

I will continue to repeat trial and error 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.

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
2,479
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Akika Inoue

Belongs to the System Solutions Department.
He joined Beyond as a founding member of the Shikoku office.
I jumped into the IT industry with no experience. As an education team, we create curriculum and conduct training for new graduates, mid-career, and existing members.
The main business is server operation and maintenance.
Either way, we value your content.
Also belongs to the Web Content Division and YouTube Team.