Docs/Basic tasks/Editing configuration files
From Mandriva Community Wiki
Often, in the course of fixing a problem with Mandriva Linux or making a configuration change, you will need to edit a system configuration file: a file that, as a normal user, you do not have the rights to access. This page explains how you can do this.
[edit] The graphical method
From Mandriva Linux 2007 Spring onwards, you can install a package which will make it easy to edit system configuration files without having to use a terminal. To access this package, you must first configure your system to use Internet package repositories: see Installing and removing software for help with this. Once you have the /contrib repositories configured, you can install gedit-root. This will add a menu entry - named Text editor (administrator) - to the system menus (in the More Applications / Editors menu). Clicking on this entry will prompt you for the administrator (root) password, and then open a text editor which will be able to open and save any file on the system. After installing the package, there will also be an option named Open with Text editor (administrator) in the right-click menu when you right click on a text or configuration file, which will allow you to edit the file with administrator privileges.
Alternatively, you can install openasroot-kmenu - it is also in the contrib repository, so follow the instructions above to enable this repository. This adds actions to the context (right-click) menu in KDE which allow you to perform certain actions with administrator privileges on certain types of file.
- Right-click on an executable: the menu entry Actions > Launch as root will run the executable with administrator privileges
- Right-click on an text file: the menu entry Actions > Edit as root will let you edit the file with administrator privileges
- Right-click on a folder: the menu entry Actions > Open as root will open the folder in a new window which has administrator privileges
[edit] The console method
For earlier Mandriva Linux releases, or if you do not wish to use the graphical method, you need to use a terminal with administrator (root) privileges. You can use the su command from a terminal to grant yourself these privileges. First, open a terminal: open the system menus (by clicking on the star at the bottom left hand corner of the screen), highlight the System menu entry, highlight the Terminals menu entry, and click on Terminal program (if you use KDE) or Terminal (if you use GNOME). A terminal window will open and you will see a prompt like this:
[username@localhost Desktop]$
Type su, and hit enter. You will see this:
[username@localhost Desktop]$ su Password:
Type in your administrator (root) password (you configured it during installation), and hit enter. Nothing will be printed on the screen while you are typing. This is normal. If you enter the password correctly, you will see this:
[username@localhost Desktop]$ su Password: [root@localhost Desktop]#
If you enter it incorrectly, you will see this:
[username@localhost Desktop]$ su Password: su: incorrect password [username@localhost Desktop]$
In this case, run su again, and try again. Once you have correctly entered the password, you have administrator (root) privileges: this is the meaning of the # that replaced the $. Any command you now run will keep - 'inherit' - those privileges. So you can run a graphical text editor and use it to edit the file. So, if you use KDE, type kwrite and hit enter. If you use GNOME, type gedit and hit enter. A text editor will open, and you can use it to open, edit and save the file you need to edit. After doing so, quit the text editor, and from the console, type exit and hit enter. You should see this:
[root@localhost Desktop]# exit exit [username@localhost Desktop]$
This means you have returned to having just your regular user privileges: the $ has replaced the #. If you wish, you may run exit again to close the terminal.