Category Archives: System administration

Network Manager failing to recognize ethernet

Problem description:

  • Network Manager refuses to start your Ethernet connection using the GUI, with the connection showing up as “Unmanaged”.

  • The command-line interface to Network Manager reports an error “Error: Connection activation failed: Device not managed by NetworkManager or unavailable”.

  • However, ifup/ifdown successfully starts and stops your Ethernet connection.


  • Edit /etc/network/interfaces. Comment out any lines referring to eth* devices.

  • Restart Network Manager via /etc/init.d/network-manager restart or upstart.

Apparent cause:

Some VPN software helpfully added the eth0 lines to your list of interfaces handled by the older network scripts. When Network Manager sees that, it refuses to manage eth0 itself.

Yum: “Unable to read consumer identity”

Did you just install a new RHEL 6 system? If so, you might have used the familiar rhn_* commands to register the system. Unfortunately, those don’t work in RHEL 6.3. Instead, they result in a broken setup where Yum always barfs with the above error.

RedHat’s knowledgebase article claims that it’s possible to set up traditional RHN on a 6.x system, but their instructions don’t seem to work.

Instead, first you’ll need to get rid of the old ‘RHN Classic’:

rm -rf /etc/sysconfig/rhn_systemid
rm -rf /var/cache/yum/*
yum clean all

Now delete the system from the classic RHN console on the web, to free up the entitlement. After that, you can register for the new improved RHN, using a different set of commands:

subscription-manager register
subscription-manager subscribe --auto

Now yum update should work.

Also, you don’t want to go to any more. That’ll only show you the “Classic RHN” systems. Instead, go to which will show you both. Yes, you have to manage your 6.x and pre-6.x systems via two different web UIs.

You can also access the new management interface via the Subscriptions menu; however, I missed finding it for ages because I didn’t realize that systems were now referred to as “consumers”. In RedHat’s crazy new terminology you’re a “distributor”, because you distribute keys to the “consumers”.

Locate a file, then cd to the location of that file

Sometimes the hardest part of improving your productivity is being able to notice that you’re doing something sub-optimal multiple times each day.

I was sitting hacking on some documents this morning when I realized that I frequently follow this usage pattern:

  1. Locate a file, using the locate command—often a Linux configuration file of some sort.
  2. Change directory to the directory containing that file, which is often a long way from the root directory or my current directory.
  3. Do some stuff using the file.
  4. Go back to what I was doing before.

A typical interaction:

w510:~/WIP 740$ locate s-pre-01.tex
w510:~/WIP 741$ cd /usr/local/context/tex/texmf-context/tex/context/base
w510:/usr/local/context/tex/texmf-context/tex/context/base 742$ cp s-pre-01.tex ~/WIP/
w510:/usr/local/context/tex/texmf-context/tex/context/base 743$ cd ~/WIP/
w510:~/WIP 744$

The problem here is that long path. I either have to type it with assistance from tab completion, or copy and paste it using the mouse.

I realized it would be really handy if I could do something like cd `locate s-pre-01.tex`

Of course, that doesn’t work for a couple of reasons, most notably that locate outputs a path to a file, not to a directory.

I checked to see if locate had an option to output only the directory name of the match, or if cd had an option to accept a filename and move to the same directory as the file. No on both counts.

Next, I checked to see if something like cdargs would solve the problem, but it seemed not.

I had the feeling a lot of other people had probably wanted to do what I wanted to do, so my next stop was Google. That turned up unhelpful monstrosities like cd "$(dirname "$(find / -type f -name ls | head -1)")"

Due diligence done, it looked like I wasn’t about to reinvent the wheel. I hacked together a couple of bash shell functions. My new improved interaction:

w510:~/WIP 757$ cdlocate s-pre-01.tex
w510:/usr/local/context/tex/texmf-context/tex/context/base 758$ cp s-pre-01.tex ~/WIP/
w510:/usr/local/context/tex/texmf-context/tex/context/base 759$ cd -
w510:~/WIP 760$

Note the use of cd -, an undocumented feature of bash which returns to the previous working directory. (It’s undocumented in help cd, at any rate.)