Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Apr 24, 2009

The 'sudo' Command's Environment

I'm sure most people are aware the 'sudo' command sterilizes the user's environment variables before executing the command passed to it. The most common issue I've run into with this is $PATH not being preserved. The usual scenario is that I have an application installed into /opt and I've appended it's location to $PATH, which works just fine until you try to execute the application with 'sudo' and it fails because the command is no longer in the current path.

The fix to this is really straight forward and I'm surprised I hadn't thought of it earlier. Simply add the following to your $HOME/.bashrc file.

alias sudo="sudo env PATH=$PATH"
What this does is use 'sudo' to run 'env' which is passed the provided command but sets the target environment's PATH to match the current users before executing it.

Don't forget that you can always run the unaliased version of a command simply by prefixing it with a backslash.

Nov 8, 2008

Upgrading to Ubuntu 8.10 (Intrepid Ibex)

In the past I've usually chose to run the early releases and install from scratch but, both because I'm busy and because my Laptop is so well supported out of the box these days I decided to do an upgrade this time around.

Here's a decent how-to if anyone is looking for directions.

The upgrade nearly went perfect. There was just one problem. There seems to be a bug in the Gnome upgrade that changes the way the bookmarks in the Places menu behave.

Here's the bug in Launchpad and here's the specific post that provided me with the fix.

Aug 10, 2008

Setting CFLAGS #2

It turns out that with GCC 4.2.1 and later there is a new 'native' architecture flag for '-march' and '-mtune' that simplifies the setting of 'CFLAGS' greatly. Now instead of having to manually determine the exact architecture you can let GCC do it for you. If you trust it. Example:

CFLAGS="-march=native"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS

previous post: 'Setting CFLAGS'

Jun 28, 2008

Determine What Version of Ubuntu You're Running?

The best way to determine the version of an Ubuntu (or any LSB compliant distribution) is to use the lsb-release command:

$ sudo apt-get install lsb-release
$ lsb_release -a
# Distributor ID: Ubuntu
# Description: Ubuntu 8.04
# Release: 8.04
# Codename: hardy

Apr 5, 2008

Ubuntu 8.04 "Hardy Heron"

The new Ubuntu release, 8.04 "Hardy Heron", is nearly out so I thought I'd take a few minutes to do a fresh 'from scratch' install on to my laptop, a Dell Latitude D830, this weekend. I was pleasently suprised that almost everything worked exactly as expected out of the box, including; wireless networking, dual head monitor support, suspend, hibernate, compiz, etc....

There was one small but very critical change I had to make. It appears that the ACPI hard drive load/unload bug has still not been fixed. It's critically important that you apply this work around unless you want your hard drive to die prematurely.

There was one other non-critical change I made. I didn't dig into the issue to understand it but for what ever reason the default ALSA settings don't support the audio pass through in the docking station. Fortunately the fix is extremely simple. You just need to install the "Gnome Alsa Mixer" and select the IEC958 check box.

#> sudo apt-get install gnome-alsamixer



I've been running Ubuntu on this laptop since the 7.04 Feisty Fawn release and this is by far the smoothest install yet. In the past I've been reluctant to declare Ubuntu's desktop experience to be better than Windows but I think I'm finally convinced.

Setting CFLAGS

It turns out the gento-wiki has a great page indicating which GCC -march flag should be set for which CPUs. To determine which CPU you have, run the following at a command prompt:

#> cat /proc/cpuinfo

It will yield a page of output. The first few lines of output from my laptop are below:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz
stepping : 10

The part you're interested in is the 'cpu family' and 'model'. Once you know those find the corresponding entries on http://gentoo-wiki.com/Safe_Cflags. Then create an entry in $HOME/.bashrc file that looks something like this:
CFLAGS="-march=prescott -O3"
CXXFLAGS="${CFLAGS}"
export CFLAGS CXXFLAGS

Of course substitute the -march value for the one you found on the wiki.