EditingFilesAsRoot

Sometimes you have to edit system configuration files using the root (superuser) account. You may have to fix a broken installation guided by the support team. This little guide shows you various ways to edit files belonging to the system, which are set to be readonly for your ordinary user account.

Using a graphical text editor (easiest way)

Provided you can still access your Desktop environment, you can use this method. If you cannot, it is probably best to reboot your machine into RecoveryMode.

Ubuntu (Gnome desktop)

Press Alt-F2 (that is keep the Alt Key pressed while hitting the F2 key; Depending on your keyboard you may have to hit a key labelled something like 'F-lock' before being able to use the F keys) to bring up the 'Run Command dialogue'. Now type the following and press enter: gksudo gedit You will have to type in your login password. After pressing enter it will bring up an editor running with root privileges. You can now just open the file you have to edit. If for example you have to edit /etc/fstab you would do the following:

  1. Click on 'Open' (that will bring up a file chooser dialogue).
  2. Double-click on 'File System' in the pane on the left, labelled 'Places'.
  3. Double-click on the directory named 'etc' in the right pane.
  4. Start typing 'fstab' to search for that file
  5. Make sure the file 'fstab' is selected in the right pane and click 'Open'

You are now able to alter the file and can save it by clicking on 'Save'

Kubuntu (KDE desktop)

Press Alt-F2 (that is keep the Alt Key pressed while hitting the F2 key; Depending on your keyboard you may have to hit a key labelled something like 'F-lock' before being able to use the F keys) to bring up the 'Run Command dialogue'. Now type the following and press enter: kdesu kwrite You will have to type in your login password. After pressing enter it will bring up an editor running with root privileges. You can now just open the file you have to edit. If for example you have to edit /etc/fstab you would do the following:

  1. Click on 'File' in the menu and then on 'Open' (that will bring up a file chooser dialogue).
  2. Click on the little black arrow next to the drop-down box at the top of the window and choose 'Root Folder: /'
  3. Click on the directory named 'etc'
  4. Start typing 'fstab' (you have to type quite quickly) or scroll a bit to locate the 'fstab' file.
  5. Make sure the file 'fstab' is selected and click 'Open'

You are now able to alter the file and can save it by clicking on the little diskette (the one without a pen) or choosing 'File' and then 'Save' from the menu.

Using a Terminal window

To be written...

EditingFilesAsRoot (last edited 2008-08-06 16:34:55 by localhost)