I added a line echo $PATH > /home/z/path.txt
to the front of /etc/profile
and found the content of /home/z/path.txt
was as follows:
/usr/local/bin:/usr/local/sbin:/usr/bin
Part of the modified /etc/profile
:
# /etc/profile
Set our umask
umask 022
echo $PATH > /home/z/path.txt
Append "$1" to $PATH when not already in.
This function API is accessible to scripts in /etc/profile.d
append_path () {
case ":$PATH:" in
:"$1":)
;;
*)
PATH="${PATH:+$PATH:}$1"
esac
}
Append our default paths
append_path '/usr/bin'
append_path '/usr/local/sbin'
append_path '/usr/local/bin'
As you can see the PATH is not empty when /etc/profile
is processed. My question is: before /etc/profile
is processed, what script sets the PATH
variable?
I've looked through /etc/environment
but I don't think it's the one I am looking for:
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#
QT_AUTO_SCREEN_SCALE_FACTOR=1
QT_QPA_PLATFORMTHEME="gnome"
QT_STYLE_OVERRIDE="kvantum"
Force to use Xwayland backend
QT_QPA_PLATFORM=xcb
#Not tested: this should disable window decorations
QT_WAYLAND_DISABLE_WINDOWDECORATION=1
EDITOR=/usr/bin/nano
I am using zsh
shell on manjaro.
echo $PATH > /home/z/path.txt
, you're overwriting the file, so how are you guaranteeing that the output you see is not from some invocation that already had$PATH
in the environment? (Also, even if you do something likeenv -u PATH /bin/zsh -c 'declare PATH'
, you'll still see zsh's built-in defaultPATH
.) And of course, zsh is sourcingzshenv
, and/etc/zprofile
, before it gets around toemulate sh -c 'source /etc/profile'
in/etc/zprofile
– muru Oct 09 '20 at 16:16/etc/login.defs
after I checked its content. – z.h. Oct 09 '20 at 16:57