Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

4 Answers 4

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

share|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

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

share|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

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).

share|improve this answer

The file you want is: /root/.bash_history

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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