Operating System - HP-UX
1830931 Members
2263 Online
110017 Solutions
New Discussion

Re: cmd for identifying shell

 
SOLVED
Go to solution
sjana
Occasional Advisor

cmd for identifying shell

Hello all,

what command is used to check in which shell we are working now.?

If i need to change the shell what steps need to be followed.

tar
siva
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor
Solution

Re: cmd for identifying shell

Hi,

# echo $SHELL

# usermod -s "shell" user
or change the shell in the passwd file.

Regards,
Robert-Jan
Chris Wilshaw
Honored Contributor

Re: cmd for identifying shell

To check your current shell

echo $SHELL

if you wish to change your default shell (the one from your entry in /etc/passwd)use the chsh command, then log out and back in to pick up the change

eg:

chsh user1 /usr/bin/ksh

If it's only the shell for your current session you wish to change use

exec NEW_SHELL

eg:

exec /usr/bin/ksh

One thing you should never do is change the default shell for the root from /sbin/sh, as this will cause you problems when you next reboot the server.
HGN
Honored Contributor

Re: cmd for identifying shell

Hi

You can use

#echo $SHELL
/sbin/sh (This will tell which shell you are in)

Rgds

HGN

RAC_1
Honored Contributor

Re: cmd for identifying shell

echo $$
echo $SHELL
look at /etc/passwd file
ps -f
There is no substitute to HARDWORK
TwoProc
Honored Contributor

Re: cmd for identifying shell

sometimes - I'm not happy with what $SHELL tells me alone. At times I want to know what actual program name I'm running. So I use "echo $0" from shell.
We are the people our parents warned us about --Jimmy Buffett
Tor-Arne Nostdal
Trusted Contributor

Re: cmd for identifying shell

You didn't say if you wanted to change the shell permanent or if it was only for a "session" or in a script.

After login you could simply fork (start) a new shell.
So - if you have csh as a login shell, just type start ksh to enter korn-shell.

The chsh is for changing the login shell for a specific user permanent.
The file /etc/shells specifies which shells is allowed as login shells.

If you want to ensure running a script with a specific shell you should specify this in the first line of the shell.
Example: #!/bin/sh
This will remove the risk of having a script that fails if the login shell for the user changes.

/Tor-Arne
I'm trying to become President of the state I'm in...
Daniel Duarte
Frequent Advisor

Re: cmd for identifying shell

Sjana

You only need use command:

# ps
PID TTY TIME COMMAND
29111 pts/2 0:00 ps
14504 pts/2 0:00 sh <----

In this case the shell used is bourne shell.