Linux Noob: Et tu sudo?


Cesar-sa_mortI haven’t been here in a while so I’ll quickly sum up.  My work machine got sad and instead of replacing the hard drive, I was gifted a Mac.  Well, the Mac got sad so I made my Linux laptop work again.

Currently, I am running Ubuntu 13.  I have been playing around with some other distros but everyone here seems to be pretty happy with Ubuntu.  Personally, I never over-liked it but Mom always said to try new things.

I wish I had been documenting all the wonders to get this thing going but suffice it to say I have been “challenged.”  My latest bout with U13 was with sudo.

I have a rather complex development workstation config going on and so, to make things easier, I have a few environmental variables set, One being the $JAVA_HOME.  This works fine when banging around but I have an application server that I develop against locally that needs to run as root.  So, I kick off the the old sudo command and I get:  java: no can find.

Bah!

I run echo $JAVA_HOME and that works
I run sudo echo $JAVA_HOME and that works… hmm
but I run sudo java and I get the ‘no can find’

So I did a bit of looking about and I found that Ubuntu has some security fix to its sudo.  Though I am hesitant to circumvent this, I had to throw this in to make it work:

alias sudo='sudo env PATH=$PATH'

With that, all is better.  Now I can access java via root, user, and sudo.  weeeeeeeeeeeeee.

Here’s the article where I found this fix: http://stackoverflow.com/questions/257616/sudo-changes-path-why

Image source: http://en.wikipedia.org/wiki/File:Cesar-sa_mort.jpg
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s