Netatalk
This is needed if you want to serve AFP from your linux machine.
$ sudo aptitude update
$ mkdir -p ~/src/netatalk
$ cd ~/src/netatalk
$ sudo aptitude install cracklib2-dev libssl-dev
$ apt-get source -t testing netatalk
$ sudo apt-get build-dep netatalk
$ cd netatalk-2.X.X
$ sudo DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -us -uc
$ sudo debi
$ echo "netatalk hold" | sudo dpkg --set-selections
After that, you’ll have a file server capable of AFP for OSX systems.
.AppleDouble Files
If you have problems with .AppleDouble files in your server, wherever you installed the netatalk binaries, there’s a script called cleanappledouble.pl which will clean up any orphaned entries in .AppleDouble directories.
$ ./cleanappledouble.pl --help
Usage: ./cleanappledouble.pl [-r] [-v] directory [directory ...]
Scans each directory and:
-
removes orphaned .AppleDouble files (from
/.AppleDouble) -
fixes permissions on .AppleDouble files to match corresponding data file (minus x bits)
-
fixes owner/group of .AppleDouble files to match corresponding data file (root only)
If you need to delete the folders, you can try something like
find . -name \.AppleDouble -exec rm -rf {} \;
Create .iso images on OSX
From the Command Line:
Show Status
localhost$: drutil status
Vendor Product Rev
MATSHITA DVD-R UJ-857E ZF1E
Type: CD-ROM Name: /dev/disk1
Sessions: 1 Tracks: 1
Overwritable: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
Space Free: 00:00:00 blocks: 0 / 0.00MB / 0.00MiB
Space Used: 46:37:04 blocks: 209779 / 429.63MB / 409.72MiB
Writability:
Unmount Disk
localhost$: diskutil unmountDisk /dev/disk1
Unmount of all volumes on disk1 was successful
Create disk Image
localhost$: dd if=/dev/disk1 of=image.iso
963672+1 records in
963672+1 records out
493400208 bytes transferred in 220.611582 secs (2236511 bytes/sec)
Mount Disk Image
localhost$ hdid image.iso
Change Background Login Image
cd /System/Library/CoreServices
sudo mv DefaultDesktop.jpg DefaultDesktop_org.jpg
sudo cp /Path/to/picture/you/want/to/use/image.jpg DefaultDesktop.jpg
ImageMagick
Resize Image
$: convert -resize 50% image.png small.png
ImageMagick Command Line Options are here
Identify image information via CLI
$: identify -format '%wx%h' 001_small.jpg
** 399x262 (result) **
Adding network routes in OSX
route version in OSX is a bit old, and does not work same as LINUX. Adding a new route in your Mac is as follows:
route -n add -net 12.0.0.0 192.168.1.200 255.0.0.0
This adds network access to 12.0.0.0 network through gateway 192.168.1.200 with 255.0.0.0 netmask.
Now we just want to route to a certain IP address.
route add -host 12.11.10.9 192.168.1.200 255.255.240.0
This IP is not accessible through the default network gateway, so we add this route over another gateway to access it.
GeekTool
TOP
top -ocpu -F -R -l2 -n20 | tail -n21 | grep -v `0.0% ..:` | cut -c 1-24,25-29,103-112
STATUS
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 }' | sed -e 's/.$//g'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
NET CONNECTION
File: ~/bin/ipaddress.sh
#! /bin/bash
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen0" != "" ]
then
echo "Ethernet : $myen0"
else
echo "Ethernet : INACTIVE"
fi
myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "myen1" != "" ]
then
echo "AirPort : $myen1"
else
echo "Airport : INACTIVE"
fi
EXTERNAL IP
echo External IP: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/:]//g'`
CALENDAR
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e) / $(date +%e | sed 's/./#/g') /"
SYSINFO
uptime | awk '{printf "Uptime: " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {printf "RAM : " $8 ", " }' ; top -l 2 | awk '/CPU usage/ && NR > 5 {print $6, $7=":", $8, $9="user", $10, $11="sys", $12, $13}'
TimeMachine LOG view
grep backupd /var/log/system.log | sed s_/System/Library/CoreServices/__g | tail -n 3
Networked TimeMachine Backup process
- Create TM backup disk image. First get your MAC address from your card and create disk image with hdiutil.
$ ifconfig en0 |grep ether
$ hdiutil create -size 120g -fs HFS+J -volname "Jacintosh Backup" jacintosh_000008000469.sparsebundle
-
Enable Unsupported Network Volumes
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
-
Mount the NAS share the sparsebundle and copy sparsebundle image to it.
rsync -avE jacintosh_000008000469.sparsebundle /Volumes/TMBackups/.
-
umount and mount again remote sparsebundle.
-
Go to TimeMachine and select new remote image disk.
-
Create your first backup.
-
If you think Time Machine backs up too often
sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800
Start Time Machine backups now in Terminal. **
tmutil startbackup
Start screen sharing remotely in Terminal
Assume you want to do some work on a remote Mac via 10.5’s Screen Sharing, but you forgot to enable Screen Sharing before you left the remote Mac. You’re now a good distance away, and apparently stuck. Fortunately, because the screen sharing system uses launchd to monitor its state, enabling and disabling is as simple as adding a file in the remote Mac’s /Libary/Preferences folder. (Note that you’ll need to be able to login to the remote Mac via ssh to run these commands on that Mac.)
$ cd /Library/Preferences
$ echo -n enabled > com.apple.ScreenSharing.launchd_
To disable screen sharing:
$ cd /Library/Preferences $ rm com.apple.ScreenSharing.launchd_
If you have a Finder window open with the remote Mac selected in the Shared section, you’ll even note the icon for Screen Sharing coming and going as you do this.
#!/bin/bash
LAUNCHD_FILE=/Library/Preferences/com.apple.ScreenSharing.launchd
if !( groups | grep -q admin );
then
echo "Must be admin to run this script" exit 1 fi case "$1" in status)
if
[[ -e $LAUNCHD_FILE ]];
then echo 'Screen Sharing is enabled';
exit 0;
else echo 'Screen Sharing is not enabled';
exit 1 fi ;; start)
echo -n enabled > $LAUNCHD_FILE ;; stop) rm -f $LAUNCHD_FILE ;; *)
echo "Usage: $0 {status|start|stop}"
esac
Now, to add a bunch of buttons that are also found in Apple Remote Desktop, type in this command (it is one line):
defaults write com.apple.ScreenSharing \'NSToolbar Configuration ControlToolbar' -dict-add 'TB Item Identifiers' \'(Scale,Control,Share,Curtain ,Capture,FullScreen,GetClipboard,SendClipboard,Quality)'
Useful tips
RSYNC in OSX
The rsync utility offers substantial improvements in performance when making backups of large file hierarchies.
To copy extended attributes with it, you must specify the -E flag. You can use rsync across a network to make centralized backups.
-E is just for the Mac OS X version of rsync 2.6.9, in the rsync 3 family, it is replaced by the -X flag.
Rebuild Spotlight index
sudo mdutil -s / (shows status)
sudo mdutil -i on / (activation)
rm -rf /.Spotlight*
sudo mdutil -E / (rebuild)
Little Script for autoindexing.
#!/bin/sh
sleep 1 # let things settle down a bit
if mdutil -s "/Volumes/stuff" | grep -q "Indexing Disabled" ;
then
mdutil -i on "/Volumes/stuff" >/dev/null
fi
Get Mac serial number through command line
ioreg -l | awk '/IOPlatformSerialNumber/ { print $4; }'
Get Mac Hardware info through command line
system_profiler | less
Dashboard Disable
defaults write com.apple.dashboard mcx-disabled -boolean YES
DNS Flush cache**
sudo dscacheutil -flushcache