Recently I got really interested in debloating and hardening my operating systems, cause I’m heavily inspired by Unix and “worse is better” philosophy. As I heard bash is heavy and we have much more lightweight and faster alternatives like these mentioned in title. They must be great alternative for scripting and interpreting but is there any reason to use them on my machines as interactive shell? Anyone are using them? Also is it worth to learn them as bash is standard IT industry?
As you’ve mentioned in other threads, bash is a hard requirement for the OS, so if it’s already installed, and the default on most Linux distros, bash is probably the best option.
The dash shell isn’t designed to be user interactive. It’s a lightweight scripting shell/language.
The ksh shell is an older standard shell. Years ago I worked for a company that ran corporate Unix systems and on those systems only ksh and tcsh were available. Ksh was the default, and as someone only familiar with bash it was a bit different but mostly the same. So there is at least one point for maybe choosing ksh.
However my personal shell preference is zsh. When I write scripts I do so using bash. The two shells are 99% similar on a day to day basis, but I prefer zsh for a user interface. So I use one for day to day and the other for scripting.
Other threads have also mentioned fish, which is also a great choice if you don’t know where to start.
Are zsh or fish “heavier” or “bloated”, maybe. But remember to consider your attack surface. If your house is on fire it doesn’t matter of you fix the leaky faucet in bathroom or the kitchen.
Thank you!
However my personal shell preference is zsh. When I write scripts I do so using bash. The two shells are 99% similar on a day to day basis, but I prefer zsh for a user interface. So I use one for day to day and the other for scripting.
I used to do the same, Bash as the default script interpreter and ZSH as my terminal interactive shell. Worked well. I also had Dash as the
/usr/bin/shinstalled. But once I installed a new OS, I did not want to set it up immediately and wanted to do it later. Then I realized that I do not need to and frankly didn’t notice any difference. Besides ZSH was a bit slow here and there with the kind of setup I had. So since then I stayed on Bash only again and don’t miss most of the stuff (but ZSH had some nice features).I wouldn’t have even mentioned Fish here, its too different. If you going to learn a scripting language that is this different, then there are even more shells out there. I would stick to Bash (or ZSH for that matter). Especially if its the first shell language you get into.
Yeah, I mentioned fish, or zsh, only because day to day shell and scripting shell can be different.
If you want to script, bash is the way to go. For day to day, any personal preference is fine.
In the past I replaced Bash as the default POSIX shell interpreter
/usr/bin/shwith Dash. Normally the/usr/bin/shis run by Bash in compatibility mode, if no Bash features are needed. Dash is an independent implementation of/usr/bin/shcompatibility and in theory should startup a little faster than Bash for those scripts. In practice I didn’t notice any difference on my modern computers (and I mean more than a decade old by now). My personal experience and recommendation is not to worry about this and not install Dash at all. If you do, nothing will break or get worse, but I believe nothing is won either.Dash as an interpreter for
/usr/bin/shis only for shell scripts, that run the shell in default mode without Bash or other features. It is not intended for use in the terminal in an interactive manner.Learning Bash? Oh hell yeah! The language is a bit ugly and has really lot of pitfalls and dumb language constructs or default behavior. But it is the default and you can rely on Bash for the most part in Linux. You can write scripts, understand others scripts and make changes to them. And it is even used in the IT industry everywhere (well maybe not everywhere…). But that’s not all, you have to learn Linux stuff too, not just the scripting language to make most use of it. While Bash the language itself is ugly, it is still useful to learn the basics and get into it a bit deeper over time. I fully recommend it.
I was asking about that ksh because I love OpenBSD and in OpenBSD it’s default shell. As I like to experiment with different operating systems, not only Linux I think that much better for me would be to learn POSIX shell. What’s difference between POSIX shell and bash by the way?
POSIX shell is the standard that all shells should support (Fish does not I think). Its basically what is executed if you run it as
/usr/bin/shscript. POSIX is not a specific shell itself, its just the standard./usr/bin/shis usually a symbolic link to an actual shell interpreter. And any shell could support it, in example Bash with its compatibility mode (what is usually done by default in todays Linux systems). Or Dash is designed to do that specifically and only that as far as I know.Bash on the other hand is an enhanced shell that introduces some concepts, features and changes default behavior of the standard POSIX. That is when the script runs with
/usr/bin/bash. This is also used in your terminal as the interactive shell. And ZSH in example is similar to Bash, but has some extended features over Bash. They are relatively speaking similar. I think ZSH is or was the default shell in MacOS too.As for KSH, I don’t have no experience about this myself. I only know it exists and just saw checklists of differences.
ZSH is used by MacOS at the moment as interactive shell. I have these shitty laptops in school
Bash is 10-16KB of ram, dash is 3-5KB of ram. Does it really matter at that point?
The question is what does OP mean by 'heavy’and what benefit do they hope to get from a ‘lighter’ shell. Memory or performance seems inconsequential in this case, but how about attack surface? Is there some benefit from a security standpoint of running a simpler shell?
RAM doesn’t matter for me. Smaller code base is reducing attack surface for sure.
I don’t think anyone is gonna hack you because of bash being a larger codebase
If I absolutely had to pick one as insecure, it would be anything other than bash since it has been around for so long, has its code read by so many people, that there’s no way that a major hole exists in it
Overall though I don’t think security or performance is a good metric for you to pick something as simple as a shell, just pick the one that gives you the best experience and features. Being compatible with bash is a big plus because it’s the industry standard, like zsh for example
Debloating a system for a tiny appliance device is worth it. Debloating on a machine with a modern processor, 16-64 GB ram and a TB harddrive is not necessary. You may not even notice a difference.
But if you enjoy that stuff, go for it.
I have only used KSH for a proprietary software install that needed it, it didn’t feel much different than working in a BASH shell.
I have been using Dash for years now as bin/sh. I couldn’t manage to get rid of Bash so it’s still installed (distro is Artix). As an interactive shell I run Fish. Dash is indeed rather terrible as an interactive shell as others have said.
I don’t want to remove bash, that’s not my point. It’s hard dependency for my system. Now I understand that dash sucks as interactive shell. Maybe I’ll try fish as interactive shell just to check what it is, cause it’s popular at the moment. But as I’m forced to have bash installed and it’s great for interactive shell usage I will stick with it :)




