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?
I use OpenBSD ksh as login shell on all my machines except the gaming pc, haven’t seen any issues
And why are u using openbsd ksh instead bash?
Because I don’t like bash
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
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.
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
I could imagine an it would matter more to people working with embedded devices.
Also some people just like learning or doing random things. Nothing wrong with some exploration, discovery or learning.
That’s why I’m asking that question :) A lot of discussions are on Reddit and I hate Reddit so to avoid using it I’m asking here.
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.
You do not want to use dash interactively! It is created solely for scripting and not for creature comfort. This means all the stuff you’re probably used to such as line editing and command history will not be available.
At some point, you’d want to ask yourself how heavy is “heavy” and how much stuff are you willing to shed? Do you not need tools such as web browser, media player, or office suite? Are you willing to get rid of desktop environment?
In the extreme, you can remove all the documentations, all the manpages to save space. You can even remove all the localization files, without which stuff would look weird, but would still run.
Further than that, you can even customize your kernel, opting out all the drivers you don’t need, or even some that you could use (e.g. wifi, audio, hardware monitoring). Next, some kernel features that are less essential such as statistics, logging, and debugging, as well as the handling for some network protocols. If you wanna go crazy, you can enable the expert/embedded options and with that you can disable stuff that can be critical (e.g. error reporting, certain IPC feature).
It’s a rabbit hole, really.
Web browser are the type of software which I hate the most. They’re main reason why a lot of personal computers aren’t usable anymore. Also browsing web through terminal is impossible, that’s another point for me to hate them 🤣 Of course I’m forced to use them but when I can I’m choosing alternatives like Gemini or Gopher and native apps. If I could I will not leaving terminal but as I need it for few GUI apps I’m using DWM 😊 I’m planning also to learn how to compile my own kernel.
It’s not about disk space but learning, minimalism (which I love), better security and efficient resource usage.
I don’t care how many resources is used by program but how efficient. People are telling me that they see in their resource monitors that they systems are using a lot of RAM, mainly gamers who have 64 GB of ram and complain about 20 GB in usage by Windows. But this why they have RAM, to use it! If they don’t need it system should allocate RAM in proper way to make computer faster. Of course Windows is not good example of efficient resource allocating 😂 but I want to make my point more clear. It’s not about removing critical features to just make it run, but making my system suited for my needs and efficient as much it’s possible. So removing man pages is not related to my case as I’m using them :)
I like to tinker and I’m learning about computers that way. I ask questions and looking for methods to optimize every part of my systems. They don’t have to be the best optimized and if will not have that many time as I have to learn I wouldn’t worry too much about it and just work on computer. I’m just aware that always we can do something better.
Can I entertain you with some minimalistic distros? Alpine is the first thing that comes to mind.
It uses busybox which is some kind of minimalistic all-in-one program that includes everything you need to run an OS such as init system and core utilities. And yes, you guessed it, it includes a shell that is a stripped down version of bash. Even the libc is stripped down here, with musl instead of glibc.
Speaking of busybox and musl, there’s also another distro that centers around compiling tiny embedded rootfs image. With this you can configure what (not) to include in the kernel. You can also do the same with busybox, where you can choose to include or exclude utilities.
But honestly, to have something lean while being able to keep up with modern computing, I’d choose Gentoo where you can choose what (not) to put in your programs at compile time.
I had contact with Alpine on one server. It’s great OS but I don’t think it’s great choice not for desktop. I’m using Gentoo and it gives me much more capabilities ;) Gentoo can’t work with busybox as GNU coreutils are hard dependency. musl is supported by Gentoo but as I heard there’s a lot of issues with it
I guess it’s just that musl and busybox are not fit for desktop use cases
yeah, they’re better for embedded devices
Btw, Gentoo.
How did you know… 😉
Yeah, I’m using Gentoo 😅
I don’t have any answers, just my own experiences. Last year I decided to use Alpine Linux as my Operating System for a couple of self-hosted things running on a Raspberry Pi. I chose it because it’s super minimal and used less common tools (for example
doasinstead ofsudo). That unintentionally forced me to learn how to use Linux using more basic commands that are more likely to be available on other Linux systems.Alpine Linux uses Busybox-Ash which is a POSIX compliant shell that’s very small and very basic. The scripts I ended up writing tend to be POSIX portable meaning that they should work on a wider variety of systems. That comes at the cost of script simplicity and readability as well as missing out on many features that make Bash scripts more complex, robust and easier to work with.
I have a working example POSIX portable script. I’ve been adding to it all the things I’ve learned. You can check it out here if you’re interested.
I use Alpine Linux with Sway as my daily driver but still keep a copy of Linux Mint DE ready to use because it’s nice to have a fully featured work environment for the days I don’t want to think.
Thank you for sharing with your experience! Alpine Linux as daily driver… that’s interesting. How is it in daily usage as desktop OS?
It’s been a learning experience. I am pretty much building it specifically for my use so it’s missing lots of stuff that’s standard on other fully featured OS’s. I’m mostly using a browser, Konsole terminal and KDE Kate as my editor.
I found an unexpected hobby in writing POSIX scripts because it’s teaching me the inner workings of Linux. In the future I’d like to expand that to including the
sedandawkcommands but I haven’t really found a project to use them with yet.Alpine Linux does offer a
setup-desktopcommand/script which will easily setup a few desktop environments such as Gnome, Plasma, Xfce, Mate, Sway and Lxqt. That only sets up the basic desktop environment so a lot of other work is needed to set up things like sound, graphics and a few other things.As I mentioned before, I still have Linux Mint DE installed. I mostly use it for Steam games but it has everything else I need for when I don’t feel like working out a problem because I wanted to simply open a .pdf file. However, it’s still really satisfying for me setting up a very specific work environment with the mininal tools I have available.
I think there is value in learning to work within a mininal environment to help give more life out of lower spec technology that’s currently available. Especially now with all the ram supply issues because of the AI rush.
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 :)
Ignoring the interactive features (or lack thereof) in dash/ksh, removing bash is not really something that’s possible on most distros (excluding Alpine and possibly Debian) since it’s used in scripts everywhere. And if you need to have bash installed anyways, why opt for the less pleasant shell in daily usage?
I don’t want to remove bash as my operating system is using it as hard dependency, I was considering using different one. I agree with you at point - installing another shell if all what I need is bash makes my system more bloated.
I do write my scripts in POSIX sh, more for compatibility sake. But shells like dash, mksh, are not made for interactive use, they lack most not-really-convenience features.
But heavy, that’s only invocation time; it mathers more if you do things like 100 awk calls (that one is heavy to invoke) per line you parse.Though i did write my own cross-shell session scripts, centering on the ENV variable which most shells understand (and a /etc/bash/bashrc loading it, since Bash doesn’t).
Again, more because i think, why load xkb maps 3 times in 3 scripts if you can do it only once? And most session scripts look like they were never touched the last 20 years. And then a if you do it, do it right mindset.Worth learning; i think so. You learn, with time, more about how to use shorthands and functions, to structure your scripts nicely, instead of doing if if if messes more “convenient” shells lead you to. Which benefits you in real programming languages too and leads to more readable and better maintainable scripts.
And the only times i miss convenience features like arrays is in 500+ loc scripts which would have better been done in python. Btw, don’t do 500+ loc shell scripts: they do become a maintenance mess even if you do everything right.Edit: right, i forgot the POSIXLY_CORRECT env variable. Some AUR setup-scripts have issues with a forced POSIX shell.
I agree with the idea of debloating and hardening your systems.
It helps to have some context as the approach I would take depends on what kind of system I’m running. I think its also good to identify your priorities to hone your approach.
When I want stability, fast security updates, minimal install size, I usually use Alpine which indeed uses the lighter busybox bin/sh instead of bash.
When it comes to my workstation shell I’m more focused on utility than size. So bash or zsh or fish, or whatever you find the most useful, makes sense to use.
Dash really sucks. Use it as an interpreter for /bin/sh and thats it
Alacrity or dieSee comment below.
What? 🤔 Alacritty is terminal.
And again, see comment below 😂
Where speaking about shells, not terminals.
My bad, I apologize, and thanks for clarifying. I think my brain automatically changed shell for terminal, and I could have sworn your reply had a question mark after ‘terminal’. Gotta stop replying here when I’m almost asleep.
For shell, I always end up switching to Zsh, mainly because of the extensive and easy customization.







