# where is my setenv ?



## bluethundr (Sep 14, 2010)

Well this seems sort of odd...

I am running the C Shell as my root shell and I am trying to set an environment variable with setenv, but it doesn't appear to be working:


```
[root@LBSD2:/usr/home/bluethundr]#setenv SUDOERS_BASE ou=sudoers,ou=services,dc=summitnjhome,dc=com
bash: setenv: command not found
[root@LBSD2:/usr/home/bluethundr]#setenv
bash: setenv: command not found
[root@LBSD2:/usr/home/bluethundr]#echo $SHELL
/bin/csh
[root@LBSD2:/usr/home/bluethundr]#which setenv
```

For that matter, why is bash telling me that this command isn't working when all indicators are that C is actually my shell?

Here is my root environment:


```
#Changing user information for root.
Login: root
Password: secret
Uid [#]: 0
Gid [# or name]: 0
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /root
Shell: /bin/csh
Full Name: Charlie &
Office Location:
Office Phone:
Home Phone:
Other information:
```

Furthermore, why is this environment, which for all intents and purposes purports to be C Shell actually behaving as bash???


```
[root@LBSD2:/usr/home/bluethundr]#export HELLO=hello
[root@LBSD2:/usr/home/bluethundr]#echo $HELLO
hello
[root@LBSD2:/usr/home/bluethundr]#
```

Can someone offer a clue here? 

Thanks in advance!


----------



## graudeejs (Sep 14, 2010)

show output of `$ env | grep SHELL`


----------



## bluethundr (Sep 14, 2010)

*my shell environment*

here ya go!


```
[root@LBSD2:/usr/home/bluethundr]#env | grep SHELL
SHELL=/bin/csh
```

Yes setenv doesn't work and the bash command export does! 


```
export SUDOERS_BASE='ou=sudoers,ou=services,dc=summitnjhome,dc=com'
[root@LBSD2:/usr/home/bluethundr]#echo $SUDOERS_BASE
ou=sudoers,ou=services,dc=summitnjhome,dc=com
```


----------



## gordon@ (Sep 14, 2010)

You are using bash. How did you become root? Did you use something like su -m or sudo bash?


----------



## SirDice (Sep 14, 2010)

bluethundr said:
			
		

> Well this seems sort of odd...
> 
> I am running the C Shell as my root shell and I am trying to set an environment variable with setenv, but it doesn't appear to be working:
> 
> ...


You're running bash.

Compare:

```
dice@williscorto:~>echo $SHELL
/bin/tcsh
dice@williscorto:~>setenv
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/dice/bin
{ Cut for abreviation }
HOST=williscorto.dicelan.home
REMOTEHOST=
WRKDIRPREFIX=/tmp/build/
DISTDIR=/storage/FreeBSD/distfiles/
TZ=Europe/Amsterdam
CLICOLOR=
TITLE=%{\033]0;%n@%m:%~\007%}
dice@williscorto:~>bash
[dice@williscorto ~]$ echo $SHELL
/bin/tcsh
[dice@williscorto ~]$ setenv
[b]bash[/b]: setenv: command not found
[dice@williscorto ~]$
```

which(1) will never find setenv because it's a shell build-in.


----------



## jalla (Sep 14, 2010)

Sure, which will find built-ins (and aliases too).

i.e.

```
snapper:~% which setenv
setenv: shell built-in command.
snapper:~% which vc
vc:      aliased to vi ~/.cshrc;source ~/.cshrc
```


----------



## madhukarbhat (Sep 14, 2010)

The following may help in identifying the shell in cases where $SHELL may seem misleading:

```
echo $0
```


----------



## freethread (Sep 14, 2010)

what is the result of the command

`# cmp `which bash` `which csh``


----------



## bluethundr (Sep 15, 2010)

*bash / csh /tcsh*

well to clarify I have a nasty habit of typing sudo bash when I want to become root but not change directories as would happen when I type su - root. My guess is that is why I was really in a bash environment when all other indicators pointed to csh! 

Bad me! Quick opinion survery.. how do you like to become root?


----------



## UNIXgod (Sep 15, 2010)

bluethundr said:
			
		

> how do you like to become root?



When ssh'd into a box as a user I us `su`

If I'm at the box I'll log in as root.


----------



## gordon@ (Sep 15, 2010)

I use sudo -H -s.


----------



## Galactic_Dominator (Sep 15, 2010)

UNIXgod said:
			
		

> When ssh'd into a box as a user I us `su`
> 
> If I'm at the box I'll log in as root.


Here too.


> My guess is that is why I was really in a bash environment when all other indicators pointed to csh!


Did you happen to notice the prompt? csh and tcsh require customization to display similar prompts.  Bash users must often forget $PWD or something.


----------

