minimize use of root account

Polytropon freebsd at
Mon Feb 22 02:27:12 UTC 2016

On Mon, 22 Feb 2016 13:07:28 +1100, Yudi V wrote:
> Thanks Polytropon.
> based on the answers here looks like the best answer is to use SUDO or

A good idea. You need to see if you prefer sudo or super.
Both have their individual strengths, but sudo is probably
the one you'll find more often.

> > ###############
> > > #!/bin/csh -f
> >
> > Why?!
> >
> > There's a relevant article: "Csh Programming Considered Harmful" written
> > by Tom Christiansen.
> >
> >
> >
> > I have written one (!) csh script and I still regret it, maybe because
> > it still works. :-)
> >
> > On FreeBSD, the default shell script interpreter is /bin/sh.
> >
> >
> I am fairly new to Freebsd and I checked the shell variable before I wrote
> the script and as it said CSH, I just went with the csh script.

The C shell is the default interactive shell (dialog shell), while
/bin/sh is the default non-interactive shell (script shell), which
you can see as most system scripts start with "#!/bin/sh". It tends
to be more readable and portable than the C shell (which isn't even
the best imaginable interactive shell, as many users seem to prefer
bash or zsh which can easily be installed on FreeBSD).

> I did not
> get why the user shell is /bin/sh and the root is /bin/csh.

For all users (including root) /bin/csh is the default dialog shell.
It's easy to set a different shell using the "chsh" command. The
shell to use must be listed in /etc/shells.

The more simple /bin/sh is used as dialog shell only in single user
mode (maintenance mode) by default.

> This is on a personal backup server and only has few scripts. I dont want
> to readup on yet another shell scripting (someone in the forum mentioned
> that /bin/sh is Almquist's Shell NOT bash).

That is correct - it's "ash" (Almquist's Shell), which is a close
re-implementation of the traditional Bourne Shell; bash is the
Bourne Again Shell (common in Linux) which can be seen as a
superset of the Bourne shell. So bash usually executes sh code,
and sh code tends to be the most reliable and portable.

> I am just happy if they work as intended. If the server was
> meant for anything else I will definitely not use csh scripts.

As I said, I'm guilty myself of writing one csh script which is
still in use and still works, even though is so full of bullshit
it should go into /dev/null. ;-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list