In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to view and edit the commands that have been executed in the Linux command terminal". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to view and edit the commands that have been executed in the Linux command terminal".
History
The history command can be used to display the commands that have been executed, or to re-execute the required commands according to the treatment shown.
N display n recent records
-an add record
-r reads records, but does not add content records
-w overwrite the original history file
-c clear the record
-d [n] Delete specified n records
-n read the specified file
-r reads the file but does not record
-w overwrite the original file
Example 1
The code is as follows:
[root@redhat ~] # history # View all executed commands
1 ls
2 pwd
3 fc-l
4 history
The code is as follows:
[root@redhat ~] # history 2 # shows 2 entries
4 history
5 history 2
The code is as follows:
[root@redhat ~] #! 4 # execute the command number 4, pay attention to the exclamation mark
History
1 ls
2 pwd
3 fc-l
4 history
5 history 2
6 history
The code is as follows:
[root@redhat ~] # history-c # clear History
! $refers to the last argument of the previous command
The code is as follows:
[tank@localhost workspace] $ls-all
The total dosage is 1060
Drwxrwxr-x. 15 tank tank 4096 August 6 16:26
Drwx-. 60 tank tank 4096 August 15 16:13..
-rw-r--r-- 1 root root 2466 July 23 18:02 1.html
Drwxr-xr-x 7 tank tank 4096 July 17 03:02 ckeditor
Drwxr-xr-x. 2 tank tank 4096 May 29 00:08 database
The code is as follows:
[tank@localhost workspace] $! $# get-all
-all
Bash:-all: command not found
Example 2
The code is as follows:
[root@redhat] #!-N # execute the penultimate N command
[root@redhat ~] #! # execute the previous command
Fc
The fc command can edit commands that have been executed before and re-execute them in batch form
-1 lists all instructions for the quota between the first instruction and the last instruction
-n does not display the number
-r reverse sort
-e specifies text editor editing, default Vi
-s select instruction execution
Example 1
The code is as follows:
[root@redhat ~] # fc-l # View the executed command, root history, very similar
Eval echo "aaa" ls
349 eval echo "aaa"; ls
350 exec ls
351 apt-get install mysql
352 apt-get install mysql-server
353 exit
354 expr 4% 6
355 expr 4% 6
356 expr 4
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.