VMware Cloud Community
Stuarty1874
Contributor
Contributor
Jump to solution

Updating .bash_profile

Guys,

I'm configuring SUDO on our hosts.

I've created a script to configure SUDO and to create the users on the host.

When the user is created I need to update the default PATH in each users HOME folder

from...

PATH=$PATH:$HOME/bin

to...

PATH=$PATH:/usr/local/sbin:/sbin:/usr/sbin:$HOME/bin

I'd like to either, remove, update or comment out and replace the default PATH and replace with the new one.

Could anyone suggest a suitable way to do this via a sh. script?

Reply
0 Kudos
1 Solution

Accepted Solutions
AndreTheGiant
Immortal
Immortal
Jump to solution

Any guidance??

A bash guide could be fine.

A mandatory profile does not exist in Linux world.. you can set some variable globally (using /etc/profile files)... but each users can modify them (so is not really "mandatory")

There is also a way to make a "default profile": create your file in /etc/skel and when you add a new user, those files will be copied in the user's home directory.

Andre

Andrew | http://about.me/amauro | http://vinfrastructure.it/ | @Andrea_Mauro

View solution in original post

Reply
0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

In the past, I've modified /etc/profile upon provision to update the path of the user's I want to have specific paths, you can take a look at how it's setup for root

# Path manipulation
if ; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

If you know the id for the user's you're creating, then you can add additional conditional OR you can just set it globally depending on your requirements.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

Reply
0 Kudos
AndreTheGiant
Immortal
Immortal
Jump to solution

For global settings, as also as written, you can use /etc/profile.

You can find a lot of examples (for other environment variables) in /etc/profile.d directory.

Andre

Andrew | http://about.me/amauro | http://vinfrastructure.it/ | @Andrea_Mauro
Reply
0 Kudos
Stuarty1874
Contributor
Contributor
Jump to solution

Thanks Guys.

I think I'd like to set the path globally so that when it creates the user it pulls the "updated path" and creates the user profile based on these settings. I suppose just like a manadatory profile in Windows.

I looked through the links but I wasn't 100% sure what I was looking for.

Any guidance??

Reply
0 Kudos
AndreTheGiant
Immortal
Immortal
Jump to solution

Any guidance??

A bash guide could be fine.

A mandatory profile does not exist in Linux world.. you can set some variable globally (using /etc/profile files)... but each users can modify them (so is not really "mandatory")

There is also a way to make a "default profile": create your file in /etc/skel and when you add a new user, those files will be copied in the user's home directory.

Andre

Andrew | http://about.me/amauro | http://vinfrastructure.it/ | @Andrea_Mauro
Reply
0 Kudos
Stuarty1874
Contributor
Contributor
Jump to solution

Thanks.

Updating etc/skel/.bash_profile with the path statement has worked.

Reply
0 Kudos