Your Mac OS X user account runs with restricted privileges; there are parts of the filesystem you don’t have access to, and there are certain activities that are prohibited until you supply a password. For example, when you run the Software Update utility from System Preferences, Mac OS X may ask you for your password before it proceeds. This extra authentication step allows Software Update to run installers with superuser privileges.
You can invoke these same privileges at the command line by prefixing
a command with sudo
, a utility that prompts you
for your password and executes the command as the superuser. You must
be an Admin user to use sudo
. The user you created
when you first set up your Mac will be an Admin user. You can add new
Admin users, or grant Admin status to a user in System Preferences
→ Accounts.
What if you don’t know your administrative password? If you forgot your password, read the Mac OS Help to direct you. You might need to reboot your computer off your original Mac OS X install CD-ROM, then when you get to the installer, select the Reset Password... option from the Installer menu. The program will then prompt you for a new password and set it for your machine. Reboot again (without the CD-ROM), and you should be set forever.
You may need to use sudo
when you install Unix
utilities or if you want to modify a file you don’t
own. Suppose that you accidentally created a file in the
/Users directory while you were doing something
else as the superuser. You won’t be able to modify
it with your normal privileges, so you’ll need to
use sudo
:
% ls -l logfile.out -rw-r--r-- 1 root wheel 1784064 Nov 6 11:25 logfile.out % rm logfile.out override rw-r--r-- root/wheel for logfile.out? y rm: logfile.out: Permission denied % sudo rm logfile.out Password:******** % ls -l logfile.out ls: logfile.out: No such file or directory
If you use sudo
again within five minutes, it
won’t ask for your password. Be careful using
sudo
, since it gives you the ability to modify
protected files, all of which are protected to ensure the system runs
properly.
3.16.207.123