Linux 如何查看root的bash_history?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13148438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view the bash_history for root?
提问by AnApprentice
I have a linux box on amazon's aws EC2. I can view the user's bash_history here:
我在亚马逊的 aws EC2 上有一个 linux 盒子。我可以在这里查看用户的 bash_history:
/home/ec2-user/.bash_history
However when I root in:
但是,当我扎根时:
sudo -s
I do not get the root's bash_history. How can I view/find the bash_history for the admin user?
我没有得到根的 bash_history。如何查看/查找管理员用户的 bash_history?
Thanks, Brett
谢谢,布雷特
采纳答案by Morgan O'Neal
You can run the history command to see the current users history.
您可以运行 history 命令来查看当前用户的历史记录。
回答by user1277476
When you "sudo -s", you apparently get the .bash_history of the source account, because $HOME is unchanged.
当您“sudo -s”时,您显然会获得源帐户的 .bash_history,因为 $HOME 未更改。
Try setting $HOME to ~root before you sudo -s.
在 sudo -s 之前尝试将 $HOME 设置为 ~root。
回答by Steve
Here's the quick way:
这是快速的方法:
sudo less /root/.bash_history
回答by tombolinux
Enable the logging within sudo, by inserting this with visudo
通过使用 visudo 插入来启用 sudo 中的日志记录
Defaults logfile=/var/log/sudo.log