LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-08-2016, 04:36 AM   #1
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Rep: Reputation: 4
Change PATH environment variable for all users.


Hello,

I want to change the PATH variable for all users and for superuser. I have changed the path in /etc/login.defs and in /etc/profile. For the superuser the path is changed, but for normal user not.

I am using Debian 8 with the xfce desktop.

What am I missing ???
 
Old 09-08-2016, 06:33 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Hmmm... perhaps add your path to /etc/environment as well?

Also, log out, and log back in!
 
Old 09-08-2016, 06:36 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,597

Rep: Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690
Quote:
Originally Posted by Axel van Moorsel View Post
Hello,

I want to change the PATH variable for all users and for superuser. I have changed the path in /etc/login.defs and in /etc/profile. For the superuser the path is changed, but for normal user not.

I am using Debian 8 with the xfce desktop.

What am I missing ???
Not a lot. If the /etc/profile did not do the trick, check the SHELL your users are loading. For BASH users I would load the change into /etc/bash_profile (or, less correctly /etc/bashrc). There are different shell specific profiles for different shells that can override. Make sure you use the pathmunge macro if it is available.

Also, if that fails you, check the ${HOME}/.bash_profile for the user. If they set the path in that it can override everything that came before.
 
1 members found this post helpful.
Old 09-08-2016, 07:13 AM   #4
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Original Poster
Rep: Reputation: 4
Thanx guys for your quick responses. Changing /etc/bash.bashrc did the trick. I added the following:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin"
fi
export PATH
@HMW: When I added the command
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin"
to /etv/environment, it was changed for the superuser as well, which was not what I wanted.
Also: you are right to mention I have to log out and back in, but that is (almost) standard procedure for me when changing settings.

@wpeckham: The files "/etc/bash_profile" and "${HOME}/.bash_profile" are not present on my system. Still, you set me on the right track, so I marked your answer as helpful.

Thanks again to both of you.
 
Old 09-08-2016, 09:54 AM   #5
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by Axel van Moorsel View Post
@HMW: When I added the command
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin"
to /etv/environment, it was changed for the superuser as well, which was not what I wanted.
Eeeh...
Quote:
Originally Posted by Axel van Moorsel View Post
Hello,

I want to change the PATH variable for all users and for superuser.
(My emphasis)

[sigh]
 
Old 09-09-2016, 02:14 AM   #6
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Original Poster
Rep: Reputation: 4
@HMW: Sorry, my bad. Should have been more precise.

What I meant was: I want to change the path for all users into something like "original_PATH_all_users:directory_A", and the path for the superuser into something like "original_PATH_superusers:directory_B:directory_C"

Thanks for bearing with me.
 
Old 09-09-2016, 06:16 AM   #7
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by Axel van Moorsel View Post
@HMW: Sorry, my bad. Should have been more precise.

What I meant was: I want to change the path for all users into something like "original_PATH_all_users:directory_A", and the path for the superuser into something like "original_PATH_superusers:directory_B:directory_C"

Thanks for bearing with me.
No problem. I'm glad that you solved your issue.

Best regards,
HMW
 
  


Reply



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
Set environment variable path Mohammed Zia Linux - Newbie 2 07-13-2012 11:27 PM
PATH environment variable rupeshkp728 Linux - Software 4 07-11-2012 11:01 PM
PATH environment variable Storken Linux - Newbie 7 12-23-2009 05:48 PM
PATH environment variable moonz Red Hat 3 09-08-2005 04:10 PM
Modifying the PATH environment variable brunnopessoa Linux - Newbie 11 11-03-2004 10:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration