From the computer of: qmchenry
(338 recipes)
Created: Jan 17, 2008 Updated: Jan 19, 2008
The sudo command line application allows a user to run another application as though they are another user. Most commonly (and by default) the other user is root, the superuser of the system who can do anything to any file on the box. In this case we want to launch the TextEdit application.
If you've never poked around at an application in OS X, it's interesting to take a peek. When you look at the /Applications folder in a finder window, you'll see the applications listed by name such as TextEdit. If you list the files from the command line ( ls -l /Applications ) they are actually directories, not simply files, and have a .app extension like TextEdit.app. You can change directory into one of these directories and look around. If you look in a few, you'll see that there is some standard organization in them and that should make you feel a little warmer and possibly fuzzier about this whole situation. This directory structure allows the applications to have many supporting files and resources neatly contained within them. Of interest to us is the location of the actual executable file inside the app directory. In the case of TextEdit, the path to this executable is /Applications/TextEdit.app/Contents/MacOS/TextEdit
Based on this information, running TextEdit with sudo to edit the /etc/hosts file becomes a simple task (if a rather long command line, sorry):
When you run this command from a command line (in a Terminal window), you'll be prompted for a password. The correct password is your own (the password of the user logged into OS X, also the password you provide when doing system updates and so on), not the root user's password (which doesn't exist by default, anyway).
Once you enter your password, a TextEdit window will open and the contents of the file you are editing will appear. Edit to your heart's content and save normally when you are done. Just keep in mind that most system files are protected from writing for a good reason (like if you make a mistake editing them, bad things may happen) so edit at your own risk.
Subscribe to the Tech-Recipes Newsletter
You can get tips like this delivered in your email every week!
We will never, ever sell your email address or spam you.
Related recipes:
OS X: Easily edit hidden configuration files with TextEdit
Mac OS X gain root/superuser access using sudo
OS X: Change your PATH environment variable
Mac OSX: Delete a user account
OS X Leopard: Create new user account with parental controls
Mac OS X change the default web browser
Mac OS X enable fast user switching
Setup Mac OS X host to print to Windows shared printer
Mac OS X install gcc compiler
OS X Leopard: Flush or Clear the DNS Cache
Sponsored links
Login
Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.Search
Tech Recipes
· Home
· Mac OS X
· Solaris
· Windows
· Programming
· UNIX
· Cisco
· MySQL
· Google
· Instant messaging
· Add recipes
· Leave feedback
· Recommend us
· RSS Syndication
Hot recipes
XP: Small, Free Way to Use and Mount Images (ISO files) Without Burning Them
Make XP look like Windows Vista / Longhorn for free!
How Do I Use or Open Bin, Cue, or ISO Files?
MySpace Hack: View Pictures and Comments on a Private Profile
SMS through E-Mail: Cingular, Nextel, Sprint, T-Mobile, Verizon, Virgin Mobile
Hacks to Beat Rapidshare Download Limits and Waiting Time
Vista: Should I Install 64-bit or 32-bit Version? (x64 vs x86)
MySpace: Hack to Download Any Song on MySpace
Who's Online
There are currently, 1655 guest(s) and 1 member(s) that are online.
You are Anonymous user. You can register for free by clicking here
Information
Wish to advertise with us?
All logos and trademarks in this site are property of their respective owner. The comments and forum posts are property of their posters, all the rest © 2003-2007 by QD Ideas, LLC.
Users of this site are legally bound by the Terms and conditions and Disclaimer. Do not use this web site if you do not agree with these policies.
The members, admins, and authors of this website respect your privacy.
Page Generation: 0.69 Seconds
Sat Jul 19 20:13:01 2008