Difference between revisions of "Useful Commands"

From Wikifications
Jump to: navigation, search
Line 1: Line 1:
'''Data rescue'''
+
====Data rescue====
 
Have a dying disk? Better get the data off before it's too late! disk1 is the culprit in this example.  
 
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
 
  dd conv=noerror,sync if=/dev/disk1 of=/Volumes/whatever/backup.dmg
  
'''Encrypted and growable (sparse) disk image''' (-size specifies max growth)
+
====Encrypted and growable (sparse) disk image====
 +
(-size specifies max growth)
 
  hdiutil create dmg_name -size 1g -encryption -type SPARSE -fs HFS+ -volname Vault
 
  hdiutil create dmg_name -size 1g -encryption -type SPARSE -fs HFS+ -volname Vault
  
'''Global find / replace'''
+
====Global find / replace====
 
  perl -pi -e 's/mandir=\'\${prefix}\/man\'/mandir=\'\${prefix}\/share\/man\'/g' configure
 
  perl -pi -e 's/mandir=\'\${prefix}\/man\'/mandir=\'\${prefix}\/share\/man\'/g' configure
  
'''Disk Stats''' (zsh, all one line)
+
====Disk Stats==== (zsh, all one line)
 
  x=0 ; df -t hfs,afpfs | grep "/" | awk '{print $2}' | sed 's/G//g' | while read line ;\
 
  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
 
  do x=($line + $x); done ; echo "($x) / 1024 / 1024 / 2" | bc
  
'''Get console idle time'''
+
====Get console idle time====
 
  echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))
 
  echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))

Revision as of 19:50, 31 December 2005

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/mandir=\'\${prefix}\/man\'/mandir=\'\${prefix}\/share\/man\'/g' configure

====Disk Stats==== (zsh, all one line)

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))