LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2005, 11:55 PM   #1
Virp00
Member
 
Registered: Jan 2005
Posts: 81

Rep: Reputation: 15
How do I get permission to edit files?


I know this sounds really stupid, but each time I try to edit a configuration file it is usually a "(read only)" and I get a message saying "permission denied" when i try to change it in gedit. So how does one obtain permission to edit these files?
 
Old 03-05-2005, 12:05 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You need to su to root before editing a file (such as in the /etc directory).

su -

Then enter the password.
If you are using a GUI editor program like kwrite, for example, then enter 'kdesu kwrite' to start the editor. You can enter it in the 'application launcher' or by launching the 'Run Command...' menu item.

An exception would be the 'sudoers' file. You need to run the 'visudo' program to edit this file.

Last edited by jschiwal; 03-05-2005 at 12:07 AM.
 
Old 03-05-2005, 12:05 AM   #3
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 33
If you own the file then as a user...

chmod 755 yourfile

if not as root...

chmod 755 yourfile

Or if it belongs to root and it's already 755, just log in as root.

Last edited by Linux~Powered; 03-05-2005 at 12:06 AM.
 
Old 03-05-2005, 12:07 AM   #4
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
Re: How do I get permission to edit files?

Quote:
Originally posted by Virp00
I know this sounds really stupid, but each time I try to edit a configuration file it is usually a "(read only)" and I get a message saying "permission denied" when i try to change it in gedit. So how does one obtain permission to edit these files?
One thing that separates Linux from some other unsecure
OSes is the Unix tradition of multiple users.

You should have and use a normal user account, which only
has access to edit files in /home/<username> and run your
system logged in as that normal user. Only su to root when
you must do system administration.

To edit them as root, you can open a terminal, and then
either su to root, or issue something like this:
mingdao@james:~$ su -c "gedit /etc/lilo.conf"
which will launch gedit as root user, but when you save
the file and close gedit, you will not be logged in as root.

For more information issue and read
mingdao@james:~$ man su
 
Old 03-05-2005, 12:11 AM   #5
Virp00
Member
 
Registered: Jan 2005
Posts: 81

Original Poster
Rep: Reputation: 15
ok, so do I enter "su" then the name of the file I want to edit?
 
Old 03-05-2005, 12:18 AM   #6
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
Quote:
Originally posted by Virp00
ok, so do I enter "su" then the name of the file I want to edit?
Issue "man su" without quotes to read the manual page.

When you issue "su" you switch users, and if you only have
a normal user and root, and you're logged in as the normal
user, it "switches to root" by default.

If you issue it like my example of
$ su -c "gedit /etc/lilo.conf"
the c switch changes the next statement to a command, so
that your system opens your filename with gedit (my example)
and you edit it as root; but when you close the program, and
stop the command, the terminal is returned to a normal user.
Therefore, you're not logged into or running your system as
the root user.

Which files do you want to edit? Perhaps if you'll share that
with us, we might know another (even better) answer to give...
 
Old 03-05-2005, 12:20 AM   #7
Virp00
Member
 
Registered: Jan 2005
Posts: 81

Original Poster
Rep: Reputation: 15
/etc/apt/sources.list
 
Old 03-05-2005, 12:21 AM   #8
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 12.04/14.04, Scientific Linux 6.3/6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,791

Rep: Reputation: 157Reputation: 157
LOL,...

No.

The su command is the "switch user" command.
You want to type:
su root
You will be prompted for your root password. Once you do, you will have console command to do whatever you want.

However, if you are attempting to do this graphically, I'd use;
kdesu konqueror
in the run box under your KDE menu,
Then enter your root password,
Then right click on the file and edit with kwrite,
That assumes you use KDE as your primary window manager.
 
Old 03-05-2005, 12:25 AM   #9
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
Quote:
Originally posted by Virp00
/etc/apt/sources.list
So you're running Debian and setting up your mirrors.

Just use either the method that jschiwal posted concerning
something like 'kdesu kwrite' or the one I told you -- either
will work fine.

There are many methods to edit files with root priviledges,
and the important thing is NOT to run your system as root.

Last edited by Bruce Hill; 03-05-2005 at 12:26 AM.
 
Old 03-05-2005, 12:52 AM   #10
Virp00
Member
 
Registered: Jan 2005
Posts: 81

Original Poster
Rep: Reputation: 15
Thanks. I was able to edit the file. However I have one question; after I entered the command, I got this message:
" GnomeUI-WARNING **: While connecting to session manager:
Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.
*** attempt to put segment in horiz list twice"


What exactly does that mean ?
 
Old 03-05-2005, 04:19 AM   #11
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
I really don't know. This is what happens when I issue it
Code:
mingdao@james:~$ su -c "gedit /etc/lilo.conf"
Password: 

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed

(gedit:3315): GdkPixbuf-CRITICAL **: file gdk-pixbuf-io.c: line 769 (gdk_pixbuf_new_from_file): assertion `filename != NULL' failed
mingdao@james:~$
but it works.

Personally, I don't use a GUI editor, I use pico,
so I've never had to deal with such as that...
 
Old 03-05-2005, 09:35 PM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Different distro's have different settings for security. On mandrake, you can su to root and start a graphic program such as gedit or kwrite. Things are set up in PAM such that xauth is used to send a ticket allowing the use of the X windows when su'ed to root. On SuSE, it will refuse to do this. I don't remember all of the hairy details, but you just need to know that there are different security policies between different distributions of linux.

On both, you can simply start the application using 'kdesu'. A requester will come up asking for the root password.

There is another way of doing it in the future, that you may find handy. Suppose that you want to easily start up 'kwrite' as root to edit configuration files.
You can drag the 'kwrite' icon from the menu onto the task bar. Then right click on your task-bar kwrite icon and select properties. Click on the 'Application' tab. Select the 'Advanced Options...' button. In the middle area, click on the 'Run as a different user button, and enter 'root' as the 'Username'. Now in the future, clicking on the task-bar icon will bring up the dialog to enter the root password, and then start the program.
 
Old 03-22-2005, 08:34 PM   #13
screwtape
LQ Newbie
 
Registered: Mar 2005
Distribution: knoppix 3.7 and suse 9.1
Posts: 3

Rep: Reputation: 0
getting permission

This may be a little off topic :
but how do I get permission to edit /etc/lilo.conf ?
I tried su to root and it still says permission denied
 
Old 03-28-2005, 12:22 PM   #14
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 33
Quote:
I tried su to root and it still says permission denied
Try running the su command like this...

Code:
su -
 
Old 03-29-2005, 01:12 PM   #15
screwtape
LQ Newbie
 
Registered: Mar 2005
Distribution: knoppix 3.7 and suse 9.1
Posts: 3

Rep: Reputation: 0
Thanks for the advice .......i tried that just now it still doesn't work but i guess it doesn't matter now.
I re installed using the grub.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vi to edit files?? Andknig Linux - Newbie 2 04-22-2005 05:18 AM
How do I edit .ini files? Virp00 Linux - General 1 01-15-2005 11:54 AM
how do i edit files???? zexter Mandriva 9 11-06-2004 11:02 AM
Edit files help flira Linux - Newbie 2 05-27-2004 10:31 PM
How to Edit .img files safrout Linux - Software 2 08-13-2003 08:54 AM


All times are GMT -5. The time now is 02:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration