You are not logged in.

#1 2013-03-22 22:21:29

ConfuseACat
Member
Registered: 2013-03-21
Posts: 18

How to Edit Files as Root

Hi everyone, I'm trying to edit my conf files but I can't save them unless I'm the root.How do you open/edit a file as root? I've searched in the forums for thread for this but couldn't find any.

Last edited by ConfuseACat (2013-03-22 22:22:56)

Offline

#2 2013-03-22 22:28:28

psli
Member
From: Santa Clara, CA
Registered: 2012-10-18
Posts: 8

Re: How to Edit Files as Root

Open the file as the root user.  If you have the "sudo" command installed

 sudo <your editor of choice> <file you are trying to edit>

Otherwise, you'll have to log in as the root user and open the file from there.

Offline

#3 2013-03-22 22:28:40

MagicSkyFairy
Member
Registered: 2013-03-14
Posts: 79

Re: How to Edit Files as Root

C'mon...  You could of easily found this on Google.

sudo nano <file>

  I'm just assuming nano would be easier for you.  You could use vim. gedit, or whatever other editor you want.


I have wasted atleast a second of your time by making you read my signature.

Offline

#4 2013-03-22 22:34:43

ConfuseACat
Member
Registered: 2013-03-21
Posts: 18

Re: How to Edit Files as Root

psli wrote:

Open the file as the root user.  If you have the "sudo" command installed

 sudo <your editor of choice> <file you are trying to edit>

Otherwise, you'll have to log in as the root user and open the file from there.

I managed to open it in root with leafpad and save it.Thanks

Offline

#5 2013-03-22 22:36:04

ConfuseACat
Member
Registered: 2013-03-21
Posts: 18

Re: How to Edit Files as Root

MagicSkyFairy wrote:

C'mon...  You could of easily found this on Google.

sudo nano <file>

  I'm just assuming nano would be easier for you.  You could use vim. gedit, or whatever other editor you want.

I'm not really sure why but when I tried to open it in nano it gave me a completely different file instead of the one I was trying to open with Leafpad.

Offline

#6 2013-03-22 22:43:45

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,838

Re: How to Edit Files as Root

$ sudoedit /etc/myconf.cfg

man sudo and look for the -e option (they're synonyms).
If you're using a GUI, then see also the askpass stuff in the same man page. Might be how gksudo works, don't know as don't have it.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#7 2013-03-23 00:01:24

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 12,943

Re: How to Edit Files as Root

I think the real problem is those of us who use arch have a paradigm that is not applicable to Archbang.

Closed.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Like you, I have no idea what you are doing, but I am pretty sure it is wrong...Jasonwryan
----
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB