Saturday, February 25, 2017

Ubuntu 16.04 how to nano override, setup root bash, and root bash history

Have you ever been annoyed by the crappy nano editor that ubuntu presents for crontab and similar interfaces ? What about the "no command line history" thing in the default root shell ? Yes, I know that is a security issue so don't start with that. This post will guide you out of the wilderness of nano and into the promised land of the real admin's editor vi.

1. Fix your personal login...
    Add these lines to the end your ~/.bashrc file...

    set -o vi
    export EDITOR=vim

   notes: Line 1 puts the history commands into sensible vi mode rather than the heinous emacs mode.               Line 2 fixes crontab and its' like to use vi rather than the wretched nano editor.

2. Fix the root login...
    Add these lines to the end of the /root/.bashrc file...

    set -o vi
    export EDITOR=vim
    export HISTFILE=/home/mylogin/.root/.bash_history

    notes: Line 3 moves the history file to a full read/write footing.
              Also, "mylogin" in practice should be your actual home directory.
              Finally, don't forget to "mkdir /home/mylogin/.root".

I know there are global ways to accomplish these goals. I am not interested in that, I want to alter just the behavior of my login and the root login. All other logins may remain in the dark, lonely nano wilderness for all I care. If, in future, I choose to expose my personal system to the internet... I will of course take appropriate steps to plug the root command line history issue. Probably by creating a script to "erase the tracks" at root logout.