|
OSXFAQ Mac OS X UNIX Tip-of-the-Day

Week 104 - Unix Commands Reference IV (11 April 2005)
by
Adrian Mayo - Editor, OSXFAQ
Friday - Example Usage
These examples are taken from my own notes and have not been tested for a while.
Screen Capture Command
When you use the interactive version (command-shift-4), the space bar will toggle between the regular marquee selection mode and a new mode to capture just a single window, the Dock or the menu bar. The cursor changes to a camera icon when you are in this new mode and as you mouse over different areas of the screen the screen capture target is highlighted for you.
Screen captures can be triggered from the command line (and therefore AppleScript, perl, etc.) using the new screencapture command found in /usr/sbin/
usage: screencapture [-icmwsWx] [file] [cursor]
-i capture screen interactively, by selection or window
control key - causes screen shot to go to clipboard
space key - toggle between mouse selection and window selection modes
escape key - cancels interactive screen shot
-c force screen capture to go to the clipboard
-m only capture the main monitor, undefined if -i is set
-w only allow window selection mode
-s only allow mouse selection mode
-W start interaction in window selection mode
-x do not play sounds file where to save the screen capture
hdiutil Command
Here is how to create a 50MB drive image, backup data to it, and then burn it onto a CD (directly in the commandline).
hdiutil create -fs HFS+ -volname Backup -size 50m ~/Desktop/backup.dmg
hdiutil mount ~/Desktop/backup.dmg
ditto -rsrc -V ~/Desktop/datatobackup /Volumes/Backup >> /Volumes/Backup/backup.log
hdiutil unmount /Volumes/Backup
hdiutil burn ~/Desktop/backup.dmg -noverifyburn -noeject
NetInfo Command Set
- Backup a NetInfo database
nidump -r / -t localhost/local > backup.nidump
- Restore a NetInfo database from backup
periodic daily backs-up the NI database to /var/backups/local.nidump
From single user with / mounted rw, move old /var/db/netinfo/local.nidb
Start essential services
/usr/libexec/kextd
/usr/sbin/configd
/sbin/SystemStarter
Create blank NetInfo database and start NetInfo
/usr/libexec/create_nidb
/usr/sbin/netinfod -s local
Load the backup into NetInfo:
/usr/bin/niload -d -r / . < /var/backups/local.nidump
- Re-create NetInfo via OS X first-time setup
rm /var/db/.AppleSetupDone
reboot
Other Commands
bless
Set OS X as a startup
sudo bless -folder '/System/Library/CoreServices' -setOF
Set OS 9 as a startup
sudo bless -folder9 '/Volumes/Mac OS 9/System Folder' -setOF
defaults
defaults read/write/delete <file> <parameters>
defaults write com.apple.terminal TerminalOpaqueness '0.85';
fsck
In single user mode, to repair HFS disc 1 partition 5
fsck_hfs -y /dev/rdisk1s5
man
man 7 ascii ... ASCII table
man 7 hier ... file system hierarchy
man cmd | col -b ... print manual pages
mount
mount_afp [-o option1[,option2 ...]] afp://[username:password]@rhost[:port]/volume node
mount_cd9660 /dev/disk2s1 /Volumes/cd
umount /Volumes/cd
mount -t hfs -w /dev/disk0s10 /Volumes/Grima
nvram
nvram -p ... to print variables
sudo nvram boot-args="-v" ... set verbose mode on boot
tcpflow
sudo tcpflow -i en1 -c port 80
whois
whois -h whois.arin.net ip-address
If you want to learn more about Mac OS X Unix visit the Learning Center
click.
- For beginners: Mac OS X Unix Tutorials
- For detailed information on specific topics: Advanced Unix
- For OS X in gereral: Mac OS X Tutorials
|