Becoming a Super User

You have already experienced becoming a super user while using the Aqua GUI. Whenever you try to install an application or an update, you will be asked to enter your username and password. Although you’ve already logged in, the “Authentication Manager” is challenging you to prove that you are an administrator. This is one of the ways that Apple allows users to administrate their own machine.

The “sudo” application is included so you can become a super user on the command line. If you try to run an application or see the contents of a file or folder that belongs to root, you will get an error like “permission denied”.  

I’ll tell you a secret. Built into Mac OS X is the Apache Web Server. Unlike “Personal Web Sharing”, your Mac can become a fully functional web server. In order to enable it you’ll have to edit a file while becoming a super user.

Let’s start by opening the Terminal application. (Applications => Utilities => Terminal) At that command prompt (%), we’ll change directories to “etc”.

% cd /etc

“etc” is a system directory that contains, among other things, configuration files. The mystery here is that one of the files in “etc” enables the Apache Web Server.   Last month I showed you the “fgrep” program, which allows us to find text strings inside files. We’ll look for “WEB” in “etc”:

% sudo fgrep “WEB” *

Unlike last month, this time we’re going to precede the “fgrep” with “sudo” so that we’re running the application as a super user. “sudo” , or “super-user do”, allows us to assume a high level of authority to search through the files. The first time you use “sudo”, you’ll get a short lecture about respecting others and most importantly “Think before you type.”

After you enter your password and hit “Return”, your program will run, and you will see something like this:

fgrep: cups: Is a directory
fgrep: httpd: Is a directory

The file we’re looking for is “hostconfig”. In order to activate the Apache Web Server we’ll change the “NO” to “YES”. Let’s use the “ed” program, but we’ll have to precede the command with “sudo” again. If we don’t start with “sudo”, we won’t have permission to save the file.

First let’s backup the file. Type “sudo cp hostconfig hostconfig.backup” to copy the original just in case! You can also use “ls” to confirm that you made a copy. Then we’ll edit the file with “sudo ed hostconfig”.

Begin by printing the file to screen with “1,$p” which will print (p) the file from line “1” to the end ($).


Type “/WEB”, to jump to the line that contains the string “WEB”.   Next type, “s/NO/YES/p” to substitute (s) “NO” with “YES”, and then print (p) the line.


At any time, you can type “f” to confirm the name of the file you’re editing. You should also use “1,$p” to confirm your changes before you save the file by writing   and quit. Type “w” to write the file and “q” to quit.

You have now enabled the Apache Web Server. Open your browser, and enter “localhost” or “” in the URL and you will get the default Apache page. This is because you became a super user with “sudo”. Now you can put on your “HTML” hat and start writing your web site.