webネタ

Webエンジニアが業務に関係することをメモしていく

linuxコマンドの履歴についてのまとめ

historyコマンド

history

いっぱいコマンドの履歴が出てきます。

historyコマンドの履歴に時間を記録

export HISTTIMEFORMAT='%y/%m/%d %H:%M:%S '
export HISTSIZE=10000
実行例
id
ls
cd /var/www/vhosts/
less /etc/php.ini
結果例
1010  2011-02-07 14:42:33 id
1011  2011-02-07 14:42:33 ls
1012  2011-02-07 14:42:33 cd /var/www/vhosts/
1013  2011-02-07 14:42:35 less /etc/php.ini

historyコマンドで参照してるファイル

~/.bash_history

psacctを使って全ユーザーのコマンドを記録

yum install psacct
service psacct start
lastcomm
lastcomm --user ryo
実行例
id
ls
cd /var/www/vhosts/
less /etc/php.ini
結果例
[root@localhost ~]# lastcomm --user ryo | head
less                    ryo      pts/2      0.01 secs Mon Feb  7 14:42
lesspipe.sh             ryo      pts/2      0.01 secs Mon Feb  7 14:42
ls                      ryo      pts/2      0.00 secs Mon Feb  7 14:42
id                      ryo      pts/2      0.00 secs Mon Feb  7 14:42

んー微妙に使えない・・・


おまけ

mysqlのコマンド履歴

~/.mysql_history

grant all on *.* to sample@localhost identified by 'password';
mysqlユーザー作成のクエリ発行した後等は、履歴をクリアしないと・・・・


トラバ(・ω・)
http://blog.justoneplanet.info/2011/02/07/mac%e3%81%aexampp%e3%81%abxdebug%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/trackback/