Fedora Linux Support Community & Resources Center
  #1  
Old 29th April 2012, 02:54 PM
shaunsingh14 Offline
Registered User
 
Join Date: Apr 2012
Location: Glen Oaks, NY
Posts: 2
linuxfirefox
Question Setting environment variables on Fedora 16?

Good day, fellow Fedora users. I migrated to Fedora 16 from Arch Linux because a kernel upgrade caused my system to break (my fault for enabling testing repo, but I really didn't feel like going through an ncurses-based installation and end up at a command line again). Fedora was my primary choice because I had a lot of fond memories with it, and I missed dealing with RPMs. The only complaint I have is the lack of a BSD-style init and /etc/rc.conf (but that's another story).

The main reason I ran for help here is because I'm in the process of installing the Android SDK, and instead of making it user-specific, I wanted it to be system-wide, because I'm sharing this computer with two other people who like to tinker around with Android, and rather than giving them my computer password and risk them messing up any sensitive documents I have, I'd rather make them two seperate accounts and place ADB/Fastboot/etc. in their $PATH (did I word that correctly?).

I accomplished this in Arch Linux by modifying /etc/profile and appending the location of the SDK to the end of the PATH line. However it seems I can't do so in Fedora (at least, not anymore).

Code:
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
What file contains the system-wide PATH? I just wanna append the location of the SDK and get on with my computing.
Reply With Quote
  #2  
Old 29th April 2012, 03:00 PM
trekkie690 Offline
Registered User
 
Join Date: May 2009
Location: Nor Cali
Posts: 75
linuxfirefox
Re: Setting environment variables on Fedora 16?

if i remember correctly you can add it to /etc/profile. But that said i would have to look through my RHEL/Fedora book. Course its safer to put the path in each profile, which you just need to add to the ~/.bash_profile for each user.
Reply With Quote
  #3  
Old 29th April 2012, 03:53 PM
shaunsingh14 Offline
Registered User
 
Join Date: Apr 2012
Location: Glen Oaks, NY
Posts: 2
linuxfirefox
Re: Setting environment variables on Fedora 16?

Quote:
Originally Posted by trekkie690 View Post
if i remember correctly you can add it to /etc/profile. But that said i would have to look through my RHEL/Fedora book. Course its safer to put the path in each profile, which you just need to add to the ~/.bash_profile for each user.
I searched through /etc/profile, but I can't find any lines that resemble this:

Code:
 PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:"
Strange, in every GNU/Linux operating system I've used, there was always a line like that (save for Ubuntu, which had /etc/environment. )

EDIT: I've managed to create a script in /etc/profile.d/ which took care of it.

Code:
[shaun@the-enforcer ~]$ cat /etc/profile.d/android-sdk.sh
# appends location of android-sdk-linux to PATH
ANDROID_SDK=/opt/android-sdk-linux
export ANDROID_SDK
PATH="$ANDROID_SDK/tools:/$ANDROID_SDK/platform-tools:$PATH"
[shaun@the-enforcer ~]$
I stll don't see why I had to create a new variable JUST to append an SDK into my $PATH.

Last edited by shaunsingh14; 29th April 2012 at 04:06 PM.
Reply With Quote
  #4  
Old 29th April 2012, 11:21 PM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,068
linuxfirefox
Re: Setting environment variables on Fedora 16?

Or you could modify the proper shell configuration file template in /etc/skel, then when you create a new user the /etc/skel/.bash_profile is copied to the new user's home directory by useradd (or system-config-user if you use the GUI user add tool).

Just modify the PATH in /etc/skel/.bash_profile as you want for the Android SDK

But if you want to use a different shell, you may need to add your own template (like /etc/skel/.tcshrc for tcsh )
Reply With Quote
  #5  
Old 30th April 2012, 03:32 PM
Gareth Jones Offline
Official Gnome 3 Sales Rep. (and Adminstrator)
 
Join Date: Jul 2011
Location: Birmingham, UK
Age: 32
Posts: 2,771
linuxfirefox
Re: Setting environment variables on Fedora 16?

Quote:
Originally Posted by shaunsingh14 View Post
Code:
[shaun@the-enforcer ~]$ cat /etc/profile.d/android-sdk.sh
# appends location of android-sdk-linux to PATH
ANDROID_SDK=/opt/android-sdk-linux
export ANDROID_SDK
PATH="$ANDROID_SDK/tools:/$ANDROID_SDK/platform-tools:$PATH"
[shaun@the-enforcer ~]$
It might be better to use Fedora's "pathmunge()" function (inherited by profile.d files from /etc/profile):
Code:
# /etc/profile.d/android-sdk.sh
# Prepend Android SDK tool directories to $PATH.
export ANDROID_SDK="/opt/android-sdk-linux"
pathmunge "$ANDROID_SDK/platform-tools"
pathmunge "$ANDROID_SDK/tools"
pathmunge() ensures that that $PATH is sane and without duplicates etc.

Quote:
I stll don't see why I had to create a new variable JUST to append an SDK into my $PATH.
If it's just to save typing "/opt/android-sdk-linux" twice (and so that you only have to change that in one place if you move it), then that's reason enough for a shell variable. That wouldn't require it to be exported to the environment though,

If the Android SDK tools themselves use the environment variable, then it should be exported.
Reply With Quote
Reply

Tags
environment, fedora, setting, variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set environment variables? Seedrick Using Fedora 3 23rd May 2010 01:47 PM
setting environment variables craigni Using Fedora 0 25th December 2006 02:54 PM
setting environment variables blahboybang Using Fedora 2 25th April 2006 12:23 AM
Environment variables Flatron Using Fedora 7 28th January 2006 02:47 AM


Current GMT-time: 10:23 (Saturday, 01-11-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Goris Instagram Photos - Phalia Photos - Kallithea