Edit locked file in Mavericks
Starting with Mac osx lion it is not possible to open the system files in textedit using terminal. Previous to lion it worked like this and you could be able to edit the system files like
hosts files or
httpd.conf file using your guid text editor like textedit.
sudo open -t /etc/hosts
Here are some alternatives on mavericks
Using terminal itself to edit text files. But its hard to find the text that you want to edit and save it but it works perfectly.
sudo nano /etc/hosts
With TextMate you can edit and save any sytem locked file in GUI mode. But TextMate is not free.
Type in terminal the following command to open TextMate using root user and edit any files.
sudo open -a /Applications/TextMate.app /etc/apache2/httpd.conf
Using free TextWrangler
Using free TextWrangler you can easily edit system locked files. Just open the TextWrangler from the terminal using sudo command and start editing. TextWrangler will ask you for Administrator login info.
sudo open -a /Applications/TextWrangler.app /etc/apache2/httpd.conf