cancel
Showing results for 
Search instead for 
Did you mean: 

Which Shell

SOLVED
Go to solution
Markus Waldorf_1
Regular Advisor

Which Shell

Hello,

Has anyone of you ever got frustrated with all those different Unix shells? Well, perhaps I got spoiled too much by VMS DCL ;-) Anyway, I would imagine and hope there is someone out there who could please help me to understand a few things:

Tru64, 5.1B:

1) /sbin/sh
2) /bin/sh -> usr/bin/sh
3) /usr/bin/posix/sh

What's the difference between 1 and 2? Dynamic Library? Both shells do not allow to create alias, hence not POSIX, I guess, but also don't produce errors regarding it.

I figured that the variable BIN_SH controls the "behavior" of sh. You get the POSIX compliant shell with "xpg4", the SVR4-like shell "svr4" or the Bourne shell with BIN_SH unset. I exported BIN_SH to "xpg4" in .profile to make it a POSIX sh and the alias command works as expected. I suppose I can just forget about /usr/bin/posix/sh?

Very interesting:
http://www.in-ulm.de/~mascheck/various/shells/


Any chance to get file completion and up-arrow key history working in POSIX or SVRwhatever SH?
Can I enable that in KSH, and how please?

I decided I don't even want to bother about c-shell and get into .login .chrc, bourn or korn, which both use .profile at least, are complicated enough. Anyone share this opinion?

Can I switch to KSH safely without compromising the system. I noticed that the way to export or source variables is different, and actually gives different results. It's probably not a good idea to start out with ksh, set a certain environment and run sh scripts, even with #/bin/sh inside scripts.

I appreciate you comments!

Best regards,
Markus

P.S. Someone at HP please make sure VMS won't die. I suppose the Tru64 case is lost.

15 REPLIES
Patrick Wallek
Honored Contributor
Solution

Re: Which Shell

As far as 1 and 2 go, assuming Tru64 uses the same conventions as HP-UX:

1) /sbin/sh is statically linked. This is so you can work in single user mode without libraries available. Those libraries are usually in /usr/lib which isn't mounted in single user mode. In HP-UX root MUST have this as its default shell. Not sure about Tru64.

2) /usr/bin/sh is the shell that is generally used by users. It dynamically calls libraries.
Kevin Wright
Honored Contributor

Re: Which Shell

1=static
2=dynamic

personally, I always use ksh. do not change root's shell. try esc-k for cmd history.

Bill Hassell
Honored Contributor

Re: Which Shell

The only shell for root on HP-UX is /sbin/sh which is a statically-linked version of the POSIX shell. The POSIX shell is a slight superset of ksh but for most purposes, they are the same. HP-UX ksh is ksh-88 while the X11 enhanced version of the Korn shell (ksh-93) is stored in /usr/dt/bin/dtksh. HP-UX hides the Bourne shell in /usr/old/bin.

Arrow keys are tricky to implement because there are so many different terminals (well, today, emulators) out there and these keys are not single ASCII characters. Bash can implenment arrow keys but you'll have to download a copy for HP-UX.

As far as standard shell features, POSIX is the most universal standard for Unix shells although there are a lot to choose from (pdksh bash ksh-88 ksh-93, etc) and non-ASCII character control keys will always be 'iffy' on various versions.

NOTE: On HP-UX (and Solaris and other SysV v.4 version filesystems) there is no /bin or /lib so you'll need to learn the 'new' locations: /usr/bin and /usr/lib. In HP-UX (and Solaris too) /bin is not a directory at all but is instead a temporary transition link (a symbolic) link. (try: ls -ld /bin /usr) The man page for tlinstall explains this. These 'new' locations are not new at all - they are more than a decade old.

ksh is by far the most universal shell so for multi-system management, I would use that shell. For command line recall and editing, make sure that these lines are in your /etc/profile or .profile:

export HISTFILE=$HOME/.sh_history
export HISTSIZE=1000
export EDITOR=/usr/bin/vi

These variables are universal so you'll find them useful on most flavors of Unix. The fc shell built=in can manage your command history but most admins will alias these:

alias history='fc -l'
alias r='fc -e -'

alias h='fc -l' is a nice shortcut to typing history. history 200 shows the last 200 commands. r recalls the current or r 194 recalls the 194th command in the history list. vi editing commands can be used to change the recalled line and Enter will execute the result. This type of command line recall/edit works in the POSIX shell, ksh, and dtksh.

All these differences is what makes multi-system Unix fun to learn. ;-)


Bill Hassell, sysadmin
Steven Schweda
Honored Contributor

Re: Which Shell

I've standardized on bash:

http://www.gnu.org/software/bash/

