LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Setting PATH variable for new users (https://www.linuxquestions.org/questions/linux-general-1/setting-path-variable-for-new-users-785783/)

vhn 01-30-2010 04:08 AM

Setting PATH variable for new users
 
Hi,
What steps have to be followed for having customized contents of PATH environment variable whenever new users are created?
I require this in order to include a special directory into PATH variable; and this has to be a default one for all the newly created users.

Thanks,

White Tea Citrus 01-30-2010 04:36 AM

setting PATH in .bashrc for new users
 
If included, you can simply edit the /etc/skel/.bashrc file.

add something like the following into it and it should work:

export TRASH=/recycle

dv502 01-30-2010 06:55 AM

Another way to add a directory to the PATH variable is

export PATH=$PATH:path_to_directorry

This is only temporary.

To make it permanent, edit /etc/bashrc and search for the PATH statement and add the directory or directories you want. Remember each directory must be separated by a colon :

Or you can just add the command listed above at the end of the file.

Now the directory will be available to all users in the system.



- Cheers

catkin 01-30-2010 08:37 AM

/etc/bashrc is not used to customise bash at startup, according to the GNU Bash Reference which says that the only global (as opposed to personal) file used to customise bash at startup is /etc/profile and that only for login shells.

The login shell restriction seems not to matter regards setting $PATH in shells running in terminals started from the GUI; investigation shows they have the $PATH that is set in /etc/profile. ps -H -U$LOGNAME -o pid,longtname,start_time,command output suggests that a graphical login does start a login shell so all shells running in terminals started from the GUI will inherit the environment variables set by that login shell including $PATH.

@vhn: it is common to source ~/.bashrc from /etc/profile. This ensures that login shells are customised in the same way as interactive non-login shells. If you want non-interactive non-login shells customised in the same way you can set environment variable $BASH_ENV in /etc/profile to ~/.bashrc. If you want bash, when started with name sh the startup file usage is different as described in the link above.


All times are GMT -5. The time now is 04:54 PM.