# Is it safe to "customize" the root profile?



## fscorrea (Feb 16, 2017)

Would `# chsh -s /usr/local/bin/bash root` cause any obvious problem? For example, a daemon relying on csh could misbehave and crash or silently cease to work properly. Am I just overthinking this?

What about creating a /root/.inputrc so Ctrl+Left/Right works "properly" (i.e. moving back and forward words?)

Thanks in advance.


----------



## SirDice (Feb 16, 2017)

fscorrea said:


> Would # chsh -s /usr/local/bin/bash root cause any obvious problem?


Yes. Note that bash is not part of the base OS. So if you're having problems with the machine (because of a botched package upgrade for example) the last thing you want happening is not being able to login because the shell can't find a library.

If you insist on using bash enable the toor account and leave root as is.



> What about creating a /root/.inputrc so Ctrl+Left/Right works "properly" (i.e. moving back and forward words?)


You can fix that for csh(1) using bindkey in ~/.cshrc. I used mine to "fix" the 'home', 'end' and 'delete' keys:

```
bindkey "^W" backward-delete-word
		bindkey -k up history-search-backward
		bindkey -k down history-search-forward
                bindkey "^[[1~" beginning-of-line
                bindkey "^[[4~" end-of-line
                bindkey "^[[3~" delete-char
```


----------



## linux->bsd (Feb 17, 2017)

fscorrea said:


> Would `# chsh -s /usr/local/bin/bash root` cause any obvious problem?



I took a different approach than SirDice did (sorry, still haven't figured out which [ CODE ] blocks hyperlink users' names):

I've got this at the bottom of my /root/.cshrc file:

```
alias hi        /usr/local/bin/bash --login
[ ... ]
echo '`hi'\'', this is tcshell. i'\''ll try to run bash.'
/bin/test -x /usr/local/bin/bash && /usr/local/bin/bash --login
```

If /usr/local/bin/bash exists start a `bash` login session. If it doesn't exist (because /usr/local/ isn't mounted, etc.) then I'm stuck in the horrible `tcshell` until I fix it.  But then I just type `hi` and I'm back in glorious `bash`.



> What about creating a /root/.inputrc so Ctrl+Left/Right works "properly" (i.e. moving back and forward words?)



I'll just leave these here in case you're a fan of Vim and want to have (a slightly-crippled form of) its editing commands at the command line. These few emacs key-bindings are a must-have:

```
set -o vi
set keymap vi-command
bind -m vi-command '"^[.": yank-nth-arg'
bind -m vi-command '"^[{": complete-into-braces'
bind -m vi-command '"^[y": yank-pop'
set keymap vi-insert
bind -m vi-insert '"^[.": yank-last-arg'
bind -m vi-insert '"^[{": complete-into-braces'
bind -m vi-insert '"^[y": yank-pop'
#bind -m vi-command '".": self-insert'
```

There are way more in the 'Readline Command Names' section of `bash`'s manpage:

```
Commands for Moving
       beginning-of-line (C-a)
              Move to the start of the current line.
       end-of-line (C-e)
              Move to the end of the line.
       forward-char (C-f)
              Move forward a character.
       backward-char (C-b)
              Move back a character.
       forward-word (M-f)
              Move forward to the end of the next word.  Words are composed of alphanumeric characters (letters and digits).
       backward-word (M-b)
              Move back to the start of the current or previous word.  Words are composed of alphanumeric characters (letters and digits).
```


----------



## Tabs (Feb 17, 2017)

linux->bsd said:


> I took a different approach than SirDice did (sorry, still haven't figured out which [ CODE ] blocks hyperlink users' names):
> 
> I've got this at the bottom of my /root/.cshrc file:
> 
> ...


I normally compile bash or zsh statically then copy it into /usr/bin and use that.


----------



## linux->bsd (Feb 17, 2017)

Tabs said:


> I normally compile bash or zsh statically then copy it into /usr/bin and use that.



I like it. But how do you manage its updates? Do you have an @daily or @weekly cron job that checks its version against a remote updates mirror, and then compiles it in the background?


Note: I read a thread today on the freebsd-questions mailing list about someone that added some code to the bottom of their ~/.cshrc file and that broke SFTP for that user. Wrapping the test and execution line I posted above in this test should fix that:


```
if($?prompt) then
        echo '`hi'\'', this is tcshell. i'\''ll try to run bash.'
        /bin/test -x /usr/local/bin/bash && /usr/local/bin/bash --login
endif
```

"Only interactive shells set $prompt." Tested and working for me.


----------

