The default terminal in Ubuntu (13.04) preserves previous commands in an iterable list, even from session to session. Same with Byobu terminal.

But for some reason sudo shutdown .... is never preserved in this list.

Why is that? How can I change it so that the shutdown command is also saved, so I don't have type it each time? (I prefer using the terminal to the GUI.)

1 Answer 1


More accurately, your shell (bash, by default) preserves the command history. It's not a function of the terminal app, gnu screen, or byobu. They all run bash, so they all share a bash history.

I don't see the behavior you're describing. My sudo shutdown ... commands seem to be preserved fine.

Some reasons you might not see a command in your bash history -

  • when you enter a command with spaces at the very beginning of the line, it's not kept in the history (assuming your $HISTCONTROL contains "ignorespace" or "ignoreboth")
  • the HISTIGNORE variable defines patterns to be excluded from the history. A cautious admin might add 'shutdown' as a string to exclude, to avoid accidentally shutting down a system with a mistaken history invocation.
  • The history is written to disk (~/.bash_history) when the shell exits. If the shell is ended abnormally (e.g. segfault, power loss, etc) then your history for that session won't be saved. (During shutdown the shell is typically killed normally and writes its history.)

More details can be found here: Bash Reference Manual: Bash History Facilities

  • OK - good info - I have been using Windows forever, just getting my feet wet with Linux the last few months, in my spare time. I will have to poke around. I don't start commands with a space that I know of. Maybe Ubuntu has shutdown defined in HISTIGNORE by default because they have the GUI, etc?
    – Vector
    Jun 15, 2013 at 23:59
  • I thought they might have started that when I read your question, but my 13.04 workstation isn't doing that. I use the Ubuntu GNOME flavor distro, which is slightly different from a vanilla Unity install, but the differences between flavors rarely extend into the bash environment.
    – Steven K
    Jun 16, 2013 at 0:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .