Mac OS X Changes On Unix

perm url with updates:

Mac OS X Changes On Unix

Xah Lee, 2010-02-15

This blog is some random notes on Mac OS X.

Recently, i was helping my friend, professor Richard Palais install and fix some svn repsotiory issues at his os x server at uci. I've been doing senior unix sys admin work during 1998-2002 on Solaris. But I haven't really been doing any serious sys admin since. It is a pleasure to dive into the unix quagmire again.

As discussed in my The Unix Pestilence page, the best resource for unix admin is not some commercial books, but rather, the documentations published by the unix maker itself.

The current documentation for Mac OS X 10.6 (Snow Leopard) is at: Mac OS X Server Guides Source. They are excellent.

Changes To Unix

Mac OS X, made many fundamental changes to the incompetent unix in the past decade since it adopted unix. Here's some of them as far as i know:

The login account management and infrastructure has changed. No more “useradd” or “groupadd”. It was replade by Netinfo, but NetInfo got replaced by Lightweight Directory Access Protocol mechanism in 10.5 (Leopard, 2007). My unix expertise is quite still classical, so i don't really understand NetInfo or LDAP.

OS X's Launchd, replaces several unix's start up processes and background processes. Here's Wikipedia quote (slightly edited):

launchd is a unified, open source service management framework for starting, stopping and managing daemons, programs and scripts. It was introduced with Mac OS X v10.4/Darwin v8.0, and is licensed under the Apache License.

The launchd daemon is essentially a replacement for init, rc, the init.d and rc.d scripts, SystemStarter (Mac OS X), inetd and xinetd, atd, crond and watchdogd (Mac Os X).

Of these replaced tech, i particular know about inetd and xinetd. The xinetd replaces the incompetences of inetd. The unix story is all about these replacements. (See: The Unix Pestilence: Tools and Software.)

SSH Session Drops Idle Connection

One annoying thing about OS X is that, if you connect to it thru ssh, after some short period of inactivity, it logs you out. This is a pain in the ass for sys admin. This is actually not caused by OS X, nor ssh settings, but somewhere in the network some software or device auto disconnect when the connection is idle for some period of time.

Here's a trick to solve this problem.

Edit the file “/etc/sshd_config”, so you have the lines:

ClientAliveInterval 280
ClientAliveCountMax 3

The ClientAliveInterval means the number of seconds to check if client is alive, by sending client a encrypted message. Every n seconds, sshd will check if client is active. If client does not respond, it adds a count. When this count reaches ClientAliveCountMax, sshd disconnect the client. You can read more by “man sshd_config”.

You may need to restart ssh. You can do it by going to Control Panel, Sharing, uncheck the “Remote Login” line, then check again.

In traditional unix, you make sshd reread the config file by sending SIGHUP to ssh. (see “man sshd”). For example: “ps auwwx | grep ssh” then “kill -s HUP ‹pid›”. However, i don't think that works in OS X, because when there is no connection, sshd isn't running. When there is a connection, and if you do “ps auwwx | grep ssh”, you'll see that it starts with “-i” option, which means it is running thru inetd. This means, sshd by default in os x is actually not running as a dedicated server, but only launched when there is a connection.

mds Process Problem

On his server, i noticed that the mds process is hogging cpu 100%. Apparently, something is wrong. A seach on the web found many posts about it. Basically, the problem is solved by making Spotlight to re-index the hard drives. (mds is one of the process of Spotlight)

To have Spotlight reindex drives, go to Control Panel, Spotlight, then Privacy Tab. Drag drives to the window. Wait for some 30 seconds for it to take effect. This will delete Spotlight's indexed files (i presume). Then, Remove the drives by clicking the minus sign.


While is was doing sys admin work 8 years ago, i use vi occasionally. That means few times a week, when i have to login to remote servers that doesn't have emacs installed. Long story short, today, i have to use vi again, so have to brush up some commands i forgot. So, i extended by vi tutorial here: Emergency vi.

The reason i have to use vi is a bit complex. Mac OS X has emacs bundled. I have 2 machines. My main machine is a PC running Windows Vista, my secondary machine, which sits on the side, is a PPC Mac running OS X 10.4.x. I can access the server either by ssh from my Windows, or from my Mac, or using the remote desktop software Timbuktu (software) on my Mac. Using the remote desktop software is not a luxury, because i actually need to access the Mac GUI for several reasons. For example, i need to access the various OS X's sys admin GUI utilities. Also, i need to give instructions about using various GUI software on the server. Also, when i use Timbuktu, he can watch while i work on the server, it helps communication. (we also are chatting in voice on Skype)

Normally, if i need to read some doc on the web, or do command line work, i use my main machine, which is Windows. However, due to the Mac ssh idle drop out problem, it makes ssh from Windows to OS Server a problem. The ssh program on my Windows is PuTTY, not that good either, and i haven't spend time to setup a alias to the server etc, so everytime i got disconnected, i have to type the damn long server name and login and password and cd to the dir i was working. A pain. So, for command line work, i work on my Mac thru Timbuktu.

To make things clear, let me repeat: I use my Mac, and Timbuktu, to connect to the server. So, i see the server's screen inside a window on my Mac. Then, i start Terminal there. While in Terminal, i could start emacs in the command line, or, start the GUI emacs Carbon Emacs. But it's not a good option. Because, i've been using emacs for 12 years, and have developed a complete custome designed set of basic shortcuts (see: ErgoEmacs Keybinding.), as well as over a thousand lines of custome elisp code. (See: Xah Lee's Emacs Customization File.) On the remote server, i don't remember what state of my emacs init files there are. Remember, the key confusion would be very complex, because i'm using a PC keyboard, connected to my Mac, going thru Timbuktu, then running Terminal on the server, then running Emacs. Also, my Mac is setup to use the Dvorak layout, and so is my account on the server. When i type a key combination on my keyboard, the keystrokes goes thrue several layers of translation to reach the emacs on the server. Adding the fact that i'm used to a different shortcut set that is different than the emacs default. So, if i just want to make some simple edit in some simple file once, it's easier to just start vi. (or, TextEdit)

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs