[Cialug] Tasks for learning shell scripting
Don Ellis
don.ellis at gmail.com
Wed Sep 29 11:49:54 CDT 2010
Yes, /bin/sh could be anything, and it's good to know what you're getting.
If it's zsh, it will behave differently depending on what name it's
called, and other shells may do something similar. Symbolic links (or
hard links) can be used to give a shell a different name.
The shells available for login are listed in /etc/shells
If you do an 'ls -l' on each of these, you can see which are symbolic
links to other locations, and which are the same binaries (maybe hard
links, maybe copies).
Example:
[11:40:09]:<ttys000>:donellis at MacRover.local:/etc
36 (536) $ ls -l /bin/*sh*
-rwxr-xr-x 1 root wheel 1346544 Feb 4 2010 /bin/bash*
-rwxr-xr-x 2 root wheel 767200 Feb 10 2010 /bin/csh*
-r-xr-xr-x 1 root wheel 2186880 May 19 2009 /bin/ksh*
-r-xr-xr-x 1 root wheel 1346624 Feb 4 2010 /bin/sh*
-rwxr-xr-x 2 root wheel 767200 Feb 10 2010 /bin/tcsh*
-rwxr-xr-x 1 root wheel 1597200 May 11 2009 /bin/zsh*
(I just did this in /bin because all the shells listed in my
/etc/shells are in /bin)
--Don Ellis
On Wed, Sep 29, 2010 at 11:37 AM, Matthew Nuzum <newz at bearfruit.org> wrote:
> On Wed, Sep 29, 2010 at 10:23 AM, Don Ellis <don.ellis at gmail.com> wrote:
>> Another thing, bash is often the default shell and ksh is an optional add-on.
>>
>> For a root login, sh is often used for the login shell because it is
>> on a filesystem that is mounted first, and doesn't depend on later
>> boot stages. However, for some systems, bash is used for root login,
>> since it is also on an initial filesystem. If a script might be run
>> before other filesystems are mounted, be sure the shell it runs in is
>> present when it's needed.
>
> Well, this gets to my point. /bin/sh could be anything. In Mac OS it's
> bash, in Ubuntu it's dash. What is it in other UNIX systems? Do most
> come with bash pre-installed? A few years ago GNU tools always had to
> be installed separately.
>
> Bash is such an awesome shell that once you grow accustomed to it you
> may have a hard time using others.
>
> I asked someone else and they suggested using bash and just making the
> student aware of the differences. This page actually explains it quite
> well: https://wiki.ubuntu.com/DashAsBinSh (Dash is a posix compliant
> shell focused on performance)
>
>
> --
> Matthew Nuzum
> newz2000 on freenode, skype, linkedin, identi.ca and twitter
>
> "An investment in knowledge pays the best interest." -Benjamin Franklin
More information about the Cialug
mailing list