• How to loop on files with space characters?
    • SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for i in `ls -1 -d *`; do echo $i; done; IFS=$SAVEIFS
    • ls -1 -d | while read i; do echo $i; done
  • How to bulk rename files?
    • ls SomeFilePattern* | while read i; do mv $i ${i/TextToReplace/Replacement}; done
  • How to use awk to sum up various output formats?
    • dq2-size() {dq2-ls -f $1 | grep "total size: " | awk '{sum+=$3} END {printf "%.3f GByte\n", sum/1024/1024/1024}';}


  • How to write a formal letter?
    • You might wanna use the g-brief document style. Here’s an example.
  • How to write a less formal letter?
    • You can use a modified article document style. Here’s an example.
  • How to write a curriculum vitae?
    • Try using the moderncv document style. Here’s an example.


  • How to assign a fixed IP address to your PC even though it uses DHCP?
    • Edit /etc/init.d/dhcp and change the line /usr/local/sbin/dnsmasq -i eth0 -D -b -f -o $options to /usr/local/sbin/dnsmasq -i eth0 -D -b -f -o $options -Z and create a file /etc/ethers filled the mac addresses and the IP addresses you want to assign:
  • How to change your MAC address?
    • You might have to have root access, depending on the system setup.
      ifconfig eth0 down
      ifconfig eth0 hw ether 00:11:22:33:44:55:66
      ifconfig eth0 up
      ifconfig eth0 | grep HWaddr
  • How to use rsync?
    • I know it’s simple, but I keep asking myself:
      rsync -av --progress --inplace --rsh='ssh -p12345' user@sourcehost:~/dir/* user@targethost:~/.


  • How to add a separator to the dock?
    • Issue the following commands as often as you want separators in your dock:
      defaults write persistent-apps -array-add '{ "tile-type" = "spacer-tile"; }'; killall Dock
  • How to change the icon of the file/folder/application?
    • Simply open the context menu and choose “Get Info”. Select the little icon in the top left corner and paste any previously selected image/icon there. Of course you can also copy the selected image from there to another place.
  • How to encrypt your TimeMachine backup?
    • Follow these steps :)
      1) mount a writeable Apple File Sharing (AFP) volume;
      2) choose this volume as backup disk in the TimeMachine preferences;
      3) start a backup process;
      4) cancel the backup process once it has actually started to back up files and a file called HOSTNAME.sparsebundle has been created on the backup volume;
      5) rename the file to something like old.HOSTNAME.sparsebundle;
      6) convert the image to an encrypted image hdiutil convert -format UDSB -o HOSTNAME.sparsebundle -encryption AES-256 old.HOSTNAME.sparsebundle (enter a sensible password when prompted);
      7) open both images in Finder using the ‘Show Package Content’ function (right click);
      8) move the file from old.HOSTNAME.sparsebundle to HOSTNAME.sparsebundle;
      9) open the new image HOSTNAME.sparsebundle by double clicking in Finder, enter the previously given password and choose to store the password in your keychain;
      10) open the Keychain Access application and copy the key related from your login keychain to the system keychain (you’ll need admin right s for that);
      11) select the volume in your TimeMachine settings once again;
      12) start a backup;
      13) check if the created encrypted image is used;
      14) enjoy
  • How to find good tools for your Mac?
    • Look here :)
      BetterTouchTool allows to (re)define all sorts of touch command for your touch pad. DejaMeni allows to access you menu from anywhere on the screen.
  • How to mount a remote folder via sshfs?
    • I am assuming that you successfully installed MacFUSE and sshfs.
      Now you can mount a remote folder by issuing e.g.:
      sshfs -o no_readahead,noappledouble,nolocalcaches user@domain.tld:/some/remote/folder ~/some/local/folder
      In principle the same should work on linux, only the noappledouble option (which speeds up the connection enormously) can be dropped.
  • How to set up a wrapper application for Linux tools on your Mac?
    • Start the “Automator” application and choose the “application” template. From the “Utilities” library choose “Run Shell Script”. It will appear on the right side and take the final applications input as parameters, when you choose “Pass input: as arguments” on the right side. In the command box you wanna put source ~/.bashrc; /Applications/MacPorts/KDE4/ "$@" &. Now you save as “File Format: Application” in the “Application” folder and off you go.
  • How to show mails in Mail as plain text by default?
    • Issue the following command in a terminal and if needed restart Mail:
      defaults write PreferPlainText -bool TRUE
  • How to show the current path in Finder’s title?
    • Issue the following command in a terminal and if needed restart Finder:
      defaults write _FXShowPosixPathInTitle -bool YES
  • How to sync your Google contacts with Mac address book?
    • Open the address book and in the preferences choose the ‘Synchronize with Google’ option. Enter your account details and … well, in case you haven’t got an iPod or iPhone (connected to your Mac) nothing will happen!? But you can issue the following command in the terminal: /System/Library/PrivateFrameworks/GoogleContactSync.framework/Versions/A/Resources/gconsync --sync or set up a crontab job doing it for you, say every three hours: crontab -e and then paste the following: 0 */3 * * * /System/Library/PrivateFrameworks/GoogleContactSync.framework/Versions/A/Resources/gconsync --sync
  • How to tell MacOS to use a temporary IPv6 address?
    • Issue the following command in a terminal and reconnect to your network: sysctl -w net.inet6.ip6.use_tempaddr=1


  • How to split a bill between friends?


  • How to extract pages from one PDF file into another?
    • Use pdftk or try this one: pdftops input.pdf - | psselect -p1-8 -p17-31 | ps2pdf14 - output.pdf


  • How to share folder in Win XP Home?
    • Use c:\Windows\system32\shrpubw