OpenBSD Journal

Default root login shell has been changed to ksh.

Contributed by grey on from the one less thing to do post-install dept.

Thanks to hackmann for pointing out the following:

CVSROOT:        /cvs
Module name:    src
Changes by:     deraadt@cvs.openbsd.org 2005/03/27 23:55:11

Modified files:
        etc            : master.passwd

Log message:
change root login shell to ksh as promised; ok many

The complete log message may be read here.

(Comments are closed)


Comments
  1. By scrooge (159.148.213.11) on

    it would be nice if default shell would be /bin/sh, but okay, ksh is better aw.

    Comments
    1. By grey (207.215.223.2) on

      Well, technically /bin/sh, /bin/ksh, and /bin/rksh are all the same (just m5d them if you don't believe me). From discussing this with people who pay more attention to shell nuances than I, apparently depending on the invocation, it will behave a bit differently. At any rate, regardless of the default there's still chsh.

      Comments
      1. By Anthony Roberts (68.145.103.21) on

        MD5 is not necessary

        $ ls -1i sh ksh rksh
        41256 ksh
        41256 rksh
        41256 sh

        They're hardlinks. All three directory entries point to the same inode.

        You are also correct that the name the shell is invoked by determines its behavior. Check the man page for sh for specifics.

      2. By Anonymous Coward (65.110.175.66) on

        Thats right!

        args[0] is a beautiful thing!

        Comments
        1. By Anonymous Coward (131.130.1.135) on

          True, it's kinda funny. Some days ago I noticed that for example traceroute also uses it in its help display. :)

  2. By SH (82.182.103.172) on

    Nice, since I'm a sucker for tab-comletion :-)

    Comments
    1. By Anonymous Coward (24.127.0.74) on

      Same here, although I make this change pretty much right after install. I just type chsh at the command line and make the change. Simple as that. I guess now I don't have to do that though. Cool.

  3. By Anonymous Coward (192.45.72.26) on

    Why not bash? I sincerely wish that one day, bash is included in the default install and is set as root's default shell. Does anyone know why the openbsd team has not done this ?

    Comments
    1. By Anonymous Coward (65.167.23.134) on

      Because they don't add GPL software without a good reason.

    2. By Ash'aman (62.245.36.23) on

      Because it is not BSD licensed.

      Comments
      1. By xhrl.thomas (24.80.50.50) on

        ksh has some cool aspects that bash doesn't, like subsititution with cd. for instance: cd /usr/local/bin cd bin etc and bingo, you're now in /usr/local/etc

        Comments
        1. By Anonymous Coward (213.179.239.104) on

          > cd /usr/local/bin
          and then
          > ^bin^etc
          in [t]csh

    3. By Gerardo Santana (168.255.203.144) gerardo.santana at gmail on http://www.openbsd.org.mx/santana/

      Why would you want bash?

      100% of the people I've talked to asking for bash only wants tab completion and history navigation with arrow keys. These features exist in sh.

      Comments
      1. By Anonymous Coward (24.127.0.74) on

        Don't you mean ksh?

        Comments
        1. Comments
          1. By Anonymous Coward (67.137.34.141) on

            No, sh and ksh are not the same thing. In OpenBSD, /bin/sh is the same file as /bin/ksh. But when you speak of sh by itself, it generally means the bourne shell.

      2. By Marc Gayles (168.12.253.66) mgayles@pobox-ready.com on

        Well, bash is the shell, along with zsh, that better works with non-us layouts. But who minds, Theo uses us layout and that's what matters.

        Comments
        1. By Dirk (193.99.145.162) morticah@gmail.com on

          Could you give an example of problems with international keyboards?
          Its a real question FMI.

          Comments
          1. By Peter Dembinski (217.96.175.71) pdemb@gazeta.pl on http://www.pdemb.prv.pl

            i18n in OpenBSD is still in very early stages of development et all

          2. By Anonymous Coward (62.175.42.214) on

            Most layouts and console drivers doesn't support Delete key. Instead, it prints ~. This ocurrs in console and xterms. FAQ doesn't solve the problem.

        2. By kokamomi (217.215.10.111) on

          And I can't even get those Windows-keys working right... =)

        3. By Anonymous Coward (212.254.223.105) on

          care to elaborate? I've used polish, swiss-french, swiss-german, international US in sh without problems.

      3. By Anonymous Coward (80.135.115.42) on

        OK, that shall be 100% no more:

        I DO use bash just for navigating the command history with C-r (incremental reverse search).

        And of course, emacs betta then vi.

        If I really really need bash as default root shell is another point, though.

        Comments
        1. By Otto Moerbeek (213.84.84.111) otto@drijf.net on http://www.drijf.net

          Well, ksh has emacs editing mode (it's even the default) and ^R works the same as in bash.

          Comments
          1. By Anonymous Coward (67.34.129.203) on

            The ^R part works like bash, and you can even set -o emacs to have sequences like ^A and ^E move around in the line. But there is a subtle difference.... Let's say you want to recall and edit a line you typed earlier. Let's say you typed: "traceroute foo.com", and you want to now traceroute to bar.com. So you do: ^Rtrac (until it shows the correct line) And here's where the problem begins. Let's say you hit the right arrow key. Guess what happens? In bash, the cursor moves one character to the right, like it should. But in ksh, some ASCII characters are inserted under the cursor. Oops... So much for convenient line editing.

    4. By Anthony Roberts (68.145.103.21) on

      "Why not bash? I sincerely wish that one day, bash is included in the default install and is set as root's default shell. Does anyone know why the openbsd team has not done this ?"

      1. bash is GPL licensed
      2. bash is pretty bloated compared to ksh

      I actually do prefer bash, but it takes about 5 seconds to install the package, and you can change the root shell if you want it that badly. I don't mind having to actively add bloat when I want it. The rest of the system that I don't care about continues to be the non-bloated alternatives, and that's a Good Thing (tm).

      Comments
      1. By Anonymous Coward (80.135.115.42) on

        It took me 5 seconds to remember that there are very rare cases turning out very inconvenient: the 5-second-install-bash is dynamically linked whereas sh is a static binary. Having root relying on that depends on availability of the mount point with those particular bash related libraries on it. So watch out!

        Comments
        1. By Anthony Roberts (68.145.103.21) on

          Very true.

          There's a statically linked bash in packages as well, which is what you'd want if you switched the root shell. You'd also want it in /bin.

          That said, I've never found a reason good enough to mess with the defaults for root.

    5. By Anonymous Bastard (12.33.195.201) on

      I too, like bash...after wget, it's the second package to get installed after a fresh install.
      i could give a sh1t about what the default shell is though... like others have stated, there is always chsh for those who dont like it.
      at the end of the day, it's still a theo-cracy.

      Comments
      1. By Nate (65.95.125.49) on

        What do you need wget for? ftp works fine and lynx works fine, they're already there.

        Comments
        1. By Anonymous Bastard (12.33.195.201) on

          recursive downloads, multiple file transfers... it's easier to script w/ wget. and b/c it's my *choice*.

          Comments
          1. By Anonymous Coward (68.121.242.123) on

            Which can be done with ftp in OpenBSD.

            Comments
            1. By Anthony Roberts (68.145.103.21) on

              You can't script HTTP gets with ftp.

              Comments
              1. By tuhtah (128.131.167.193) on

                you can: ftp -ortfm.html "http://www.openbsd.org/cgi-bin/man.cgi?query=ftp"

                Comments
                1. By Anonymous Bastard (12.33.195.201) on

                  Gay. just b/c you can do something one way, doesn't mean its the best way or the only way. again - G.A.Y. stop arguing for argument's sake.

                  Comments
                  1. By tuhtah (128.131.167.193) on

                    honey, get over it! on obsd there is really just one true way, namely the audited BSD-licensed base system way...

                  2. By Anonymous Coward (67.137.34.141) on

                    In OpenBSD, the way generally is they provide you with one way to do it in the base install, and give you the choice of installing other ways from ports if your way doesn't happen to be the OpenBSD way. And the best way is often someone's masturbatory preference.

                  3. By Anonymous Coward (67.34.129.203) on

                    Right on. I'm tired of the pointless debates. I use Lynx most of the time for interactive browsing, but when I want to download stuff in a scripted manner, I reach for either wget, or a perl script I wrote (that internally uses LWP but has the option of falling back onto wget if necessary).
                    In fact I use wget so much I ended up making an alias:
                    $ grep wget .profile
                    alias mirror='wget -t 0 -r -k -np'
                    wget also makes it easy to exclude certain paths, or automatically convert extensions like .php -> .html so you can browse the local files in Lynx...
                    mirror -E -X /badpath http://nifty.stuff.here/index.php
                    There's also another tool called "pavuk" that's even more powerful and can interpret javascript... I've used it in the past, but it's a bit overkill for most things.

            2. By Anonymous Coward (62.175.42.214) on

              ¿Logfiles?
              ¿Parsing files for links?
              ¿Custom referer?
              ¿Custom user agent info?
              ¿Cookies?
              ¿Base URLs?
              ¿Real background?
              ¿Speed limiter?
              ¿Download quota?

    6. By henning (80.86.183.87) on

      because bash is a piece of crap full of bugs that offers almost nothing that ksh doesn't offer perhaps

      Comments
      1. By Michael Knudsen (217.157.199.114) on

        Don't get me started on long command lines in bash.

        It's known as InstaGarble[tm] where I come from.

    7. By Anonymous Coward (142.166.106.226) on

      Bash is also something of a pig (resource-wise). Ksh is much faster to start too (esp. when combine with rxvt). My only real beef is having to futz around to pass the 'login shell' flag in some console programs -- and this is awkward only because console programs in Gnome/Kde seem to assume the shell will be Bash and so not need parameters .... not really a flaw with ksh). -

    8. By Chas (147.154.235.53) on http://rhadmin.org

      I'm not really sure what is happening with ksh under the new release of OpenBSD 3.7 (is it still pdksh, or did the "ksh source code cleanup" indicate that it's been forked?), but bash does not implement full ksh88 compatibility, let alone ksh93. A few missing features:

      The print statement
      coprocesses (showstopper)

      ksh93 introduces some important features that all the other shells have ignored for far too long:

      floating point arithmetic
      case fallthroughs (;&)
      numeric for loops (aesthetic quality only)

      I understand that Apple recently made bash the login shell for internationalization reasons. Bash is still really a bloated and substandard shell, but it scratched Apple's itch so they went with it. OpenBSD is a bit more purist, both from a licensing and code quality standpoint.

      Comments
      1. By Otto Moerbeek (213.84.84.111) otto@drijf.net on http://www.drijf.net

        pdksh is basically abandoned by its author. Last release was Jul '99.

        We already fixed quite some bugs and added some features in the past, so you could call this it a fork, I guess.

        The source code cleanup we did consisted of ansifying all functions and removing a lot of #ifdef'ed crud we don't need, like support for OS/2.

        Comments
        1. By Peter Hansen (130.225.45.173) pih@xbase.dk on

          So, when do we get to see openksh.org?

          Comments
          1. By Alex Hafey (82.69.184.245) alex@hafey.org on

            You can always download this:

            http://www.research.att.com/~gsf/download/tgz/ksh.2005-02-02.openbsd.i386.gz

            Linked from http://www.kornshell.com/software/

            or if you want source:

            http://www.research.att.com/sw/download/

            Comments
            1. By Chas (147.154.235.51) on

              I posted an article on ksh93 to undeadly some time ago. It was discussed at some length.

    9. By Anonymous Coward (213.179.239.104) on

      because bash is slow, memory-consuming, and GPLed.
      Why ask? Nearly 99% of users use nearly 5% of bash power, and you can do tab-completion and history in other [quicker,smaller,better] shells too.

  4. By Anthony Roberts (68.145.103.21) on

    I don't spend much time as root, but I really dislike csh.

    Comments
  5. By Glenda (82.182.149.44) on http://plan9.bell-labs.com/plan9dist/

    ... they will switch the default shell to rc.

    Well, at least dropping the csh aberration is a step in the right direction that I hope the other BSDs will follow soon.

    Comments
    1. By Anonymous Coward (206.171.8.192) on

      I always considered csh as the root shell a bonus. It was incentive not to use root during those lazy moments.

      Comments
      1. By Anonymous Coward (82.182.149.44) Glenda on http://plan9.bell-labs.com/sys/doc/auth.pdf

        Why not fixing the the root problem instead?

        That is, getting rid of root, but I was expecting that would take at least another 20 years.

        But don't despair, unlike others, at least OpenBSD seems to be going (mostly) in the right direction.

        Comments
        1. By Nate (65.95.125.49) on

          Neat, you're marked as Glenda next to your ip now, I'd never seen that on Undeadly before. That is a handy one.

        2. By Nate (65.95.125.49) on

          And another thing, what's the deal with you being all bitchy and wanting OpenBSD to be Plan 9? If you want Plan 9, download the damn thing and use it. csh is was not removed from the system, it is still there for anyone to use if they want it, it was the default shell for so long out of respect for the past. csh is the default shell of the ancient BSDs from long ago. rc would probably be considered for being in the base system instead of a port if it wasn't licensed so stupidly, it is basically trying to be a BSD license but is worded poorly and sound like it was writen by a teenager. Root is a necessary part of security in a multiuser system, you need a single user to be in charge and to have all others be lesser users.

      2. By Anonymous Shell (68.121.242.123) on

        "It was incentive not to use root during those lazy moments."

        As the newblar I was to UNIX when I tried OpenBSD 2.7, csh definitely kept me from using root for anything on the command line. So, if it wasn't for my dislike towards csh, I would have destroyed the system most likely sooner than later.

        I hope the decisions made had technical merit behind them instead of giving in to comfort and whining.

    2. By McLone (213.179.239.104) on

      > Maybe in another 20 more years they will switch the default shell to rc
      Yes rc is clean and beautifull, but this one particular implementation has flaws (i've seen couple when using http://swtch.com/plan9port/ on FreeBSD RELENG_5, exit status related and other)

      Inferno's /dis/sh is interesting too

  6. By Anonymous Coward (141.157.203.182) on

    Don't know why everyone so abhors csh; I think it is quite great. Using $< instead of that horribly long 'read', and the beauty of foreach speaks for itself.

    Comments
    1. By Anonymous Coward (202.45.125.5) on

      the beauty of foreach speaks for itself.

      What's wrong with...

      
      for something in `cat file.txt`
      do
          echo $something
      done
      

      ???

      Comments
      1. By mirabile (82.83.250.19) on http://MirBSD.org/

        Congratulations for the useless use of cat award.

        for foo in $(<file); do
        something $foo
        done

        Of course, that's still bad (but flexible, due to IFS splitting)
        because the line length is pretty limited.

        I've done the step from csh to ksh after pondering for 1½ years
        because csh was historically BSD, but I'm a (pd)ksh addict myself
        (don't miss too many features from ksh93).

      2. By Anonymous Coward (141.157.203.182) on

        it was sarcasm, pure and simple. notice csh's "$<" is compared against the 'horribly long read'? I do like csh, but this was sarcasm. Besides which, what is wrong with:
        foreach i (`cat 0.txt`)
        echo $i
        end
        Absolutely nothing. Besides, with tcsh, I get all the things I want (tab completion & the csh features). csh can be a pain in the ass, but it is not so evil as most people make it sound.
        Cheers!

        Comments
        1. By McLone (213.179.239.104) on

          ever saw 900kb csh script (in CAD system) which you must debug?

      3. By Gerardo Santanaa (200.65.129.33) gerardo.santana at gmail on http://www.openbsd.org.mx/santana/

        while read something; do echo $something; done < file.txt

    2. Comments
      1. By tedu (64.173.147.27) on

        the problem with a list of bugs from last century is that the bugs get fixed but the list doesn't. not that your default shell has *anything* to do with the shell used to interpret scripts.

  7. By SleighBoy (64.146.180.98) on http://www.code.cx/

    And there was much rejoicing *yay*

  8. By Anonymous Coward (66.159.249.56) on

    i never really used ksh before, but it seems like most of the features that people want are present in tcsh, and its more likely to be compatible with old shellscripts.

    Comments
    1. By Anonymous Coward (70.16.56.164) on

      I bet Theo, et al never considered this!

      Comments
      1. By thomasw.xhrl (24.80.50.50) on

        theo thought about it and still went with it. for myself i will trust in his reasoning:)

    2. By Anonymous Coward (203.24.6.121) on

      "... its more likely to be compatible with old shellscripts."

      Your scripts should begin with "#!/bin/whatevershell" which would tell the script which shell to use to interpret it. It doesn't actually matter what your primary shell is.

    3. By Anonymous Coward (69.197.92.181) on

      Shell scripts are almost always written in sh to be portable and because csh has some annoying limitations.

    4. By RC (4.8.16.53) on

      > it seems like most of the features that people want are present in tcsh,

      Yeah, I want the feature where my shell does nothing at all when I hit tab several times, and gives me no clue as to why (eg. multiple matching files)...

      > and its more likely to be compatible with old shellscripts.

      This change only has to do with the default root shell for interactive use... Nothing at all to do with scripts.

      ksh88 is the standard now, and for good reason. You can still use /bin/csh in your scripts if you want to for some reason, though I suspect there are very few people who script csh anymore.

      Comments
      1. By tedu (64.173.147.27) on

        Yeah, I want the feature where my shell does nothing at all when I hit tab several times, and gives me no clue as to why (eg. multiple matching files)...

        you could read the man page and discover set autolist.

  9. By Peter Hessler (208.201.244.164) on

    Use your regular user, and use sudo. Geeze!

    If it matters *that much*, install your favorite. Make sure its staticly linked, and copy it to /bin. Otherwise it won't help you when you *have* to use a root shell (single user mode, with nothing mounted).

    Comments
    1. By pgilman (67.83.114.80) on

      peter hessler wrote:

      "...install your favorite (shell). Make sure it(')s static(al)ly linked, and copy it to /bin. Otherwise it won't help you when you *have* to use a root shell (single user mode, with nothing mounted)."

      i've always been curious as to why the binary from the bash-static package gets installed in /usr/local/bin instead of directly into /bin. can anybody enlighten me on this?

      thanks!

      Comments
      1. By Nate (65.95.125.49) on

        Cause it is not part of the base system, and therefore belongs in /usr/local.

      2. By Anthony Roberts (68.145.103.21) on

        In general, nothing post install should automatically alter directories created for the base system. The packages can print a notice saying that further action needs to be taken when they're installed (the shells will tell you that /etc/shells needs to be updated, for example).

        I don't know if the statically linked bash does that.

Latest Articles

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]