Best Shell for UNIX systems

A manual always contains the rule of the thumb. Having zsh for root is just easy ,it's not your PC takes fire.
In the event zsh should break , you recover with a USB stick.
Their point is valid. I have locked out my root user for real in a system where I had an error in my root's zsh profile. If you have a bad .zshrc, game over. You need to restore from the installation CD.
If you're fine with taking your system offline and restoring - sure, go for it. Maybe I do it myself too. :)
 
They say you should not change your root shell!
I really hate struggling with csh in single user mode. At a time when I need to be sharp, I find myself stumbling in the dark, cursing csh, and no man pages available.
So, I make sure I always have the shell that works for me:
Code:
[ritz.1131] $ grep ^root /etc/passwd
root:*:0:0:Charlie &:/root:/bin/ksh
[ritz.1132] $ grep ^/bin/ksh /etc/shells
/bin/ksh
[ritz.1133] $ file /bin/ksh
/bin/ksh: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 11.3, FreeBSD-style, stripped
This is not at variance with the reasons given for what they say (shell may not be available if /usr not mounted), because a statically linked binary in the root has no dependencies.
The pdksh port has an option for static linking. The "make install" goes into the /usr/local prefix. I copy the binary manually to the root, and manually modify /etc/shells.
I accept that I have to maintain it manually. I keep abreast of both pdksh shell and libc patches (pdksh uses only one system library, libc, so it's not hard to keep watch).
All my FreeBSD systems have been like that since 1997, to no ill-effect.
 
/bin/sh for root (leave it) and scripts, mksh (ports) for interactive use.

So what is mksh?
On the website https://www.mirbsd.org/mksh.htm, it says "The MirBSD Korn Shell".
Well that does not really help.
In fact, going through the entire website for mksh, and I am still lost.

All the other shells that are mentioned on this thread, either I know them or I can find out what they do. Some I like and some I don't. I do have the choice.

But I can't be [expletive] X!#* [/expletive] with anything exclusive.

Thank you.
 
So what is mksh?

It's a fork of pdksh, so the genealogy is V7 Bourne clone -> BRL shell -> pdksh -> mksh.

There's some venerable names associated with that lineage.

It's widely available, but today, it's arguably most famous for being the default shell on Android.
 
Their point is valid. I have locked out my root user for real in a system where I had an error in my root's zsh profile. If you have a bad .zshrc, game over. You need to restore from the installation CD.
If you're fine with taking your system offline and restoring - sure, go for it. Maybe I do it myself too. :)

Not quite true. All you have to do is boot into single user mode from the boot menu and then select an alternative shell at the prompt. If the system is absolutely hosed then /rescue/sh is usually a good choice. This gives you enough to be able to fix what you broke.

The main reason for never changing roots shell used to be that /usr/local/bin was usually mounted separately to the / filesystem and if for any reason it failed to mount it would leave you broken. These days there is a good chance those two are on the same filesystem anyway.

Or alternatively the shell binary may be dynamically linked against other dependencies that may break. Like libncurses or something. This can be solved by compiling the shell as a static binary which ports like shells/bash let you do. There's even a package for it called shells/bash-static.

So basically, it's not the end of the world if you do this, just that you need to know the consequences, and how to deal with any issues that may happen.
 
There is zsh static also. But sometimes zsh can complain , like when there is no .history file.
Note : pdksh has also emacs edit mode.
 
I really hate struggling with csh in single user mode. At a time when I need to be sharp, I find myself stumbling in the dark, cursing csh, and no man pages available.
So, I make sure I always have the shell that works for me:
Code:
[ritz.1131] $ grep ^root /etc/passwd
root:*:0:0:Charlie &:/root:/bin/ksh
[ritz.1132] $ grep ^/bin/ksh /etc/shells
/bin/ksh
[ritz.1133] $ file /bin/ksh
/bin/ksh: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 11.3, FreeBSD-style, stripped
This is not at variance with the reasons given for what they say (shell may not be available if /usr not mounted), because a statically linked binary in the root has no dependencies.
The pdksh port has an option for static linking. The "make install" goes into the /usr/local prefix. I copy the binary manually to the root, and manually modify /etc/shells.
I accept that I have to maintain it manually. I keep abreast of both pdksh shell and libc patches (pdksh uses only one system library, libc, so it's not hard to keep watch).
All my FreeBSD systems have been like that since 1997, to no ill-effect.
You could also always manually type "zsh" when you login as root. It works. :)
 
You could also always manually type "zsh" when you login as root. It works. :)
It's certainly true that zsh is, to me, vastly more preferable than csh.
However, zsh has a dependency on /usr/lib/libdl.so.1, and if /usr is mounted (or in the root), then I could just type "ksh" (or ksh93) for a dynamically linked ksh.
My approach "fails safe" under all circumstances. ;)
 
When it's statically compiled one does not care,everything included. Unless, your .zshrc has a problem.
Milliseconds can be important on embedded systems but not on a desktop.
 
It's certainly true that zsh is, to me, vastly more preferable than csh.
However, zsh has a dependency on /usr/lib/libdl.so.1, and if /usr is mounted (or in the root), then I could just type "ksh" (or ksh93) for a dynamically linked ksh.
My approach "fails safe" under all circumstances. ;)
ksh93 has a cool feature. You can change argv[0] which has been quite handy in some situations I have encountered.
 
Back
Top