LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-30-2010, 04:08 AM   #1
vhn
LQ Newbie
 
Registered: Nov 2009
Posts: 6

Rep: Reputation: 0
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,
 
Old 01-30-2010, 04:36 AM   #2
White Tea Citrus
LQ Newbie
 
Registered: Sep 2009
Location: Slovakia
Distribution: Trisquel 5.0 Dagda
Posts: 27

Rep: Reputation: 0
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
 
Old 01-30-2010, 06:55 AM   #3
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
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

Last edited by dv502; 01-30-2010 at 07:10 AM.
 
Old 01-30-2010, 08:37 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
/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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to : setting PATH variable for TCL raju.mopidevi Suse/Novell 18 02-22-2009 11:14 AM
Setting PATH variable Aigarzs Linux - Newbie 2 02-07-2008 02:27 PM
Trouble setting PATH variable krutten1986 Suse/Novell 4 09-04-2006 01:21 PM
Help setting $PATH variable Nylex Linux - General 9 08-09-2003 11:44 AM
setting path variable shahrahulb Linux - General 2 07-30-2003 08:25 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration