I was installing Julia in my fresh FreeBSD installation. I set the path at
and finally entered
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.