Command-line recall is fairly VMS-like. As
with much GNU stuff, it has more features
than any sane person would want, so it
probably has what you want, too.
Ivan Ferreira
Honored Contributor

Re: Which Shell

I really prefer bash, the command line completion using tab, the keyboard shortcuts and so one, makes my life easier.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Markus Waldorf_1
Regular Advisor

Re: Which Shell

Many thanks so far! I noticed that HP-UX seems to be similar regarding root using /sbin/sh. Under Tru64 this seems even hardcoded in single user mode, ignoring the shell entry in /etc/passwd - well this is intelligent.

Seems like Bash is doing most of what I need to make my life easier without having to configure much or know cryptic VT keystrokes. But what worries is that Bash has too many features. I mean, how much can I trust Bash as a command shell under Tru64 in a production environment regarding security and compatibiltiy. I can imagine it was a long way to Bash version 6.12 - if I may say that please without undermining anyones work or ideas.

Assuming that actually most people appreciate the same few file navigation and prompt features, I'm surpised there are not included in the bourne shell.

Bill Hassell
Honored Contributor

Re: Which Shell

The shell is just a user interface to the kernel so in general, it is not that important as far as system management. All shell scripts will be interpreted by the shebang line 1 (#/usr/bin/sh or whatever) so whether you use Bourne or ksh or Bash, the right shell will be used. (of course, any script without a shebang line is not ready for production)

Bourne will never be enhanced - it is a standard (very old standard) shell and if it was enhanced, it would no longer be compatible. There are so many severe limitations in the Bourne shell that most sysadmins won't use it. So the question about which shell is best depends a lot on whether you will be working on a lot of different systems.


Bill Hassell, sysadmin
Manish PATHAK_2
Regular Advisor

Re: Which Shell

Above is true:

1. for static
2. for dynamic

Yes you can change your shell to ksh without any problem if you already not running some important scripts in previous shell, i hope only changing in /etc/passwd should work.

I prefer bash it is really good and helpful while working.

All depends upon the customized applications or the requirement that you have.

Br
Manish Pathak
Markus Waldorf_1
Regular Advisor

Re: Which Shell

I have downloaded the latest version of Bash version 3.2. It compiled fine under Tru64 and also "make test" did not show problems.

My conclusion now is that although Ksh(93) is probably cool for scripting and using available resources efficiently, bash is more compatible with sh, providing what I need, and suitable for my environment. Bash is also standard on most Linux systems, which should hopefully not introduce, but offer sufficient support in terms of detecting security flaws, etc. quickly. If we had public access to our systems I would use /usr/bin/sh as standard, and ksh for advanced users, but that is not the case here.



Manish PATHAK_2
Regular Advisor

Re: Which Shell

Hi,

Can you post this new compiled bash version so that others can also test it.

Br
Manish
Markus Waldorf_1
Regular Advisor

Re: Which Shell

Apart from other concerns, are you sure I would not cause a conflict of interests by posting binaries that are part of a package?

I used 5.1B patchkit 5, download bash-3.2.tar.gz from http://ftp.gnu.org/gnu/bash/

#gunzip bash-3.2.tar.gz
#tar xf bash-3.2.tar
#cd bash-3.2
#./configure
#./make
#./make test
#./make install

It worked flawless. Have you tried?

The last make installed the bash binaries in /usr/local/bin, and also installed the man pages.
Sinisa Radas
Occasional Visitor

Re: Which Shell

Hello all,

I don't have too much experience in HP-UX, but when I changed shell in /etc/passwd file to BASH for some user, that user cannot FTP to the system. Reading ftpd manual, I noticed this is because BASH is not in the list of standard shells. Also visible through SAM in user management, where are several shells to change, but no BASH. Now, since BASH is really easy to use and most of my users like it, is it some list where I can add BASH as standard shell, so system will recognize it like so?

Thank you
Hein van den Heuvel
Honored Contributor

Re: Which Shell

Sinisa,

Welcome to the HPUX Tru64 Forum.

Good job on searching a prior discussion, but you ended up in the wrong forum.

Also, 'hijacking' an old discussion for your own, maybe not completely related discussion is frowned discouraged.

Markus,
You may want to close this thread.

Regards,
Hein.
Markus Waldorf_1
Regular Advisor

Re: Which Shell

will standardize on bash.
Steven Schweda
Honored Contributor

Re: Which Shell

Re: shells

On HP-UX, "man ftpd" says:

[...]
+ The user must have a standard shell returned by
getusershell().
[...]

and "man getusershell" says that
getusershell():

Returns a pointer to the first legal user
shell as defined in the file /etc/shells (see
shells(4)). [...]

A little editing of "/etc/shells" should
solve that problem.

And a new thread in the right forum would be
a good idea, too.