When using the command line as root in Debian I get last commands executed as root. Where are those saved, what is the default file path and how can I find it?

thanks

link|improve this question

feedback

4 Answers

up vote 12 down vote accepted

If you're using bash (default shell in Debian) you can see all your recent history in the file ~/.bash_history (so .bash_history file in your local user)

Also from the command line you can type history and it'll also show you all your recent command history

link|improve this answer
thanks to all of you guys. – Elzo Valugi Jan 31 '11 at 10:13
1  
Note that the file will not be updated immediately with default setting, but after closing the shell (bash in this case). – Lekensteyn Jan 31 '11 at 13:16
is there also a log with the full history? – Elzo Valugi Jan 31 '11 at 15:02
Unfortunately not, unless you configure bash for doing so it'll cut off your history. You can decide how many lines of history you get by adding this to your ~/.bashrc file export HISTSIZE=10000 (in this case I get 10,000 lines of bash history) – lynxman Jan 31 '11 at 15:04
feedback

The file you want is: /root/.bash_history

link|improve this answer
Haha, you beat me twice by 2 seconds, good answer sir ;) – lynxman Jan 31 '11 at 9:39
feedback

What others have said about .bash_history is right and proper, but it won't pick up commands executed as root with sudo. Those will be in the individual users' ~/.bash_history files (or other files, if they use other shells than bash).

link|improve this answer
feedback

Executing command with space in front, wont store command in history also.

link|improve this answer
1  
This does not answer the question, but it's a really nice trick. Thanks, learned something new today :) – Lekensteyn Jan 31 '11 at 13:16
@user68884 interesting – Elzo Valugi Jan 31 '11 at 15:01
This can be controlled using the HISTCONTROL variable. – Dennis Williamson Jan 31 '11 at 15:16
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.