Useful commands for OS X

  • ioreg shows I/O Kit registry. I usually use this to check the capacity of a battery in my powerbook
ioreg -p IODeviceTree -n "battery" -w 0 | grep IOBatteryInfo
  • hdiutil manipulates disk images: I usually use this to merge several dmg files to one iso file.
hdiutil makehybrid -iso -o /path/to/make/your/iso/file.iso /directory/of/the/source/dmg/files/
  • chflags change file flags: I usually use this to unlock files with uchg, nodump, some other flags.
sudo find . -flags uchg -exec chflags nouchg {} \;
  or
sudo chflags -R nouchg .
  • fsaclctl controls the ACL on the specific path.
usage:  fsaclctl -p path | -a  [-e enable] [-d disable] [-v]
                -p              path to filesystem mount point
                -a              operate on all relevant volumes
                -e              enable access control lists on this filesystem
                -d              disable access control lists on this filesystem
                -v              print version
· %2007/%07/%21 %15:%Jul · 0 Comments

Setting up ssh-agent on OS X

It is very important to make the environment variable SSH_AUTH_SOCK available all the time in order to set up successfully ssh-agent on your OS X. The way to save the SSH_AUTH_SOCK variable is simple. Just create the following directory and file on your $HOME.

cd $HOME
mkdir .MacOSX
cd .MacOSX

And then create a file environment.plist in it

[15:02] halfrunt:~/.MacOSX % cat environment.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>SSH_AUTH_SOCK</key>
        <string>/tmp/dikim_ssh-agent.socket</string>
</dict>
</plist>

After that, follow up with the normal ssh-agent configuration on linux.

  1. if SSH_AUTH_SOCK is not defined, setup the value with my specific null file(e.g., /tmp/dikim_ssh-agent.socket)
  2. Otherewise, just use the value of SSH_AUTH_SOCK
  3. check to see if ssh-agent process is running
  4. if not, start it like this
    ssh-agent -a /tmp/dikim_ssh-agent.socket
  5. And then add your ssh private key to your running ssh-agent (e.g., ssh-add ${HOME}/.ssh/id_dsa mostly)

I wrote a simple shell script to run all the boring processes and then put the script to my customized shell configuration(e.g., .tcshrc, .cshrc, or .bashrc) to make my ssh-agent configuration always work whenever I login.
Here is my shell script to configure my ssh_agent.

#!/bin/sh
#
# Check that the ssh-agent is running, and if not, kick it off
#

# default TTL = 8 hours
TTL=28800

if [[ -z $SSH_AUTH_SOCK ]]; then
   SOCKETFILE=/tmp/dikim_ssh-agent.socket
else
   SOCKETFILE=${SSH_AUTH_SOCK}
fi

/bin/ps -wU ${USER} | grep "[s]sh-agent" > /dev/null
if [[ $? -gt 0 ]]; then
   rm -f ${SOCKETFILE}
   ssh-agent -a ${SOCKETFILE}
   chmod 600 ${SOCKETFILE}
   ssh-add ${HOME}/.ssh/id_dsa
fi
· %2007/%07/%20 %15:%Jul · 0 Comments

Where is ldd on OS X?

I have tried to look for ldd in my DarwinPort but it is not there. Instead, I found that OS X uses “otool -L” which is doing the exactly same thing as ldd does.

For more infomation, try to do “man otool”

· %2007/%07/%18 %19:%Jul · 0 Comments
blog/apple.txt · Last modified: 2007/07/18 18:56 (external edit)
Back to top
Open Systems Lab
Indiana University Computer Science Department
Lindley Hall 215
150 S. Woodlawn Ave.
Bloomington, IN 47405-7104

chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0