5

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

Elzo Valugi
  • 387
  • 2
  • 4
  • 15

4 Answers4

12

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

lynxman
  • 9,397
  • 3
  • 25
  • 28
  • 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
9

The file you want is: /root/.bash_history

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
3

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

MadHatter
  • 79,770
  • 20
  • 184
  • 232
2

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

Tornike
  • 121
  • 2