Command only found with -su

I was installing Julia in my fresh FreeBSD installation. I set the path at
Code:
~/.cshrc
and finally entered
Code:
source ~/.cshrc.

The thing is: when I type "julia", terminal doesn't find it:
Code:
$ julia
sh: julia: not found

But when I do the same command with su, it works.
I tried checking the $PATH variables and I came along something interesting:

Code:
$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin
$ su
Password:
root@Leon:/home/leon # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/bin/julia-1.6.2/bin
root@Leon:/home/leon #

Seems like there are two $PATH files, one for super user, the other for general user? How can I change that?
 
To make $PATH .../julia-1.6.2/bin valid for all shells, without taking every shells configuration file in account, use the "login class method" to set the environment variable. Set it system wide in /etc/login.conf:
Code:
default:\
    ...
    :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\
    ...

or per user base in ~/.login_conf:
Code:
me:\
   :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\

Run cap_mkdb /etc/login.conf (or cap_mkdb ~/login_conf) afterwards. If user is logged in, log out, log in to take effect.
 
Path is set in .shrc (for sh(1)) or .cshrc for tcsh(1) (root's shell is csh(1)). Your user's shell is set to sh(1).

I don't see any of those paths in
Code:
/.shrc
Code:
# $FreeBSD$
#
# .shrc - bourne shell startup file
#
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to this file.
#
# see also sh(1), environ(7).
#


# file permissions: rwxr-xr-x
#
# umask 022

# Uncomment this to enable the builtin vi(1) command line editor in sh(1),
# e.g. ESC to go into visual mode.
# set -o vi



^G Ajuda     ^O Gravar    ^W Onde está?^K Recortar  ^T Executar  ^C Local
^X Sair      ^R Ler o arq ^\ Substituir^U Colar     ^J Justificar^/ Ir p/ linha
  GNU nano 5.8                         /home/leon/.shrc                                     
# $FreeBSD$
#
# .shrc - bourne shell startup file
#
# This file will be used if the shell is invoked for interactive use and
# the environment variable ENV is set to this file.
#
# see also sh(1), environ(7).
#


# file permissions: rwxr-xr-x
#
# umask 022

# Uncomment this to enable the builtin vi(1) command line editor in sh(1),
# e.g. ESC to go into visual mode.
# set -o vi


# some useful aliases
alias h='fc -l'
alias j=jobs
  GNU nano 5.8                   /home/leon/.shrc                               
# some useful aliases
alias h='fc -l'
alias j=jobs
alias m="$PAGER"
alias ll='ls -laFo'
alias l='ls -l'
alias g='egrep -i'

# # be paranoid
# alias cp='cp -ip'
# alias mv='mv -i'
# alias rm='rm -i'


# set prompt: ``username@hostname:directory $ ''
PS1="\u@\h:\w \\$ "

# search path for cd(1)
# CDPATH=:$HOME


To make $PATH .../julia-1.6.2/bin valid for all shells, without taking every shells configuration file in account, use the "login class method" to set the environment variable. Set it system wide in /etc/login.conf:
Code:
default:\
    ...
    :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\
    ...

or per user base in ~/.login_conf:
Code:
me:\
   :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\

Run cap_mkdb /etc/login.conf (or cap_mkdb ~/login_conf) afterwards. If user is logged in, log out, log in to take effect.

Tried with both. Nothing changes.
 
Tried with both. Nothing changes.
No problem here:
Code:
test@s840:~ $ grep -m 1 path /etc/login.conf
:path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\

test@s840:~ $ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin/julia-1.6.2/bin:/home/test/bin

test@s840:~ $ echo $SHELL
/bin/sh

test@s840:~ $ chsh -s /bin/tcsh
Password:
test@s840:~ $ exit
login:

test@s840:~ % echo $SHELL
/bin/tcsh

test@s840:~ % echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin/julia-1.6.2/bin:/home/test/bin

Please make sure to remove all $PATH variables in any shell configuration files, run cap_mkdb(1), to take effect of the variable change, log the user out and in.
 
No problem here:
Code:
test@s840:~ $ grep -m 1 path /etc/login.conf
:path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/bin/julia-1.6.2/bin ~/bin:\

test@s840:~ $ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin/julia-1.6.2/bin:/home/test/bin

test@s840:~ $ echo $SHELL
/bin/sh

test@s840:~ $ chsh -s /bin/tcsh
Password:
test@s840:~ $ exit
login:

test@s840:~ % echo $SHELL
/bin/tcsh

test@s840:~ % echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin/julia-1.6.2/bin:/home/test/bin

Please make sure to remove all $PATH variables in any shell configuration files, run cap_mkdb(1), to take effect of the variable change, log the user out and in.

Did everything as suggested, shell did change, but path still the same.

Code:
leon@Leon:~ % echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin

I noticed there's this /usr/games path and as far as I looked for, didn't find it in any of those config files (~/.profile, ~/.shrc, ~/.cshrc, .login_conf), what makes me think there could be probably another conf file?
 
Did everything as suggested, shell did change, but path still the same.
Please post entire /etc/login.conf. I assume you have run cap_mkdb /etc/login.conf after edit.

I noticed there's this /usr/games path ...
As SirDice asked, what version of FreeBSD are you running? Please post uname -a.

Also
The thing is: when I type "julia", terminal doesn't find it:
...
But when I do the same command with su, it works.
...
root@Leon:/home/leon # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/bin/julia-1.6.2/bin
Have you set 'julia' path for 'root' in /root/.cshrc?
 
I was installing Julia in my fresh FreeBSD installation. I set the path at
Code:
~/.cshrc
and finally entered
Code:
source ~/.cshrc.

The thing is: when I type "julia", terminal doesn't find it:
Code:
$ julia
sh: julia: not found

But when I do the same command with su, it works.
I tried checking the $PATH variables and I came along something interesting:

Code:
$ echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin
$ su
Password:
root@Leon:/home/leon # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/bin/julia-1.6.2/bin
root@Leon:/home/leon #

Seems like there are two $PATH files, one for super user, the other for general user? How can I change that?
You should not be able to invoke source ~/.cshrc (or source ~/.cshrc.) from a /bin/sh shell prompt, at all:
Code:
len@mate:~ $ source ~/.cshrc
sh: source: not found
len@mate:~ $ source ~/.cshrc.
sh: source: not found

The source command is implemented by the csh shell as an internal, "builtin" command, however, it is not implemented internally by the sh shell. Reference: man builtin (or man source).

Note particularly that it says:
"If a command specified to the shell contains a slash ‘/’, the shell will
not execute a builtin command, even if the last component of the
specified command matches the name of a builtin command. Thus, while
specifying “echo” causes a builtin command to be executed under shells
that support the echo builtin command, specifying “/bin/echo” or “./echo”
does not."

Furthermore, there is no external source program or script either, or, none that I can readily find in FreeBSD-13.0-RELEASE:
Code:
len@mate:~ $ which source
len@mate:~ $ su
Password:
root@mate:/home/len # which source
source: shell built-in command.
root@mate:/home/len #

In addition, when you invoke ~/.cshrc the command is executed in a subshell. If a command is executed in a subshell, changes in environment variables will not be retained when the instruction pointer returns to the invoking shell.

To work around this problem, you can run a command in the main shell instead of in a subshell, and thereby retain environment variables, by using the "dot" command syntax, to wit:

. ~/.cshrc

instead of

~/.cshrc

However, this leads to the further problem that csh commands are not usable by the sh shell:
Code:
len@mate:~ $ . ~/.cshrc
alias: history: not found
alias: 25: not found
h='fc -l'
alias: jobs: not found
alias: -l: not found
j=jobs
alias: la: not found
alias: ls: not found
alias: -aF: not found
alias: lf: not found
alias: ls: not found
alias: -FA: not found
alias: ls: not found
alias: -lAF: not found
ll='ls -laFo'
/home/len/.cshrc: setenv: not found
/home/len/.cshrc: setenv: not found
/home/len/.cshrc: 31: Syntax error: "(" unexpected (expecting "fi")
len@mate:~ $
In summary, this post doesn't make much sense at all, unless you're using something other than FreeBSD 13.0...?

Edited to add:
^"Seems like there are two $PATH files, one for super user, the other for general user? How can I change that?"

You can't. Super user is using /root/.cshrc and general user is using /home/leon/.shrc. PATH is set in /etc/login.conf as outlined above by T-Daemon, but can be overridden in .cshrc for csch shells, or in .shrc for sh shells. Normally this is done (for sh shells) by a statement like:

PATH=$PATH:/usr/local/bin/julia-1.6.2/bin

I'm not sure of the syntax for csh shells.
 
Back
Top