LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I get permission to edit files? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-get-permission-to-edit-files-297814/)

Virp00 03-04-2005 10:55 PM

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?

jschiwal 03-04-2005 11:05 PM

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.

Linux~Powered 03-04-2005 11:05 PM

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.

Bruce Hill 03-04-2005 11:07 PM

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

Virp00 03-04-2005 11:11 PM

ok, so do I enter "su" then the name of the file I want to edit?

Bruce Hill 03-04-2005 11:18 PM

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...

Virp00 03-04-2005 11:20 PM

/etc/apt/sources.list

JaseP 03-04-2005 11:21 PM

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.

Bruce Hill 03-04-2005 11:25 PM

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.

Virp00 03-04-2005 11:52 PM

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 ?

Bruce Hill 03-05-2005 03:19 AM

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...

jschiwal 03-05-2005 08:35 PM

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.

screwtape 03-22-2005 07:34 PM

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:confused:

Linux~Powered 03-28-2005 11:22 AM

Quote:

I tried su to root and it still says permission denied
Try running the su command like this...

Code:

su -

screwtape 03-29-2005 12:12 PM

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.


All times are GMT -5. The time now is 07:05 AM.