屬性 : 系統相關 - 其他
語法 :
history [欲查詢最近其他使用過的指令個數] [參數]
!! <執行最近一次執行的命令>
![history 中的編號] <執行history編號的命令>
執行範例 :
* 列出最近5個使用的指令
allentest:~ # history 5
910 history 5
911 head -c 20 aa.txt
912 clear
913 cat aa.txt
914 history 5
* 執行前一次執行指令
allentest:~ # !!
history 5
910 history 5
911 head -c 20 aa.txt
912 clear
913 cat aa.txt
914 history 5
* 執行編號為913的指令
allentest:~ # !913
cat aa.txt
line 1 : test
line 2 : test
line 3 : test
line 4 : test
line 5 : test
line 6 : test
line 7 : test
如果你經常使用Linux命令,那麼使用history命令無疑會提升你的工作效率。
History命令主要用於顯示歷史指令記錄內容, 下達歷史紀錄中的指令 。
1>History命令語法:
linux中history命令不僅僅讓我們可以查詢歷史命令而已. 我們還可以利用相關的功能來幫我們執行命令。
2>運行特定的歷史命令
history會列出bash保存的所有歷史命令,並且給它們編了號,我們可以使用“歎號接編號”的方式運行特定的歷史命令.
語法說明:
[test@linux]# [!number] [!command] [!!]
參數說明:
3>History命令實戰
[test@linux] # history <列出所有的歷史記錄:>
[test@linux] # history 10 <只列出最近10條記錄:(注,history和10中間有空格)>
[test@linux] #!99 <使用命令記錄號碼執行命令,執行歷史清單中的第99條命令>
[test@linux] #!! <重復執行上一個命令>
[test@linux] #!rpm <執行最後一次以rpm開頭的命令(!? ?代表的是字符串,這個String可以隨便輸,Shell會從最後一條歷史命令向前搜索,最先匹配的一條命令將會得到執行。)>
[test@linux]# history | more [color=brown]<逐屏列出所有的歷史記錄:>
[test@linux] #history -c <立即清空history當前所有歷史命令的記錄>
補充說明 :
1. history 可記錄使用過的指令, 這對於使用過指令追蹤與安全的管控是很重要的.
2. History命令的用途確實很大!但需要小心安全的問題!尤其是 root 的歷史紀錄檔案,這是黑客們的最愛!因為不小心的 root 會將很多的重要資料在執行的過程中會被紀錄在~/.bash_history 當中,如果這個檔案被解析的話,後果不堪設想!
This is a blog to track what I had learned and share knowledge with all who can take advantage of them
標籤
- [ 英文學習 ]
- [ 計算機概論 ]
- [ 深入雲計算 ]
- [ 雜七雜八 ]
- [ Algorithm in Java ]
- [ Data Structures with Java ]
- [ IR Class ]
- [ Java 文章收集 ]
- [ Java 代碼範本 ]
- [ Java 套件 ]
- [ JVM 應用 ]
- [ LFD Note ]
- [ MangoDB ]
- [ Math CC ]
- [ MongoDB ]
- [ MySQL 小學堂 ]
- [ Python 考題 ]
- [ Python 常見問題 ]
- [ Python 範例代碼 ]
- [心得扎記]
- [網路教學]
- [C 常見考題]
- [C 範例代碼]
- [C/C++ 範例代碼]
- [Intro Alg]
- [Java 代碼範本]
- [Java 套件]
- [Linux 小技巧]
- [Linux 小學堂]
- [Linux 命令]
- [ML In Action]
- [ML]
- [MLP]
- [Postgres]
- [Python 學習筆記]
- [Quick Python]
- [Software Engineering]
- [The python tutorial]
- 工具收集
- 設計模式
- 資料結構
- ActiveMQ In Action
- AI
- Algorithm
- Android
- Ansible
- AWS
- Big Data 研究
- C/C++
- C++
- CCDH
- CI/CD
- Coursera
- Database
- DB
- Design Pattern
- Device Driver Programming
- Docker
- Docker 工具
- Docker Practice
- Eclipse
- English Writing
- ExtJS 3.x
- FP
- Fraud Prevention
- FreeBSD
- GCC
- Git
- Git Pro
- GNU
- Golang
- Gradle
- Groovy
- Hadoop
- Hadoop. Hadoop Ecosystem
- Java
- Java Framework
- Java UI
- JavaIDE
- JavaScript
- Jenkins
- JFreeChart
- Kaggle
- Kali/Metasploit
- Keras
- KVM
- Learn Spark
- LeetCode
- Linux
- Lucene
- Math
- ML
- ML Udemy
- Mockito
- MPI
- Nachos
- Network
- NLP
- node js
- OO
- OpenCL
- OpenMP
- OSC
- OSGi
- Pandas
- Perl
- PostgreSQL
- Py DS
- Python
- Python 自製工具
- Python Std Library
- Python tools
- QEMU
- R
- Real Python
- RIA
- RTC
- Ruby
- Ruby Packages
- Scala
- ScalaIA
- SQLAlchemy
- TensorFlow
- Tools
- UML
- Unix
- Verilog
- Vmware
- Windows 技巧
- wxPython
訂閱:
張貼留言 (Atom)
[Git 常見問題] error: The following untracked working tree files would be overwritten by merge
Source From Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 # git clean -d -fx 方案2: 今天在服务器上 gi...
-
屬性 : 系統相關 - 檔案與目錄 語法 : du [參數] [檔案] 參數 | 功能 -a | 顯示目錄中個別檔案的大小 -b | 以bytes為單位顯示 -c | 顯示個別檔案大小與總和 -D | 顯示符號鏈結的來源檔大小 -h | Hum...
-
轉載自 這裡 前言 : 歡迎來到二進位的世界。電腦資料都是以二進位儲存,想當然程式語言的變數也都是以二進位儲存。在 C/C++ 當中有幾個位元運算子: << SHIFT LEFT 、 >> SHIFT RIGHT 、 & AND 、 ...
-
Understanding the core indexing classes : As you saw in our Indexer class ( A simple application ), you need the following classes to...
沒有留言:
張貼留言