I am running an Ubuntu distro where
/bin/sh is a symlink to
/bin/dash. While this is OK for most of my users, one of them must have
bin/sh "symlinked" to
Is that possible? I am not sure how to do this.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
[…] one of them must have
I suspect that the actual state of affairs is:
[…] one of them has some badly written shell scripts with Bashisms in, and doesn't want to fix xyr bad scripts.
You cannot do a per-user symbolic link, obviously. So get your user to get those Bashisms out of any shell script that uses
/bin/sh as its interpreter, and to put
/bin/bash (or the alternatives mentioned by piernov) in any shell scripts where the Bourne Again shell really is supposed to be the script interpreter.
These scripts, if they assume that
sh is only ever the Bourne Again shell or if they rely upon Bashisms and don't in fact invoke the Bourne Again shell as
bash (Even invoking it as
sh is wrong if one wants some of a fair number number of Bashisms.), are broken and should be mended.
/bin/sh is just a Bourne shell. Both dash and bash can act as sh-compatible shells, and since original Bourne shell isn't used anymore, sh is often a symlink to bash or dash (mainly on Ubuntu), or even zsh.
When using sh though, you shouldn't be using any specificity of a particular shell. That's why a script with a
#!/bin/sh shebang shouldn't rely on any bashism for example. When it is using any particularity of bash, it should be using
#!/usr/bin/env bash. That is for a shell used to run scripts.
Another aspect of shell is the command prompt used by an user. Most of the time it is defined in
/etc/passwd, and the choice is at the discretion of the distribution you're using. If the default is to use dash, you can obviously change the line in
/etc/passwd for a specific user and put
Finally, even if it's not a good idea, if you really want the
sh command to run
bash, if it's in a shell you should be able to
alias it, or create a symlink to it in another directory (
~/bin for example) then prepend it to the PATH (