반응형
history 기록되는 과정
- 명령어 입력 -> buffered -> 로그아웃 시 .bash_history에 기록
history 결과의 구성요소
- .bash_history + buffer
- .bash_history: 이전 세션에서 입력한 명령어
- buffer: 현재 세션에서 입력한 명령어
- 로그인 후 입력한 명령어는 history에는 보이나, .bash_history 내용을 까보면 보이지 않음(로그아웃 시 기록)
-
[root@localhost system]# history 1 history 2 cd /etc/yum.repos.d/ 3 ll 4 vim CentOS-Base.repo 5 cat CentOS-Vault.repo 6 cd .. 7 ll 8 cd systemd/ 9 ll 10 cd system/ 11 ll 12 history [root@localhost system]# cat ~/.bash_history
-
- 로그인 후 입력한 명령어는 history에는 보이나, .bash_history 내용을 까보면 보이지 않음(로그아웃 시 기록)
buffer의 내용을 .bash_history에 동기화
- # history -a
-
[root@localhost system]# cat ~/.bash_history [root@localhost system]# history -a [root@localhost system]# cat ~/.bash_history history cd /etc/yum.repos.d/ ll vim CentOS-Base.repo cat CentOS-Vault.repo cd .. ll cd systemd/ ll cd system/ ll history cat ~/.bash_history history -a
-
history 완전 삭제 방법
- 로그인 이전 사용했던 명령어 기록 삭제 (.bash_history)
- 접속 계정의 home 디렉토리로 이동
- # cat /dev/null > ~/.bash_history
-
[root@localhost ~]# cd [root@localhost ~]# cat /dev/null > ~/.bash_history [root@localhost ~]# cat .bash_history
-
- 로그인 이후 사용한 명령어 기록 삭제 (history)
- # history -c
- 현재 세션에서 입력한 명령어들 삭제(버퍼 내용)
- # history -c
- .bash_history 삭제 후 버퍼 내용(history -c)까지 삭제한 결과
-
[root@localhost system]# cat /dev/null > ~/.bash_history [root@localhost system]# history -c [root@localhost system]# history 1 history
-
- 혹은 # history -a 를 이용하여 Buffer내용을 .bash_history에 적용시킨 뒤, cat /dev/null > .bash_history를 해도 동일함.
- 이 경우, # history를 입력하면 Buffer의 내용이 보일 수 있으나, 로그아웃 이후 보이지 않음.
반응형
'Linux > CentOS' 카테고리의 다른 글
[Linux] 파일 정보 확인하기 (권한, 용량, 소유자 등) (0) | 2021.11.23 |
---|---|
Clamav 설치 및 실행 방법 (0) | 2021.01.21 |