Difference between revisions of "Useful Commands"
From Wikifications
(→Rsync) |
|||
Line 3: | Line 3: | ||
-a = archive, preserve metadata | -a = archive, preserve metadata | ||
-v = verbose | -v = verbose | ||
− | -z = use compression | + | -z = use compression (most useful across slow network links) |
The following copies the local directory /some/stuff into a directory called 'stuff' in the user's home dir on the remote host. | The following copies the local directory /some/stuff into a directory called 'stuff' in the user's home dir on the remote host. | ||
rsync -avz /some/stuff user@remote.host:stuff | rsync -avz /some/stuff user@remote.host:stuff | ||
+ | |||
+ | To go in the other direction, use the form: | ||
+ | rsync -av user@host.com:'/dir/1 /dir/2' /local/path | ||
====Data rescue==== | ====Data rescue==== |
Revision as of 14:29, 4 August 2006
Contents
Rsync
Use it just like scp for maximum ease! We will add the -avz flags for
-a = archive, preserve metadata -v = verbose -z = use compression (most useful across slow network links)
The following copies the local directory /some/stuff into a directory called 'stuff' in the user's home dir on the remote host.
rsync -avz /some/stuff user@remote.host:stuff
To go in the other direction, use the form:
rsync -av user@host.com:'/dir/1 /dir/2' /local/path
Data rescue
Have a dying disk? Better get the data off before it's too late! disk1 is the culprit in this example.
dd conv=noerror,sync if=/dev/disk1 of=/Volumes/whatever/backup.dmg
Encrypted and growable (sparse) disk image
(-size specifies max growth)
hdiutil create dmg_name -size 1g -encryption -type SPARSE -fs HFS+ -volname Vault
Global find / replace
perl -pi -e 's/foo/bar/g' file perl -pi -e 's/mandir=\'\${prefix}\/man\'/mandir=\'\${prefix}\/share\/man\'/g' configure
====Disk Stats==== (zsh)
echo -n "Sum of all HFS and AFP volumes in gigs: " ; x=0 ; df -t hfs,afpfs | grep "/" \ | awk '{print $2}' | sed 's/G//g' | while read line ; do x=($line + $x); done ; echo "($x) / 1024 / 1024 / 2" | bc
Get console idle time
echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))
System Tuning
Any of these can be set manually with:
sudo sysctl -w sysctl.key=value
Place the following in /etc/sysctl.conf and reboot to boost your limits
# values increased by 2x over defaults kern.maxfiles=24576 kern.maxfilesperproc=20480 kern.maxprocperuid=200 kern.maxproc=1064
iChat Logging
defaults write com.apple.iChat Log YES defaults write com.apple.iChat Log.SecureIM YES defaults write com.apple.iChatAgent Log YES defaults write com.apple.iChatAgent Log.SecureIM YES /Applications/iChat.app/Contents/MacOS/iChat -errorLogLevel 7
Mail logging
/Applications/Mail.app/Contents/MacOS/Mail -LogActivityOnHost bar.company.com
Screen Saver
defaults -currentHost write com.apple.screensaver askForPassword -boolean true defaults -currentHost write com.apple.screensaver moduleName -string foo defaults -currentHost write com.apple.screensaver modulePath -string "~/Library/Screen Savers/foo.saver"