Operating System - HP-UX
1836401 Members
3340 Online
110100 Solutions
New Discussion

what's the difference between -sh and sh

 
常有慈悲心
Regular Advisor

what's the difference between -sh and sh

i use cde login,use termial window,and ps -f
can find /usr/bin/sh or sh process,
and i use telnet and can find -sh process,
what's the difference of -sh ,and sh?

thanks
6 REPLIES 6
Sanjay Kumar Suri
Honored Contributor

Re: what's the difference between -sh and sh

There is no difference. However on subsequent call of sh show only sh (not -sh).

Still wondering why -sh for the first time.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Jeroen Peereboom
Honored Contributor

Re: what's the difference between -sh and sh

l.s.

-sh is a login shell.

JP.
Muthukumar_5
Honored Contributor

Re: what's the difference between -sh and sh

hai,

-sh process (who's PPID parent pid is not equal to 1 (init process )) are being created for login with it's shell type /sbin/sh.

sh is used to execute the shell scripts without having the execution permission (by creating the sub shell to execute that file).

We can get the extented long format with ps -exlf | grep -v grep | grep sh to know the difference.

Regards,
Muthukumar.
Easy to suggest when don't know about the problem!
常有慈悲心
Regular Advisor

Re: what's the difference between -sh and sh

but what's in manual of cue:


After a successful login, the accounting files are updated, initializing the user and group ids, group access
list, and working directory. If the session type chosen is tsm, the SHELL to start in each tsm session is
determined from corresponding user entries in the /etc/passwd file. cue then forks the appropriate
shell by using the last component of the shell pathname preceded by a - (for example, -sh or -ksh).
When the session type is invoked with its name preceded by a minus in this manner, the shell performs its
own initialization, including execution of profile, login, or other initialization scripts.
常有慈悲心
Regular Advisor

Re: what's the difference between -sh and sh

and in manual login(man login):


Ater a successful login, the accounting files are updated, user and group IDs, group access list, and working
directory are initialized, and the userâ s command interpreter (shell) is determined from corresponding user
entries in the files /etc/passwd and /etc/logingroup (see passwd(4) and group(4)). If
/etc/passwd does not specify a shell for the user name, /usr/bin/sh is used by default. login
then forks the appropriate shell by using the last component of the shell path name preceded by a - (for
example, -sh or -ksh). When the command interpreter is invoked with its name preceded by a minus in
this manner, the shell performs its own initialization, including execution of profile, login, or other initialization
scrip
Bill Hassell
Honored Contributor

Re: what's the difference between -sh and sh

A login shell is different than a child process. The login shell follows all the rules defined by the shell (inherit the current environment, source /etc/profile, then source $HOME/.profile, possibly .kshrc, etc). To mark the login shell, the - (minus) is prepended to the shell's name. If you run an Xwindows environment such as CDE, the default for terminal emulators is to *NOT* run a login shell, which leads to a lot of confusion. The shell

To find all the processes by name, don't use grep. It does not understand where to search for the process name is located and will find things like hashdaemon and sherry as well as sh, csh and ksh. Instead, use the powerful options in ps to locate programs by an exact name:

UNIX95= ps -f -C sh

This will find -sh, sh, even /usr/bin/sh, but will not find ksh or csh, etc.


Bill Hassell, sysadmin