View Full Version : Which shell do you use?
Citsakots
December 6th, 2008, 06:15
I'm planning on switching the shell I'm currently using(tcsh) to Bash but I've read that changing the root shell to bash might be a bad idea. The main problem I have is tcsh doesn't update the directory list automatically, so that's why I'm wondering which shell do you guys use?
cajunman4life
December 6th, 2008, 06:21
Do not, DO not, DO NOT change root's shell.
Your comments lead me to believe that you are doing everything on your system as root. This is also a bad idea.
Create a user account for yourself, and select any shell you want. Give yourself SU and/or sudo access so you can still maintain the system. But try to do as little as root as possible.
That said, I use bash and ksh93 about half/half.
Citsakots
December 6th, 2008, 06:28
Do not, DO not, DO NOT change root's shell.
Your comments lead me to believe that you are doing everything on your system as root. This is also a bad idea.
Create a user account for yourself, and select any shell you want. Give yourself SU and/or sudo access so you can still maintain the system. But try to do as little as root as possible.
That said, I use bash and ksh93 about half/half.
Haha don't worry I have my own user account in the wheel group so that's nothing to worry about. Also I have my user account shell as bash and my root account shell to tcsh. I've read, which makes perfect sense, that you shouldn't change your root shell because once an update occurs, the libraries change and that you won't be able to go to root because the installed shell won't work till update. So in the end your shell won't work in root and it causes a lot of problems. I just wanted to know the reason why and such :).
Mel_Flynn
December 6th, 2008, 06:50
make -C /usr/ports/shells/bash -D WITH_STATIC_BASH -DWITHOUT_NLS PREFIX=/ install
Library problem and "no mounted /usr" problem solved. The rest is paranoia. It's easy to change the shell back to csh for problem reporting if you suspect the shell to play a roll with your bug.
su(1) has quite a few advantages over sudo as shell/command wrapper, especially in machine stress situations and because sudo tries to be too smart about your environment variables.
Of course, the conservative "feed the newbies babyfood" answer is to not change root shell.
Djn
December 6th, 2008, 06:55
I've just gotten used to tcsh. The history completion (type the first letters, arrow up) is more pleasant than ^R in bash, the config syntax makes more sense, and I do anything complicated in script files anyway.
Besides, it's one less thing I need to install. :)
The rehash thing is slightly annoying, granted - I'm thinking about just setting it to run whenever tcsh displays a new prompt. (The overhead is so small these days that running it each time I press enter in a shell really doesn't worry me).
gnemmi
December 6th, 2008, 07:06
csh for every user on my system ..
See ... csh is the default root shell .. so why shouldn't I use it as the default shell for my system users as well??
After a while, users get used to use csh and switching back and forth between a regular users and root makes it even easyer for newcomers .. after all thye've all been using csh for moment one on a daily basic .. so .. there's no real need to go switching from shell to shell according to suit a particular user's need.
Even so .. if a particular user feels unconfy with csh... well... that woud make him a minority .. and minorities (as well as exceptions), constitut no base upong wich general rules should be created.
Scripting is still confined to sh thouhg ...or Perl :D
Yet still ... users are free to change their shell to something else that better suit their needs at the drop of a hat. I ain't forcing anyone to use csh after all...
My two cents.
PS: I'm willing to pay a reasonable price for this two books, since they are downright impossible to get around here: Unix C Shell Field Guide (Paperback) (http://www.amazon.com/Unix-C-Shell-Field-Guide/dp/013937468X/ref=sr_1_5?ie=UTF8&s=books&qid=1228542368&sr=8-5) and C Shell Quick Reference Guide (Paperback) (http://www.amazon.com/C-Shell-Quick-Reference-Guide/dp/0935739238/ref=sr_1_7?ie=UTF8&s=books&qid=1228542368&sr=8-7). No matter what state their are in ... I just can't get them over here. So if you happen to have a spare copy, please let me know and we will work someting out.
Thanks
Best Regards
Gonzalo
PS: wouldn't it be a good idea to setup a "sell/buy subforum"?? .. just a thought ...i mean .. what's nothing to some ... means a lot to others around the globe ...
Regards
Citsakots
December 6th, 2008, 07:15
make -C /usr/ports/shells/bash -D WITH_STATIC_BASH -DWITHOUT_NLS PREFIX=/ install
Library problem and "no mounted /usr" problem solved. The rest is paranoia. It's easy to change the shell back to csh for problem reporting if you suspect the shell to play a roll with your bug.
su(1) has quite a few advantages over sudo as shell/command wrapper, especially in machine stress situations and because sudo tries to be too smart about your environment variables.
Of course, the conservative "feed the newbies babyfood" answer is to not change root shell.
Wow, thank you for such a great post. I didn't know you could do that and also thank you for not feeding me "baby food".
Mel_Flynn
December 6th, 2008, 07:47
csh for every user on my system ..
See ... csh is the default root shell .. so why shouldn't I use it as the default shell for my system users as well??
Cause the default shell for users is sh? csh is BSD historical for root, I don't think there are any valid technical reasons other then "importing a new root shell or switching to sh gives too many noise on mailing lists", but I'll gladly be corrected on this topic.
It's quiet inconvenient to install software on a vanilla machine using csh, cause you have to rehash all the time. Of course I never spent time investigating csh, so I might be missing a shell feature to set auto rehash.
gnemmi
December 6th, 2008, 08:54
Yes ..I considered "rehash" briefly ... but .. root has to rehash all the time .. so .. why not getting newcomer to get used to the habit of rehashing?
After all .. newcomers are "someday will be root" or will have to work as root eventually .. son why not getting them accuaitend with rehash from moment one??
By the time they get to be root "rehash" wil be second nature to them ...
Learning to do a rehash after years of not using it ... is quite annoying .. so why not avoiding that from the ground up???
That's the way I see it (and I'm far from having an absolute truth on this matter or any onther ...) it's the best way to go.
I mean .. If you're going to do something ... why not leraning it the right way from the very beginning??
On a side note .. rehash is not only a good habit .. but also a good practice that let's you know more about some of the most simpler internals of you OS of choice :)
Mel@:It's quiet inconvenient to install software on a vanilla machine using csh, cause you have to rehash all the time. Of course I never spent time investigating csh, so I might be missing a shell feature to set auto rehash.
Yes ... and I probably falll in the same cateory too ... we need books on Csh ... that was why I was asking for Unix C Shell Field Guide (Paperback) and C Shell Quick Reference Guide (Paperback) :(
But i've got the feeling that, even if you don't like it _that_ much or are still not quite convinced.. you do know where I'm aiming at :)
Now, and back to the books .. it would really be a good thing to have them both at hand...
vermaden
December 6th, 2008, 09:05
My choices are:
#! /bin/sh for scripting
ZSH for interactive use
CSH for root account (also often the first thing I type on the root prompt is 'zsh' if its avialable)
sverreh
December 6th, 2008, 11:19
I use tcsh (and sometimes sh) on the command line. The "rehash problem" is really not a problem for me. It takes about 0.2 seconds to type and execute the command, and I usually don't install very many programs every day. So in an average week I think I loose about 1 second because of "rehash" ;)
Scripting is still confined to sh thouhg ...or Perl :D
Absolutely! Although I tend to use Perl more than sh. :D
graudeejs
December 6th, 2008, 12:43
i use mksh, because it's sh compatible.
for some reason I didn't like ksh93
danger@
December 6th, 2008, 12:51
you can use su -m ...
MartijnAtLico
December 6th, 2008, 13:18
I use zsh.. currently I only use about 5% of it's functionality, but someday I'm going to do great things with it :)
http://friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need/
Dr_Phoenix
December 6th, 2008, 13:56
Using csh. When running and testing some scripts switching from csh to sh or bash if needed but more simple to add at the start of script file signature like #!/bin/sh #!/usr/bin/perl etc.
estrabd
December 6th, 2008, 18:58
bash, though I try to write my shell scripts so that they're compatible with the original bourne shell.
estrabd
December 6th, 2008, 18:59
I use tcsh (and sometimes sh) on the command line. The "rehash problem" is really not a problem for me. It takes about 0.2 seconds to type and execute the command, and I usually don't install very many programs every day. So in an average week I think I loose about 1 second because of "rehash" ;)
Absolutely! Although I tend to use Perl more than sh. :D
I love me some Perl, but *many* things are still done more appropriately as a shell script.
sverreh
December 6th, 2008, 20:43
I love me some Perl, but *many* things are still done more appropriately as a shell script.
When it comes to system administration, I agree totally. However, I am not a sysadm (except for the desktop at home), and many of my scripts at work rely heavily on regexp. And there Perl really shines. :e
UNIXgod
December 6th, 2008, 23:22
My choices are:
#! /bin/sh for scripting
ZSH for interactive use
CSH for root account (also often the first thing I type on the root prompt is 'zsh' if its avialable)
+1 but I never change my shell under root. even if it's avalable. Even the zsh guys don't suggest it for root.
I can't begin to explain the problems that could occure if the root shell is changed.
anomie
December 6th, 2008, 23:48
I'm planning on switching the shell I'm currently using(tcsh) to Bash but I've read that changing the root shell to bash might be a bad idea.
I'll agree with other sentiments on the thread. Leave root's shell alone. If you want a root (for functional purposes) account with a special shell, then set up the toor user.
Two easy steps:
# chpass -s /usr/local/bin/bash toor
# passwd toor
Voila. Use su - toor from a regular user account.
The main problem I have is tcsh doesn't update the directory list automatically, so that's why I'm wondering which shell do you guys use?
I use tcsh for interactive shells (even on a Linux workstation), and sh for scripting everywhere (FreeBSD, Linux, Solaris).
Eponasoft
December 7th, 2008, 00:15
Good ole /bin/sh for me. :)
Oko
December 7th, 2008, 03:05
$ echo $SHELL
/bin/ksh
$
ninjaslim
December 7th, 2008, 06:39
I generally use ZSH for everything. No, I have not changed the root shell. I just use sudo, which preserves env vars.
Pushrod
December 7th, 2008, 08:46
Do not, DO not, DO NOT change root's shell.
I changed my root's shell to zsh sometime in 2005 and have not had a single problem. zsh is installed in /bin on my machine, and all of the libs are outside of /usr, so basically, I have zsh in the base system. It works great and I would recommend it to anyone who is willing to take the couple of careful steps needed. I have this same setup on four different computers; three are FreeBSD and one is CentOS Linux (sigh).
I personally don't like [t]csh because it uses a different language than sh. It does not make sense to me to switch back and forth, and I don't feel the need to learn csh scripting.
lyuts
December 7th, 2008, 10:32
I'm using tcsh and have no problems with scripting.
CyberCr33p
December 7th, 2008, 10:58
For root I use csh and for users bash.
SirDice
December 7th, 2008, 11:42
Tcsh for all my accounts, the standard bourne sh for scripting and if things get complicated perl.
dap
December 7th, 2008, 12:44
I use tcsh because I like the programmable completion and the completion.
For scripting I use sh and Python.
tomh009
December 7th, 2008, 18:12
Hmm, not many ksh users out there, it seems. After spending my early years with csh and tcsh, I switched about 20 years ago to ksh, as I could have the same shell on Windows (with MKS Toolkit), and I haven't switched since.
I use pdksh, as none of the ksh93 features seem compelling to me, and I figure that for sure I'd have to relearn something. :)
The big thing that I love about ksh in general is "set -o vi" which lets me use the navigation keys that are ingrained in body ... navigation without having to think about it, and without having to locate the cursor keys on the keyboard. And note that it also supports "set -o emacs" so there is no need to have a religious discussion about vi vs emacs! :e
cajunman4life
December 7th, 2008, 19:38
The big thing that I love about ksh in general is "set -o vi" which lets me use the navigation keys that are ingrained in body ...
I can't tell you how many MSWord documents that have :w or :wq embedded randomly within... it's tough to break.
tomh009
December 7th, 2008, 21:13
I recognize those random letters from my documents, too! That's why I try to have as many common tools across platforms as possible, and ksh and vi are an easy choice for that.
nakal
December 8th, 2008, 00:31
I'm using tcsh, because the history function is very convenient. I just type a short prefix (mostly one letter) and press "cursor up". It finds the last matching line.
Scripting shell is sh for me.
bsddaemon
December 8th, 2008, 12:17
Bourne shell, for scripting, of course, and zsh, for interactive use. The auto-complete feature in zsh is just amazing. I can even auto complete remote file/dir when I scp with private key, kernel config file when I build, install kernel...
I wish I could do in-line scripting (scripting with command line in interactive mode) with zsh. There are some differences syntaxes, builtin commands in Bourne and zsh.
Is there any setting that I can enable the "bourne shell compability", if it does exist?
vermaden
December 8th, 2008, 13:44
I wish I could do in-line scripting (scripting with command line in interactive mode) with zsh. There are some differences syntaxes, builtin commands in Bourne and zsh.
Any examples?
nORKy
December 8th, 2008, 14:01
scripts : sh
users : zsh
root: csh
bsddaemon
December 8th, 2008, 14:20
Any examples?
I was having problem with in-line command cp (with variable), printf (zsh has it own printf?), complex while or if statement. There are some more but I couldnt remember on top of my head. They work in bourne script file, but didnt work with zsh
afaik, zsh is more bash-like, rather than sh
jleal2003
December 9th, 2008, 02:34
My choices are:
#! /bin/sh for scripting
BASH for root account (
bsddaemon
December 9th, 2008, 02:50
bash for root??? Poor Charlie...
and there is no normal account, you log in as root all the time???
lazybones
December 9th, 2008, 03:46
The big thing that I love about ksh in general is "set -o vi" which lets me use the navigation keys that are ingrained in body ... navigation without having to think about it, and without having to locate the cursor keys on the keyboard. And note that it also supports "set -o emacs" so there is no need to have a religious discussion about vi vs emacs! :e
Another pdksh user here! The pdksh maintainer was a sysadmin at my school when I was there - they had it deployed for all user accounts campus-wide and it's been my shell of choice for 15 years now. I'm married to the vi commandline editing - in any other shell I'm driving people nuts with beeps when I fire off "[esc]kkk"
Ole
December 9th, 2008, 07:01
Wow, thank you for such a great post. I didn't know you could do that and also thank you for not feeding me "baby food".
With portupgrade you can automatize that by:
MAKE_ARGS in pkgtools.conf:
'shells/bash' => [
'WITH_INCLUDED_FAQ=yes',
'WITH_STATIC_BASH=yes',
'WITH_INTEGRATED_HELPFILES=yes',
],
AFTERINSTALL in pkgtools.conf:
'shells/bash' => sprintf(
'/root/bin/ports/bash.sh'
),
and create&chmod +x /root/bin/ports/bash.sh with similar content:
#!/bin/sh
cp /usr/local/bin/bash /bin/bash
cp /etc/shells /tmp
grep -iv "bash" /tmp/shells > /etc/shells
echo "/bin/bash" >> /etc/shells
(not cleanly scripts but it working ;). For example it remove records /usr/local/bin/bash for exclude of wrong-headed choice user shell in "adduser"
After that, portinstall and portupgrade shells/bash will be compile static bash, place him to /bin and correct /etc/shells file
sverreh
December 9th, 2008, 07:41
I'm married to the vi commandline editing - in any other shell I'm driving people nuts with beeps when I fire off "[esc]kkk"
I'm also "married to the vi commandline editing" as you say! :e
But I am using tcsh, which has the same feature. Just put
bindkey -v
in .cshrc (or .tcshrc if you like)
bsddaemon
December 9th, 2008, 16:20
Any examples?
Another one:
func () {
VARS="a 1 b 2 c 3"
for var1 var2 in $VARS; do
echo $var1 $var2
done
}
This function works fine with zsh, but doesnt work with Bourne
Syntax error: word unexpected
In my script, I have no choice but to define shebang as #!/usr/bin/env zsh :S
Maybe someone has better solution?
vermaden
December 10th, 2008, 09:04
I wish I could do in-line scripting (scripting with command line in interactive mode) with zsh. There are some differences syntaxes, builtin commands in Bourne and zsh.
Is there any setting that I can enable the "bourne shell compability", if it does exist?
(...)
Another one:
func () {
VARS="a 1 b 2 c 3"
for var1 var2 in $VARS; do
echo $var1 $var2
done
}
This function works fine with zsh, but doesnt work with Bourne
In my script, I have no choice but to define shebang as #!/usr/bin/env zsh :S
Maybe someone has better solution?
From man sh:
The syntax of the for command is:
for variable [in word ...]
do list
done
This is the syntax of POSIX sh, so there is nothing strange that extended ZSH capabilities (for A S D in ...) does not work on standart sh, ZSH IS compatible with POSIX sh, I just do not know why you want POSIX sh to be compatible with ZSH extensions.
Other example of that is that for loop that only works at ZSH:
$ for I in {1..10}; do echo $I; done
UNIXgod
December 10th, 2008, 23:26
Hmm, not many ksh users out there, it seems. After spending my early years with csh and tcsh, I switched about 20 years ago to ksh, as I could have the same shell on Windows (with MKS Toolkit), and I haven't switched since.
I use pdksh, as none of the ksh93 features seem compelling to me, and I figure that for sure I'd have to relearn something. :)
The big thing that I love about ksh in general is "set -o vi" which lets me use the navigation keys that are ingrained in body ... navigation without having to think about it, and without having to locate the cursor keys on the keyboard. And note that it also supports "set -o emacs" so there is no need to have a religious discussion about vi vs emacs! :e
What do you think of zsh?
dclau
December 14th, 2008, 09:36
user(s): ksh
root: csh
scripts: sh
hydra
December 16th, 2008, 17:38
I am using tcsh, was thinking about trying out zsh.
rdivacky@
December 16th, 2008, 23:26
while I agree that tcsh is a messy old warty piece of sh... shining ;) I am still using it. I guess it's my .cshrc that makes it so appealing to me but I am to lazy to switch
lme@
December 21st, 2008, 14:09
with shells/tcshrc tcsh is a very nice piece of software! I just love its programmable completion! :)
tangram
January 8th, 2009, 17:28
For root I use tcsh and zsh for regular user in FreeBSD. On Linux land I mainly use bash.
I actually like tcsh quite a bit but I'm looking into zsh (building .zshrc).
estrabd
January 8th, 2009, 17:44
csh for root, bourne or bash as user; for scripting, I bound myself to the limits of bourne.
darkshadow
June 14th, 2010, 18:43
I love zsh , and it is great take a look http://zsh.sourceforge.net/Doc/Release/Introduction.html
nekoexmachina
June 14th, 2010, 18:54
i use zsh too, but may be i'll switch to csh for interactive shell if i'll find time to configure it as my zsh.
fronclynne
June 14th, 2010, 19:56
tcsh because I'm lazy. I don't use very many features but I'm used to the completion paradigm of tcsh on freebsd, and I have no good reason to change, since it's in /bin.
I usually install zsh and pdksh (& sometimes mksh) and every once in a great while I'll change my ol' user account over to one, but I go back to tcsh after a couple of days.
ah7013
June 14th, 2010, 23:08
bash for me because I come from a Linux background and all the Linux distros I have tried used bash so i'm just used to it.
ckester
June 14th, 2010, 23:57
I've been using mksh since seeing killasmurf recommend it in another thread.
Reasons: size, speed, absence of GNUish cruft. Ability to redirect stderr. Enhanced pattern matching in variable substitutions. Reasonable license!
hedwards
June 15th, 2010, 01:38
For my main user account, I've switched from tcsh to bash on account of all the scary things I was reading about the c shells. The main one being that other shells have the ability to evaluate what a command is going to expand to without actually executing it.
But, as for root, I'll leave it as is forever. If, however, one is going to change it then for God's sake keep it as one of the ones which is shipped as a part of the base system. Having had the experience earlier today where I couldn't log in as myself because I hadn't finished the dependencies for bash I'd highly recommend against using ports for root's shell.
I do however dislike the way that bash handles the history. It's always irritated me that you can't type in a few characters of the command and skip to just the commands you've entered that start with those characters.
DutchDaemon
June 15th, 2010, 12:34
I've been using mksh since seeing killasmurf recommend it in another thread.
Reasons: size, speed, absence of GNUish cruft. Ability to redirect stderr. Enhanced pattern matching in variable substitutions. Reasonable license!
I've switched to mksh from bash as well. Less clutter, better speed, and with the included mkshrc sample it can be made to look like bash with minor tweaks. And NO dependencies whatsoever!
ckester
June 15th, 2010, 16:56
I didn't know about that mkshrc sample, Dutch. Thanks for pointing it out. Something to play with today!
The .profile I'd been using with bash seems to be working just as well with mksh, without needing any edits. What I liked in bash is apparently just the stuff they borrowed from Korn shell, and not any of their own "innovations". ;)
olav
June 15th, 2010, 17:40
Im using bash mostly, but after reading this thread I have to check out mksh :)
graudeejs
June 15th, 2010, 18:30
sh vs bash vs mksh (http://forums.freebsd.org/showthread.php?t=12768)
hedwards
June 16th, 2010, 02:10
sh vs bash vs mksh (http://forums.freebsd.org/showthread.php?t=12768)
Those results aren't terribly surprising. The clone of the Bourne Shell FreeBSD uses ought to be quite a bit quicker as it doesn't incorporate as much cruft as bash does.
carlton_draught
June 16th, 2010, 04:35
I used sh for root, and bash for users. In root, I always switch straight to bash for interactive use. Scripts are done in sh when I have a choice. However, I will have a look at some of the more popular options after reviewing this thread.
graudeejs
June 16th, 2010, 06:45
Those results aren't terribly surprising. The clone of the Bourne Shell FreeBSD uses ought to be quite a bit quicker as it doesn't incorporate as much cruft as bash does.
So what cool stuff do you do with bash, that other shells can't do?
http://en.wikipedia.org/wiki/Comparison_of_computer_shells
lme@
June 17th, 2010, 07:45
Now that our beloved Bourne Shell got support for filename completion, we can all switch to it! :)
See http://svn.freebsd.org/viewvc/base?view=revision&revision=209221
BrainDamage
June 17th, 2010, 13:16
zsh for interactive use
csh as default for root account, but normally I switch over and use the zsh
mirabilos
June 17th, 2010, 18:14
Now that our beloved Bourne Shell got support for filename completion, we can all switch to it! :)
It’s actually an almost-POSIX shell, not(!) a Bourne shell,
with broken behaviour for "sh -c 'somescript' -- foo bar baz"
which mksh can emulate when compiled with a specific option,
-DMKSH_MIDNIGHTBSD01ASH_COMPAT, and then when either called
with “-o sh” or as sh when compiled with -DMKSH_BINSHREDUCED.
I’d say ditch it. MidnightBSD is doing so, and they like mksh.
fairy
June 18th, 2010, 02:10
sh vs bash vs mksh (http://forums.freebsd.org/showthread.php?t=12768)You could have included zsh. It's usually faster than bash and has better sh emulation.
Anyway, shell scripts are easy to rewrite for bash/zsh/whatever so that they're faster than on /bin/sh. You'll see real performance when you reduce external commands to minimum.
loop
June 18th, 2010, 03:26
csh for root, zsh for user.
I've been using zsh for years ... mostly for it's completion abilities (I'm a lazy typist :). Started using it well before any of the other shells featured built-in completion, and haven't bothered to change
ckester
June 18th, 2010, 04:38
It looks like those of us who are looking for something other than bash are about evenly divided between mksh and zsh. Perhaps we need to do a head-to-head comparison between these two. What benchmarks do you suggest?
sk8harddiefast
June 18th, 2010, 09:46
Hi. I use bash but i want to use mksh but i didn't find none .mkshrc sample googling. Even on mirbsd site.
Is anyone how can post one or give me a url with a sample?
DutchDaemon
June 18th, 2010, 15:45
Ports install examples under /usr/local/share/examples/.
sk8harddiefast
June 18th, 2010, 16:02
This was the path i was searching for. I found it and i copy it on my home directory.
I set alias ls='ls -G' and i have colorised terminal :)
But how can i colorise my hostname too?
I don't understand nothing on this file :P
graudeejs
June 18th, 2010, 17:24
I've read man mksh.
As I understand, you can't colorize it (without some trick, which have side effects)
At least I can post small replies
DutchDaemon
June 18th, 2010, 18:05
The default (included) .mkshrc colorizes with ls -G
No additional settings have been made.
Just tried without any .mkshrc .. still colorizes.
sk8harddiefast
June 19th, 2010, 01:10
Just tried without any .mkshrc .. still colorizes.
On me default is not ls -G. Is ls -F.
No. Without any .mkshrc on my home directory all colours are white :(
Also without any .mkshrc is not giving me hostname before $
I open mksh from bash. This is possible to make the difference?
mirabilos
June 19th, 2010, 19:41
When you copy the dot.mkshrc sample file (ugh, the FreeBSD porters have colourised some
parts of it?) to ~/.mkshrc then mksh will give you the username, hostname and current
working directory before the $ (or #). You can of course write your own, it’s just a
sample ;-)
Colourising that is rather easy and, in mksh (as opposed to, say, pdksh), comes without
side effects. The sample file starts the effective PS1 with ^A^M (i.e. control-a or ASCII
0x01, and control-m or \r or ASCII 0x0D). This enables a “magic mode” first known from
AT&T ksh88 which allows you to wrap your escapes into matching pairs of ^A, like you use
\[ and \] in GNU bash.
Since mksh, by urging from Dave Korn himself, now supports $'…', you can use
│ PS1=$'\1\r\1\e[7m\1$PWD\1\e[0m\1> '
or things like that (this is actually an example line from the manual page, not
a prompt I use, but it works like that too). The prompt from dot.mkshrc is much
more complex, for example it applies the replacing of $HOME with ~ similar to
GNU bash’s \w and, in addition to that, prevents the rest from being wider than
about a third of the display.
Also, you could send me your (GNU bash syntax) prompt per eMail and I’ll convert
it to mksh syntax for you (unless I get a bazillion eMails per day…) – you should
of course state if you want the whole directory (/home/foo/bar), \w (~/bar), or
just the last part, for example.
I will update the online versions of the manpage to match mksh-current right
after submitting here:
• https://www.mirbsd.org/man1/mksh or https://www.mirbsd.org/man/mksh.1
• https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh.pdf
It should be noted that I will *not* be monitoring this web forum, I just
stumbled across this thread (it was pointed out to me). There are support
channels (both IRC and eMail) documented.
sizemj
January 5th, 2011, 22:20
Kind of an opinion question. I was wanting to know what shell most people use. I have come from Linux so Bash is the norm but FreeBSD it is the csh.
thanks
[ merged with existing thread - Mod. ]
graudeejs
January 5th, 2011, 22:28
http://forums.freebsd.org/showthread.php?t=12768
http://forums.freebsd.org/showthread.php?t=11819 (a little related)
UNIXgod
January 5th, 2011, 22:44
Kind of an opinion question. I was wanting to know what shell most people use. I have come from Linux so Bash is the norm but FreeBSD it is the csh.
thanks
err. So because you come from linux you prefer bash? Just because the system has a 'default' shell does not dictate that you have to use it. Also FreeBSD user should default to ash not tcsh.
I use zsh and script in ash.
UNIXgod
January 5th, 2011, 22:53
http://www.freebsd.org/doc/en/books/faq/applications.html#MINIMAL-SH
ckester
January 6th, 2011, 00:31
I've been using shells/mksh ever since I saw killasmurf's recommendation early last year.
sizemj
January 6th, 2011, 15:42
No I have change to the tcsh. I know that sh is the default.
Pushrod
January 6th, 2011, 16:23
I use zsh exclusively and have "tunnel vision" with it. It's root's shell even.
jrm
January 6th, 2011, 19:17
zsh here, for root as well. I've messed things up, but have always been able to fix the mess-ups with the toor account, which uses /bin/sh. Can someone give a scenario where toor couldn't save you?
zsh users who don't like to rehash may want to check out the options nohashdirs and nohashcmds.
UNIXgod
January 6th, 2011, 21:58
haha don't change root shell! lol to zsh even. You guys have way to much time on your hands.
vermaden
January 6th, 2011, 22:44
@UNIXgod
When he has toor account available with /bin/sh shell, then nothing can hurt him, even rm -f /usr/local/bin/zsh ...
UNIXgod
January 6th, 2011, 23:23
@UNIXgod
When he has toor account available with /bin/sh shell, then nothing can hurt him, even rm -f /usr/local/bin/zsh ...
Never really used toor ( reverse root) .... I imagine it's a security risk to some degree to enable it.
I don't like messing to much with root. I guess I never found /bin/csh to be that disabling. It has shell !history and simple tab completions and reminds me that I'm running root with it's prompt. But to each their own.
Pushrod
January 6th, 2011, 23:39
haha don't change root shell! lol to zsh even. You guys have way to much time on your hands.
Yeah, takes a real lowlife to su root and then chsh.
You can consider me the resident BSD badass. I have changed root's shell, don't have separate partitions for /var, /usr, or /tmp, and I have minfree set to 0 on almost all disks.
UNIXgod
January 6th, 2011, 23:54
Yeah, takes a real lowlife to su root and then chsh.
You can consider me the resident BSD badass. I have changed root's shell, don't have separate partitions for /var, /usr, or /tmp, and I have minfree set to 0 on almost all disks.
Wow you rebel. Do you also duel boot your laptop to win98 as well or just run inside vm?
j/k =)
vermaden
January 7th, 2011, 00:56
Never really used toor ( reverse root) .... I imagine it's a security risk to some degree to enable it.
What security risk if both root and toor will have the SAME password?
That is the PURPOSE of toor account, as backup for root, or as a root account with alternative shell.
Blueprint
January 7th, 2011, 01:34
I use ksh93 (interactive + scripting) because I use AIX at work and it is included in the base install. However ksh88 is the default root shell. :(
I haven't heard of mksh either until I saw killersmurfs post but I was hoping he would have included ksh93 in his tests. From what I read ksh93 is meant to be faster then all the other sh compatible shells.
Many people critisize ksh93 for interactive use but I think its really good now with recent versions.
I'm just curious why people would use mksh over ksh93, is it for licensing reasons?
UNIXgod
January 7th, 2011, 01:52
I'm just curious why people would use mksh over ksh93, is it for licensing reasons?
That was the original reason. Korn shell was not F/OSS originally and those who prefered it used pdksh( i.e. public domain ksh).. mksh somehow came from there through openbsd. korn didn't become open source until the end of the 90's. Also bash and zsh have incorporated modern shell feature originally found in the korn shell. zsh was directly influenced.
Blueprint
January 7th, 2011, 02:22
Sorry I probably should have asked if it's "still for licensing reasons?". I am aware of the history, and the reasons we have bash,zsh and pdksh. But since ksh93 has been opensource for a while and since mksh is a relatively new offering. Are people in this thread making the switch to mksh for licensing reasons or do they prefer it over ksh93 for other reasons?
Galactic_Dominator
January 7th, 2011, 05:29
One thing not mentioned with building static libs, is the penalty of using them. It's going to use more memory that way. If you're doing a lot of scripting in a memory contrained enviroment, a static build of bash/zsh/etc is not ideal. That and sh execution is faster despite an earlier claim to contrary. This is why the base system shell of Debian and Ubuntu have switch to the dash shell(Debian Ash) similar to FreeBSD's /bin/sh.
Personally, I use either zsh, or tcsh for an interactive shell and I hate working in bash. One it's more frustrating attributes for me is it's history-search-backward functions as it's not nearly as useful as tcsh's FreeBSD default and to get the same behavior in zsh just add
bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward
There is no identical behavior in bash although you can get close with some fiddling.
tcsh has many nice attributes too that many aren't aware of. For example, set autolist in your .cshrc/.tcshrc gives nice autolisting similar bash or zsh. Many more too, see tcsh. A lot less memory than bash/zsh too although that may not be as important as it once was.
If I'm doing to heavy lifting with shell zsh is a easier IMO, but for me I've probably already resorted to use python. I just don't like typing a thousand lines in sh when I could do in 100 with python plus it's easier to read/maintain/debug.
fat64
January 7th, 2011, 14:01
shells/ksh93 as a user, and /bin/sh as root.
ckester
January 7th, 2011, 19:30
Sorry I probably should have asked if it's "still for licensing reasons?". I am aware of the history, and the reasons we have bash,zsh and pdksh. But since ksh93 has been opensource for a while and since mksh is a relatively new offering. Are people in this thread making the switch to mksh for licensing reasons or do they prefer it over ksh93 for other reasons?
To be honest, I haven't tried ksh93. I suppose I should.
I'd been using bash out of dumb, lazy habit (it's the default on the OS X system I was on before switching to FreeBSD) and was looking for something lighterweight. killasmurf's recommendation of mksh spoke to my need/desire.
But to turn the question back on you, why ksh93 rather than mksh?
rbelk
January 8th, 2011, 04:55
I have never liked Bash, but I have and will use it on Linux systems. I use TCSH for interactive shells and SH for scripts. I did switch to ZSH for a while. Since I try to keep it simple, I use TCSH. TCSH is already installed in the base and I don't have to install ZSH. All I do on a new system is copy my .tcshrc over to the new system and I'm done!
Blueprint
January 8th, 2011, 06:37
But to turn the question back on you, why ksh93 rather than mksh?
Well for me it makes sense to keep my life simple by using a shell that is available on all systems I may need to use in the future. Ksh93 is available on all the propriety unix systems, linux distros and FreeBSD.
ckester
January 8th, 2011, 07:26
I'm retired now, and the only systems I'm likely to use are my own. So portability is less a concern than it used to be. ;)
I did install ksh93 since my last post in this thread. One thing I notice right away is that it's bigger than mksh:
$ ls -l /usr/local/bin/ksh93 /usr/local/bin/mksh
-r-xr-xr-x 1 root wheel 1222248 Jan 7 21:24 /usr/local/bin/ksh93
-r-xr-xr-x 1 root wheel 210560 May 10 2010 /usr/local/bin/mksh
I've also been doing some web searches for benchmarking tests of shell and other scripting languages:
This site (http://theowoll.netau.net/benchmark.html) looks interesting, although I haven't given a close reading yet. Nor have I tried to run its tests myself.
Here (http://www.metacard.com/kshbench.html) are some benchmarking tests specifically for ksh and its workalikes.
Taking a different tack altogether, this one (http://rigaux.org/language-study/scripting-language/) tries to evaluate the suitability of different languages for "script oriented programming".
captobvious
January 8th, 2011, 08:00
zsh for users :)
Daisuke_Aramaki
January 10th, 2011, 06:02
csh for root and ksh for user on my OpenBSD boxes. csh for root and mksh for user on my FreeBSD box.
fossala
January 10th, 2011, 11:35
csh for root and tcsh for user. zsh on linux.
vermaden
January 13th, 2011, 01:11
I just tried the mksh shell, I could use it under one circumstance ... it must support !$, let me explain:
ZSH/CSH/BASH:
# ls /boot
# cd !$
cd /boot
MKSH:
# ls /boot
# cd !$
mksh: cd: /!$ - No such file or directory
Generally !$ meanse LAST argument of previous command, pretty goddamn usefull in interactive mode.
DutchDaemon
January 13th, 2011, 01:44
vermaden, try [alt]+[dot] (this will expand the last argument of the previous command, pasting it at the cursor position). Repeat for browsing previous arguments.
vermaden
January 13th, 2011, 02:14
Thanks for suggestion, but that does not seem to work.
The left [ALT]+[.] does not do anything, the right [ALT]+[.] puts something like 'middle dot' and returns an error after [ENTER]:
# ls /boot
# ls ·
ls: ·: No such file or directory
DutchDaemon
January 13th, 2011, 03:16
Weird ;) Works fine here, with the 'left alt' and the 'right alt (alt gr)'. I use straightforward us-ascii though. Both insert /boot when the previous command was ls /boot. I've seen other methods (or at least mksh feature requests) that seemed to work with something like 'm-.' and/or 'M-.', but I have no idea how these would work.
There's also this in the manual (emacs mode):
man mksh | less +/" Emacs editing mode"
prev-hist-word: [n] ^[., ^[_
The last (nth) word of the previous (on repeated execution, sec-
ond-last, third-last, etc.) command is inserted at the cursor.
Use of this editing command trashes the mark.
I guess I miss the necessary genetic markers to fathom this. But it's clear that the logic to retrieve/reproduce the last argument is definitely in there somewhere.
nekoexmachina
January 13th, 2011, 05:59
Right now - zsh.
Want to migrate my zshrc to cshrc and use it, if it would be functional enough (like, to use minimum of non-base software :))
ckester
January 13th, 2011, 06:06
Weird ;) Works fine here, with the 'left alt' and the 'right alt (alt gr)'.
Works here too, with $TERM=xterm-256color.
But it doesn't work with $TERM=cons25.
vermaden
January 13th, 2011, 09:37
@DutchDaemon
Would You mind sharing Your ~/.mkshrc file? Maybe its a configuration problem on my side.
DutchDaemon
January 13th, 2011, 15:01
@vermaden:
It's basically /usr/local/share/examples/mksh/dot.mkshrc with a very minor alteration to the PS1 line to get a nicer prompt. And my $TERM is 'xterm', by the way.
vermaden
January 13th, 2011, 15:38
I have also tried that, it does not work with [ALT] but with [ESC] for me, seems that I do not have somewhere 'meta sends esc' option enabled.
DutchDaemon
January 13th, 2011, 15:51
Heh ... [ESC] + [.] also works here ;)
The only difference is that I can cycle with [Alt] + [.] [.] [.] [.] etc., but have to use [ESC] + [.] [ESC] + [.] [ESC] + [.]
mirabilos
January 13th, 2011, 18:48
Alt-x as Meta is not supported, DutchDaemon: Meta-. yields ® really. Use Esc+x instead (note foo-bar = hold them together, foo+bar = press them in sequence notation). ^[x means Esc+x just as ^X means Ctrl-X – Ctrl-[ is ESC in ascii(7).
Czesc vermaden, mksh feature requests (and support, I suppose) go via IRC (channel #!/bin/mksh or #ksh on Freenode) or, if must be, mailing lists. (Or Launchpad… if absolutely must be.) IRC is the fastest/best/easiest.
^[. does have a feature request open (in the Debian BTS). I don’t think the specialness of the exclamation mark will find its way into mksh though (it also would break just too many scripts), and the presence of the “wbx hack” (PS1 response beginning with "!" is converted into "r ") is a mistake.
Hi ckester, nice to see ☺ Note that some things are terminal dependent, for example, in wsvt25 (wscons, the BSD equivalent to FreeBSD’s cons25) there’s no difference between Ctrl-CurLeft and just CurLeft, so the shell cannot know that. On others, the keys are simply not known, but you can usually use the bind builtin to configure that yourself.
.oO(In MirBSD, there’s no toor and never has been, and root is usually not usable, doesn’t even have a password or home directory, real men use sudo(8), see http://xkcd.com/838/ ☻)
Blueprint, on some NetBSD mailing list, there’s a discussion about pdksh/mksh/ksh93, and it seems that ksh93 cheats a little to be faster (plus it has a bytecode compiler, but IMO a lot of bloat and inferiour command line editing – YMMV though). I’m okay with Dave Korn, and he’s okay with mksh as long as I try clearly to get people to not confuse it with AT&T ksh. And mksh is by no means new, just its “product placement”. It’s actively developed though (like ksh93).
Off again,
//mirabilos (Mr. mksh)
vermaden
January 14th, 2011, 15:15
@DutchDaemon
Ok, thanks mate ;)
@mirabilos
Ok, goot to know, thanks.
purgatori
January 14th, 2011, 17:04
My choices are:
#! /bin/sh for scripting
ZSH for interactive use
CSH for root account (also often the first thing I type on the root prompt is 'zsh' if its avialable)
This.
chrcol
January 19th, 2011, 21:00
make -C /usr/ports/shells/bash -D WITH_STATIC_BASH -DWITHOUT_NLS PREFIX=/ install
Library problem and "no mounted /usr" problem solved. The rest is paranoia. It's easy to change the shell back to csh for problem reporting if you suspect the shell to play a roll with your bug.
su(1) has quite a few advantages over sudo as shell/command wrapper, especially in machine stress situations and because sudo tries to be too smart about your environment variables.
Of course, the conservative "feed the newbies babyfood" answer is to not change root shell.
also to add further, changing root's shell still allows login with toor on default shell, should a bash problem occur.
chrcol
January 19th, 2011, 21:08
I use zsh.. currently I only use about 5% of it's functionality, but someday I'm going to do great things with it :)
http://friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need/
unfortenatly #1 failed for me on that list of reasons to use it.
my prompt variables fail and act like sh instead of bash.
chrcol
January 19th, 2011, 21:10
+1 but I never change my shell under root. even if it's avalable. Even the zsh guys don't suggest it for root.
I can't begin to explain the problems that could occure if the root shell is changed.
please explain since I have ran root using bash for a numbr of years without noticing problems.
the only problem I know off really is if the bash binary breaks preventing login.
Galactic_Dominator
January 19th, 2011, 21:53
please explain since I have ran root using bash for a numbr of years without noticing problems.
the only problem I know off really is if the bash binary breaks preventing login.
Well since a lot of us work on remote systems off-site, sometimes a long way away, that is a pretty large problem. There are still a ways that binary can break(not all /usr are located on the same disk / is) so given that bash as an interactive shell doesn't hold a lot of advantages over something like tcsh then I guess the standard advice is still good advice. The static binary approach would be less than ideal for memory constrained system running a bunch of bash scripts and if you aren't running a bunch of bash scripts it's really debatable if bash gives you an advantage.
It's more of a "Should you change the root shell" vs "Can I change the root shell" question and that's best answered by the person/group administering the system. If bash gives useful functionality not present in tcsh and you're ok with the risk and hassle then switch.
chrcol
January 19th, 2011, 21:55
I also remotely administer servers.
in over 5 years I think I have had bash break twice, the last time it happened I was aware of toor and it was a non issue as I simply logged into toor, and recompiled bash to fix it.
I have a few issues with the default shell, mainly.
rehash - urrgh
poor command history system
less compatible with most scripts out there.
my prompt variable doesnt work on it.
its down to choice which I am fine with, but am wondering if this changing root shell thing is simply overstated given that there is a recovery account.
Galactic_Dominator
January 19th, 2011, 22:50
I also remotely administer servers.
in over 5 years I think I have had bash break twice, the last time it happened I was aware of toor and it was a non issue as I simply logged into toor, and recompiled bash to fix it.
You must mean you were aware of toor prior to your issue and enabled it. Making toor available to a remote login isn't something that's good practice if that's what you did.
rehash - urrgh
Difficult to respond to. rehash and the frequency required has never caused me a second thought.
poor command history system
I guess that's a per-user preference because that's primarily the reason I hate bash. It's command history filter is near useless IMO. Most of the time it's just easier to retype the whole thing under bash. tcsh and the FreeBSD defaults allow me to quickly find complex commands I've already got in history.
less compatible with most scripts out there.
Actually most scripts are shebang'd to run with the shell they were written for which is hopefully /bin/sh. Many also test for the proper shell before executing main code. Also please note this is about the interactive, not scripting shell. I'm not saying you should use #!/bin/tcsh in your scripts.
my prompt variable doesnt work on it.
Use the appropriate tcsh variables and you won't have a problem.
its down to choice which I am fine with, but am wondering if this changing root shell thing is simply overstated given that there is a recovery account.
I don't think so. It's typically a new user issue(coming from linux) and toor account is disabled by default. Expecting the new user to remember and deal with all the complications of changing the root shell is just asking for trouble.
UNIXgod
January 19th, 2011, 23:40
please explain since I have ran root using bash for a numbr of years without noticing problems.
the only problem I know off really is if the bash binary breaks preventing login.
I though this was answered or is this just bait?
pkubaj
January 19th, 2011, 23:54
Zsh wherever it's possible.
chrcol
January 20th, 2011, 20:52
why are people mentioning enabling toor?
I have done nothing to specifically enable toor and am able to use it on newly deployed servers.
also I am not baiting anyone.
Galactic_Dominator
January 20th, 2011, 21:29
why are people mentioning enabling toor?
I have done nothing to specifically enable toor and am able to use it on newly deployed servers.
Because if you haven't enabled the toor account, the only way you can utilize it is an su from a super-user account. You cannot login with a default toor account meaning there's no way to fix your bash error you claimed to earlier via toor unless you have explicitly setup the account.
Run vipwlook at the toor line. Notice the '*' in the second field? That mean that account cannot login.
Either way, you're wrong on something.
FWIW, there is nothing inherently special about the toor account, it's just another UID 0 that comes disabled by default.
chrcol
January 21st, 2011, 10:38
I just tested again and can login to toor over ssh even without it having no shell configured in passwd. It uses csh. So it seems a misunderstanding here, it blocks su but not direct ssh login. So regardless of this, someone can setup an alternative shell for root and then enable the toor account for su. Still not a disaster to change root's shell.
Jan 21 09:38:36 vm1 sshd[81144]: Accepted publickey for toor from 192.168.1.124 port 54316 ssh2
# id
uid=0(root) gid=0(wheel) groups=0(wheel)
# grep toor /etc/passwd
toor:*:0:0:Bourne-again Superuser:/root:
Galactic_Dominator
January 25th, 2011, 20:57
I just tested again and can login to toor over ssh even without it having no shell configured in passwd. It uses csh. So it seems a misunderstanding here, it blocks su but not direct ssh login. So regardless of this, someone can setup an alternative shell for root and then enable the toor account for su. Still not a disaster to change root's shell.
Jan 21 09:38:36 vm1 sshd[81144]: Accepted publickey for toor from 192.168.1.124 port 54316 ssh2
# id
uid=0(root) gid=0(wheel) groups=0(wheel)
# grep toor /etc/passwd
toor:*:0:0:Bourne-again Superuser:/root:
Obviously by this point you're trolling at this point disseminating incomplete information to further your position. I encourage anyone who is actually interested in changing their shell to "verify" these statements before they proceed. You will find a different scenario than the one quoted above. ssh via pam authenticates against /etc/master.passwd. The only default scenario where ssh can bypass a disabled account is using ssh keys or some other type of authentication like openldap/NIS. If you have bypassed normal authentication paths in order to make toor work, that does invalidate your point about toor being accessible remotely by default. You did need to do extra steps prior to a bash login issue in order to resolve it.
Also as mentioned before, enabling a UID 0 user for remote login is generally not considered safe. It's somewhat more debatable if you're using keys and such, but even then it's another attack vector. The standard sshd config file doesn't allow root logins for a reason. This is also the policy of many companies so you may not have a choice in the matter.
chrcol
January 26th, 2011, 02:59
will you stop calling me a troll I find it offensive.
the fact is this.
I use key login, I allow key login for root over ssh (but not password), and that allows me to login as toor using my key over ssh without modifying the toor account.
What is so incomplete about it? I dont call people trolls who disagree with me.
DutchDaemon
January 26th, 2011, 03:27
Stop the bickering, or you'll both get to know the /sbin/nologin shell! (:p)
Mattias
January 26th, 2011, 20:03
bash :f
- since it's works flawlessly right out of the box on the Linux distro's I'm running, I use it on BSD's as well (for uniformity). And I really don't notice any difference speed-wise.. guessing I'm the bottle neck in the interaction hehe.
rusty
January 26th, 2011, 21:27
root = csh
me/users = tcsh
No complaints from anyone with access to my servers.
Bra1n0v3rfl0w
January 29th, 2011, 02:08
(1) user = tcsh
(2) root = csh
(3) script = sh
(1),(2) reason: http://www.freebsd.org/doc/handbook/install-post.html, and page 4 of this thread (January 5th, 2011, 22:53), by UNIXgod: reference to chapter 7.10 FAQbook.
(3) reason: http://www.kitebird.com/csh-tcsh-book/csh-whynot.
UNIXgod
January 29th, 2011, 02:52
... and page 4 of this thread (January 5th, 2011, 22:53), by UNIXgod: reference to chapter 7.10 FAQbook.
You have immortalized me!!!! =)
I'll quote it for all to see:
7.10. Why is /bin/sh so minimal? Why does FreeBSD not use bash or another shell?
Because POSIX® says that there shall be such a shell.
The more complicated answer: many people need to write shell scripts which will be portable across many systems. That is why POSIX specifies the shell and utility commands in great detail. Most scripts are written in Bourne shell, and because several important programming interfaces (make(1), system(3), popen(3), and analogues in higher-level scripting languages like Perl and Tcl) are specified to use the Bourne shell to interpret commands. Because the Bourne shell is so often and widely used, it is important for it to be quick to start, be deterministic in its behavior, and have a small memory footprint.
The existing implementation is our best effort at meeting as many of these requirements simultaneously as we can. In order to keep /bin/sh small, we have not provided many of the convenience features that other shells have. That is why the Ports Collection includes more featureful shells like bash, scsh, tcsh, and zsh. (You can compare for yourself the memory utilization of all these shells by looking at the “VSZ” and “RSS” columns in a ps -u listing.)
Here is a clean link to Csh Programming Considered Harmful (http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/)
Bra1n0v3rfl0w
January 30th, 2011, 19:49
You have immortalized me!!!! =)
Hahaha...nice one !!!!!!!!!
To be true, I add the first link I had in mind regarding csh programming considered harmful. :e
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.