1833137 Members
3266 Online
110051 Solutions
New Discussion

shell

 
SOLVED
Go to solution
khilari
Regular Advisor

shell

Hi people, i wanted to know as to how do i know which shell i am in (korne,bourne). Furthermore, i type in some commands from system admin books but they dont work, y is that.

Thanks
11 REPLIES 11
Robert-Jan Goossens
Honored Contributor

Re: shell

Hi,

# echo $SHELL

Regards,
Robert-Jan
Steven E. Protter
Exalted Contributor

Re: shell

Shalom khilari,

echo $SHELL

That tells you the shell

Take the output of that and used the what command.

what /bin/sh

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sandman!
Honored Contributor

Re: shell

echo $SHELL will tell you the current shell you're using and your PATH variable (echo $PATH) isn't setup correctly for the sysadmin commands to work.
James R. Ferguson
Acclaimed Contributor

Re: shell

Hi:

Note carefully that the HP-UX standard shell is the POSIX shell.

For root, this is the statically linked executable: '/sbin/sh'.

For non-root users, the dynamically linked version provides a smaller memory footprint and is found in '/usr/bin/sh'.

Do *not* change root's shell. To do so means your system will not boot! Remember that '/usr' isn't mounted in single-user mode and/or during the early startup scripts.

The old Bourne shell (which is virtually useless) resides in '/usr/old/bin').

The POSIX shell is a Korn ('ksh') variation conforming to Posix standards.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: shell

Note that unlike most other Unix systems, HP-UX has a POSIX shell called /usr/bin/sh. This is not the Bourne shell (a very limited and deprecated shell) like other systems. The Bourne shell in HP-UX is found in /usr/old/bin/sh. You can also see the shell (and other details) with the command:

finger $(id -un)


Bill Hassell, sysadmin
spex
Honored Contributor
Solution

Re: shell

khilari,

If you enter a bogus command into some shells, the error they return is prefaced with the name of the shell:

# garbage
sh: garbage: not found.

However, 'echo $SHELL' is far more reliable.

Regarding the missing commands, either:

1) Your $PATH does not include the directory containing the system admin commands,

or

2) The binaries for the commands do not exist on your system.

To determine which is the case, choose a command from your book and run:

find / -type f -name 'your_command_here' -exec dirname {} \;

If you get any results, you are most likely in case #1. Repeat the find with another command or two, and then add the result to PATH in ~/.profile.

If you do not get any results, repeat the find with another command. If you still do not get any results, the binaries are not on your system, or you do not have permission to see them. The latter is not the case if you do the find as root.

PCS
rariasn
Honored Contributor

Re: shell

Hi khilari,

$ env

rgs,

ran
totoperdu
Frequent Advisor

Re: shell

Hello,

i'm not ok with you.
my shell is bash and when i do "echo $SHELL" the value /bin/sh is returned, so, SHELL var is not the shell i use.

--
Cheers,
Cédrick Gaillard
Ninad_1
Honored Contributor

Re: shell

As been said by everyone to find out shell use echo $SHELL or even can just type ps [without any arguments] and that will list the shell you are using.
As far as some system admin command not working - the reason could be either the PATH is not set or the if the command is related to any package then that software package may not be installed on your system.
When running any command you can check if the shell will find the command [If PATH has been set] using which
which ps [ If found it will show the full path of the command ]
/usr/bin/ps

which xyz
If not found it will show
no xyz in /usr/sbin /usr/bin /opt/ansic/bin ....
Which means since PATH variable does not include the directory where this command is located, shell cannot find it.

Also you may tell us which command you are trying and also tell us the output of echo $PATH if you need more help on this.

Regards,
Ninad
Doug O'Leary
Honored Contributor

Re: shell

Hey,

Actually, I have to disagree w/just about everyone...

The standard answer "echo $SHELL" will tell you what shell you logged in as, not necessarily what shell you're currently using:

To wit:

$ grep root /etc/passwd
root:x:0:3::/root:/sbin/sh

$ sudo su -
Password:xxx

# echo $SHELL
/sbin/sh

# /bin/ksh -o vi
# echo $SHELL
/sbin/sh
# echo $0
/bin/ksh

So, "echo $0" is the correct answer. $SHELL is an environment variable that gets set during the login process. If you change shells anywhere in the process, $SHELL no longer contains the correct information.

HTH;

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
totoperdu
Frequent Advisor

Re: shell

Thanks Doug for theses explanations ;)

--
Cedrick Gaillard