Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Ubuntu Linux and am new to Linux. When I try to try to edit some files it requires root privileges.

Following command gives a permission error:

echo "xyz" > abc.txt

But using sudo echo "xyz" > abc.txt works

I want to do the same thing from UI. So how can I do it?

Also some files like hosts and hostname cannot be edited. Any clues on this? I guess they are read only. How can i make them writable?

share|improve this question

migrated from May 3 '12 at 14:12

This question came from our site for system and network administrators.

I can guess some reasons for the downvotes, but the poster has a legitimate (if naive and/or off-topic) question. If you feel the need to downvote it, please add some constructive criticism in a comment so they can ask better questions next time. – pjmorse May 3 '12 at 13:26
I don't believe it. If echo "xyz" > abc.txt fails, sudo echo "xyz" > abc.txt will also fail – stew May 3 '12 at 13:35

The files appear as read-only because you don't have enough permissions to modify them. If you want to use the GUI, you run your editor from command prompt like:

sudo gedit
share|improve this answer

I don't think this is necessarily a serverFault topic, more like superuser...but you should be able to change permissions via chmod.

I'm assuming you're the file owner, in which case

sudo chmod u=rwx

MIGHT (emphasis on the might) work to give you permission to mess with the file outside of sudo. the u+rwx specifies that the 'user'(owner) of the file gets the r, w, and x permissions (read write execute).

I'm by no means a linux expert, but that seems like it should work. If you require more help, superuser would be the better stack exchange site to ask on, as serverfault is more for server issues.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.