테스트 사이트 - 개발 중인 베타 버전입니다

history 명령에 대해

· 13년 전 · 375
 
history 가끔 사용을 하는데, 사용법을 잘 모를때가 있어 찾게 되네요.
이참에 정리한번 합니다. 
 
 
history 명령을 입력하면, 지금까지 사용한 명령들이 나타납니다.
 
아래는 사용 예입니다.
 
1. 최근 사용한 명령 20개 보기
 
[root@localhost ~]# history 5
  388  [2010-12-02 14:33:01] ls
  389  [2010-12-02 14:33:51] history 
  390  [2010-12-02 14:34:58] history -n 20
  391  [2010-12-02 14:35:01] history 20
  392  [2010-12-02 14:35:51] history 5
 
 
2. history 내용을 지워보자
 
[root@localhost ~]# history -c
 
 
3. 방금전에 실행했던 명령 실행하기
 
[root@localhost ~]# !!
 
4. 실행한 명령들의 번호로 실행하기
 
[root@localhost ~]# history 5
  167  [2010-12-02 14:39:45] history 
  168  [2010-12-02 14:40:15] history 
  169  [2010-12-02 14:40:24] history 5
  170  [2010-12-02 14:40:35] ls
  171  [2010-12-02 14:40:37] history 5
[root@localhost ~]# !170
ls
anaconda-ks.cfg  install.log  install.log.syslog
 
5. 특정단어로 시작하는 가장 최근 명령 실행하기
 
[root@localhost ~]# !his
history 5
  172  [2010-12-02 14:41:42] ls
  173  [2010-12-02 14:42:17] history 5
  174  [2010-12-02 14:42:42] history 3
  175  [2010-12-02 14:43:03] history 5
  176  [2010-12-02 14:43:34] history 5
 
6. 이전 명령 보기
 
[root@localhost ~]# !!:p
history 5
 
7. history  내용이 저장되는 위치
 
/root/.bash_history
 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
32341
32339
32326
32325
32322
32319
32318
32316
32315
32313
32312
32311
32310
32304
32303
32300
32293
32292
32291
32285
32284
32275
32271
32268
32265
32261
32258
32257
32255
32254
32253
32251
32250
32249
32247
32246
32245
32244
32243
32242
32241
32240
32239
32238
32237
32236
32232
32229
32228
32227
32217
32215
32214
32213
32211
32207
32196
32193
32192
32190
32188
32186
32184
32173
32172
32171
32167
32165
32163
32162
32158
32157
32155
32151
32149
32135
32132
32127
32125
32122
32120
32119
32117
32116
32115
32114
32112
32111
32109
32107
32104
32103
32102
32101
32094
32089
20404
31036
8279
8268