473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,320 developers and data experts.

Fixing NetInfo Errors on the Command Line

pbmods
5,821 Expert 4TB
FIXING NETINFO ERRORS ON THE COMMAND LINE
LEVEL: ADVANCED
PREREQS: TERMINAL / COMMAND LINE, USERS AND GROUPS

Intro

Today, while performing routine maintenance, I noticed that I was no longer able to use sudo. And attempting to authenticate wasn't working; my computer kept complaining that I wasn't providing a valid administrator's Username.

"That's odd," I thought, since I'd always had an administrator account.

A quick trip into Netinfo Manager confirmed my suspicions: One of my groups had been mysteriously renamed to start with 'admin'.

Now, In Mac OS X, the 'admin' group defines the Users that have administrator privileges. And when there's two admin groups, the system gets confused and decides that there should be *no* administrators.

This is not good, especially because you need admin privileges to modify the NetInfo database!

Fortunately, there is hope. By booting into single User mode (hold down Cmd-S right after you hear the startup chime), you can execute commands with root permissions, even if your normal login account does not have admin privileges.

And wouldn't you know it, but there's a fantastic tool for working with your NetInfo database from the command line in Mac OS X. It's called nicl.

nicl is short for 'NetInfo Command Line'. Unfortunately, there's not a whole lot of documentation for it, but we'll go over the basics here.

Warning: You can screw things up pretty badly if you don't know what you're doing. Only modify your NetInfo database to fix problems, not to cause them.

Basics

Let's start with some simple stuff. Open up your terminal and type the following command:

Expand|Select|Wrap|Line Numbers
  1. nicl . -list /users
  2.  
This will output a list of all User account short names on your system. Note the dot after 'nicl'. This means that we want to look at the local NetInfo database. The '-list' argument means that we want to list all nodes in the users 'directory'.

Note that the term 'directory' here does not actually mean a folder in the filesystem; we use the term because it's kind of like a directory because the NetInfo database is organized in a hierarchal fashion similar to your computer's filesystem.

If you wanted to get information about a specific User account, you could run this command:

Expand|Select|Wrap|Line Numbers
  1. nicl . -read /users/daemon
  2.  
This command lists all variables for the 'daemon' node in the 'users' [pseudo-]directory.

Advanced Stuff

Now let's get into the interesting stuff. How do we change information in the NetInfo database? There are basically four commands that will do the bulk of what you'll need:
  • -create to create nodes (sudo nicl . -create /users/joe)
  • -append to add values to nodes (sudo nicl . -append /users/joe passwd "*")
  • -rename to, well, rename stuff (sudo nicl . -rename /users joe mark)
  • -delete to delete stuff (sudo nicl . -/users mark)

Note that to modify your NetInfo database, you need root permissions. This is where single-User booting comes in handy.

Fixing NetInfo

Considering the situation described at the start of this article, I needed to do something about the errant group entry. After looking at the duplicate 'admin' group (using nicl . -read /groups/admin), I realized that the new group would have to go, and I'd have to re-create the original group (it was www).

So I booted into single-User mode and executed the following commands:
Expand|Select|Wrap|Line Numbers
  1. sh /etc/rc  # finish startup sequence
  2. .
  3. .
  4. .
  5. nicl . -list /groups  # Since there's two admin groups, I don't want to delete the wrong one.
  6. .
  7. .
  8. .
  9. 60         mailman
  10. 61         appserverusr
  11. 62         admin                  <---  Here's the duplicate.  Note its ID number 62.
  12. 63         appserveradm
  13. .
  14. .
  15. .
  16. nicl . -delete 62  # You can also refer to nodes by their ID numbers to resolve duplicates.
  17. nicl . -create /groups/www  # Recreate the original group
  18. nicl . -append /groups/www users www
  19. nicl . -append /groups/www name www
  20. nicl . -append /groups/www passwd "*"
  21.  
  22. shutdown -r now  # To restart the computer.
  23.  
Once I logged back in, everything was back to normal!

Summary

nicl provides a very handy interface for viewing and modifying your NetInfo database information. You can -list and -read directories and nodes, -create, -rename and -delete directories, nodes and keys and -append keys and values to nodes.

You can use nicl in single-User mode to repair damaged NetInfo databases, even if you would otherwise be unable to use your computer.

For More Information
Check out Apple's man page for nicl for more information on how to use nicl.
For more information about NetInfo, what it does and how it works, check out Apple's man page for netinfo.
Jun 23 '07 #1
0 7309

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike Zupan | last post by:
I had some problems with urllib and py2exe under pyton2.3. I works fine until i try to use the exe file. Here is the error Error: 1 LookupError Exception in Tk callback Function: <bound...
0
by: ChrisH | last post by:
Is there a way in python to run a DOS command and have it return any errors that occur? I've tried some of the different versions of peopen as well as the code listed below and none of them give me...
0
by: Wolfgang Kohnen | last post by:
Hello out there! I am new to python and so far I like it a lot. Now I want to create some IMAP mailboxes on my cyrus imapd, with quotas and each user should be subscribed to her/his own spam...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
7
by: vadi | last post by:
I need to design a class for fixing different kind of errors. The errrors fall into number of categories. For each category the methodology of fixing the error is different. I do not want to use a...
0
by: Stephen Cairns | last post by:
I have the following rpx file in a .Net solution and I am getting the following build errors which are driving me crazy and ive no idea where I have went wrong. The build errors I'm getting are as...
4
by: wxforecaster | last post by:
As alluded to in my post yesterday, I'm trying to compile a common C utility in Windows. It's only reference is to zlib.h, which needs zconf.h and in turn libz.a On Unix I've compiled this with...
4
by: Franky | last post by:
I have a cpp program that use to compile in C++6 but give a bunch of errors in VS2005 I'm wondering if I need to reference to some library. I'd appreciate any helpful suggestion Even if...
3
by: V S Rawat | last post by:
Browser has its own settings, java, javascripts, addons, extensions, keyboard shortcuts, along with the problem in html coding in the php file, which all I think might interfere with seeing only...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.