지금까지 입력했던 명령어들이 표시된다.
history -c
히스토리 삭제
[root@Linux ~]# history -c [root@Linux ~]# history 1 history |
!명령어 번호
히스토리에 기록된 번호의 명령어가 실행된다.
[root@Linux ~]# history 1 history ... 107 echo \#comment #comment 108 history [root@Linux ~]# !107 echo \#comment #comment #comment |
!!
바로 직전의 명령어를 재실행한다.
[root@Linux ~]# ls -l total 0 drwxr-xr-x. 2 root root 6 Apr 28 12:48 test [root@Linux ~]# !! ls -l total 0 drwxr-xr-x. 2 root root 6 Apr 28 12:48 test |
히스토리에 시간 출력
- /etc/profile 을 vi편집기로 연다.
[root@Linux ~]# vi /etc/profile |
- profile 맨 아랫줄에 추가로 입력
HISTTIMEFORMAT="%F %T " |
- 저장 후 나와서 재부팅 명령어 입력 또는 재부팅
[root@Linux ~]# source /etc/profile |
- history 명령어를 사용하면 명령어 옆에 타임라인이 출력된다.
207 2023-04-25 11:29:33 cat /etc/passwd/etc/shadow/ 208 2023-04-25 11:29:33 cat /etc/passwd/etc/shadow 209 2023-04-25 11:29:33 pwd 210 2023-04-25 11:29:33 echo #comment #comment 211 2023-04-25 11:29:33 echo \#comment #comment |
시간 설정에 대한 형식
- %d: 요일
- %m: 월
- %y: 년
- %H: 시간
- %M: 분
- %S: 초
- %F: Full date (Y-M-D 형식)
- %T: 시각 (H:M:S 형식)
- %c: 날짜 및 타임스탬프 완료 (Day-D-M-Y H:M:S 형식)
profile 실행순서
- /etc/profile.d/*.sh : profile.d에 있는 모든 sh파일
- /etc/profile : 시스템 전체 적용
- /etc/bashrc
- ~/ .bashrc
- ~/ .bash_profile : 사용자 적용
'리눅스-기초명령어 > 명령어 관리' 카테고리의 다른 글
리눅스 명령어 단축키 (0) | 2023.08.31 |
---|---|
grep (0) | 2023.08.31 |