Can a non-root modify environment variables?

Can a non-root (without sudo permissions) run the following command:

export PATH=/tml:$PATH

If so, how does it work?

I thought environment variables are read-only for non-root users, while shell variables can be modified freely.


The output of the following commands should convince you that you can modify your environment variables.

$ grep PATH ~/.profile 
# set PATH so it includes user's private bin if it exists
    PATH=~/bin:"${PATH}"
PATH="$PATH:/usr/games"

$ ls -l ~/.profile
-rw-r--r-- 1 sudodus sudodus 632 dec 10  2010 /home/sudodus/.profile

In other words, you can not only modify these variables temporarily, but also make it persist by modifying your configuration file ~/.profile. You, as a regular user can do it.


The following command line shows system files, where the PATH is set or modified

sudo grep -r 'PATH=' /etc/*

You may want to get more details. See for example the following link,

Unix & Linux: Complete view of where the PATH variable is set in bash - particularly the answer by Gilles.