Terminal: Browsing Applications

Mac OS X has an elegant way of installing and uninstalling applications, just drag an drop and application to your desired folder and you are done. But once in a while every 10 years or so you need to make a change manually but there aren’t any files to edit it was a just a single file. Well it isn’t, its actually a folder OS X just treats them differently then regular folders on you computer. If you need to edit a setting inside an application manually you can do so in command line (terminal).

To do it, open up a terminal and browse to the folder where the application is you can use the change directory command “cd”, you also don’t need to type the whole folder name just type a few characters and hit tab and it will complete it for you. Following is how Firefox looks on the inside.

$ ls /Applications/Firefox.app/Contents/
.               Info.plist      PkgInfo         Resources
..              MacOS           Plug-Ins

Most applications has the same structure when it comes to organizing files.

$ ls /Applications/Mail.app/Contents/
CodeResources              MailTimeMachineHelper.app/ Resources/
Info.plist                 PkgInfo                    version.plist
MacOS/                     PlugIns/

Files and executables are under ‘MacOS’ folder. This is where you should look for the file you are looking for. Another neat trick is, you don’t need to run an application from GUI (Graphical User Interface aka aqua). If you need to run Firefox from command line you can use…

$ /Applications/Firefox.app/Contents/MacOS/firefox-bin

Installing MySQL on OS X

Unfortunately OS X doesn’t comes with MySQL installed. To create your lamp stack on OS X, first you need to get the MySql database from MySQL AB. Installation is straight forward. But don’t forget to install the Mysql.pref which adds a preferences pane to System preferences for starting and stopping the server.

After installation to test your configuration open up a terminal and type

/usr/local/mysql/bin/mysql -u root

If you get prompt like the following. You got your Mysql database running.

$ /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51b MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


Enabling PHP in Mac OS X

Mac OS X comes with everything a web developer needs. Php, Perl, Ruby, Apache. But they are not activated by default to get your Apache to play nice with default PHP install of OS X. Follow these steps.

Open file called “httpd.conf” which is located under “/private/etc/apache2/” with your favourite editor.


Or, open up a terminal and type,

sudo vim /private/etc/apache2/httpd.conf

Move to line “around 114” at the end of LoadModule section it should print

#LoadModule php5_module        libexec/apache2/libphp5.so

Remove the # symbol to uncomment that line.

LoadModule php5_module        libexec/apache2/libphp5.so

Now apache knows about your php module. Go to you System Preferences then sharing and turn on web sharing. To test your installation create a file called hello.php with the following code snippet and place it in /Sites/

Print "Hello, World!";

If everything went fine going to in your browser should print Hello, World!.

Defeating Cooperate Firewalls

When you work at a company that won’t let you browse Facebook or any other itchy site. OS X comes with a utility called SSH (secure shell).

With it you can setup a secure encrypted channel between 2 machines and browse anything you want without IT department knowing about it.

What you need is a machine with SSH and a valid user account (Your home Mac ). Fire up a terminal on your work machine and enter.

ssh -ND 9999 -v [email protected]

This will setup the secure channel between your work machine and home machine. Anything you send to port 9999 on your local machine will be encrypted and forwarded to your home machine, from there it will travel unhindered to its destination.

Effectively by passing any Firewall or blocking rules your IT department migth have.

Now you have your secure channel things will not work magically. You need to set your browser to use the proxy you just setup.

Go to your browsers proxy settings


Preferences -> Advanced -> Proxy -> Change  Settings -> Socks proxy


Preferences -> Advanced -> Network  -> Connection settings -> Socks proxy

Set your proxy ip to and port 9999

You are set now, any thing your IT department will see is garbage going to/from your machine at home and machine at work.

For Firefox users there is a plugin called FoxyProxy which will let you use the proxy only when connecting to blacked list sites. Since proxy is a little bit slower than your local network it will speed up your overall browsing exprience.

Terminal: Stuck Trash

Ever empty your trash but stuck with a full trash icon or can not empty your trash because finder is complaining that files in it are in use.

If you want to get rid of it fire up a terminal and type

rm -rf .Trash/

A word of coution “rm -rf” will delete everything starting from the
provided folder without warning. it will not complain if the directory is
not empty. A typo like “rm -rf /” will cost you your whole drive.