Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
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
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

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

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

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

share|improve this answer
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

Your Answer


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.