# FreeBSD-12.3p2 - su does not read ~/.cshrc



## byrnejb (Feb 17, 2022)

I have run into a situation that I cannot resolve on my own.  When I `su -l` the root user's logon .cshrc is not `source`d. 

```
[byrnejb_hll@vhost01 ~ (master)]$ su -l
Password:
root@vhost01:~ # CD
CD: Command not found.
root@vhost01:~ # grep CD /root/.cshrc
alias CD="cd"
root@vhost01:~ # source /root/.cshrc
root@vhost01:~ # CD
CD: Command not found.
root@vhost01:~ # 
ll /root/.cshrc
-rw-r--r--  1 root  wheel  1724 Feb 11 10:51 /root/.cshrc
ll -a /root/.*profile*
-rw-r--r--  1 root  wheel  3379 Jul 10  2020 /root/.bash_profile
-rw-r--r--  1 root  wheel   288 Dec 24 09:56 /root/.profile

root@vhost01:~ # cat /root/.profile
# $FreeBSD: releng/11.0/etc/root/dot.profile 278616 2015-02-12 05:35:00Z cperciva $
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
HOME=/root
export HOME
TERM=${TERM:-xterm}
export TERM
PAGER=more
export PAGER

alias bash 'bash -l'
alias rm 'rm -i'
```

This is a recent change in behaviour which occurred after I made  some changes suggested by the `lynis` hardening utility.  I  have reversed most of these these but the change in behaviour remains.

These are the system login scripts:


```
root@vhost01:~ # cat /etc/csh.cshrc
# $FreeBSD: releng/12.3/bin/csh/csh.cshrc 337849 2018-08-15 14:41:24Z brd $
#
# System-wide .cshrc file for csh(1).
```


```
root@vhost01:~ # cat /etc/csh.login
# $FreeBSD: releng/12.3/bin/csh/csh.login 363525 2020-07-25 11:57:39Z pstef $
#
# System-wide .login file for csh(1).
#
# For the setting of languages and character sets please see
# login.conf(5) and in particular the charset and lang options.
# For full locales list check /usr/share/locale/*
#
# Check system messages
# msgs -q
# Allow terminal messages
# mesg y
```

Does anyone have an idea as to why ~/.cshrc cannot be sourced?


----------



## SirDice (Feb 17, 2022)

byrnejb said:


> When I `su -l` the root user's logon .cshrc is not sourced.


What's root's shell set to?


----------



## mer (Feb 17, 2022)

cat /etc/passwd | grep root
Make sure that root's shell is /bin/csh and not something else.


byrnejb said:


> This is a recent change in behaviour which occurred after I made some changes suggested by the `lynis` hardening utility. I have reversed *most* of these these but the change in behaviour remains.


Did you reverse all of them?

What version is actually running?  freebsd-version -kru tells us.
On a FreeBSD-13.0-Release it's working as expected.


----------



## kpedersen (Feb 17, 2022)

```
root@vhost01:~ # source /root/.cshrc
root@vhost01:~ # CD
CD: Command not found.
```

This part seems to suggest that even manually sourcing the file isn't working?


----------



## T-Daemon (Feb 17, 2022)

byrnejb said:


> root@vhost01:~ # grep CD /root/.cshrc
> alias CD="cd"


In csh/tcsh aliases are set without equal sign:

```
alias CD cd
```


----------



## byrnejb (Feb 17, 2022)

T-Daemon said:


> In csh/tcsh aliases are set without equal sign:
> 
> ```
> alias CD cd
> ```


Thanks.


----------

