31

More specifically the

/etc/apt/

folder. I need to delete some files and replace

/etc/apt/sources.list

with a newer version.

6 Answers 6

44

To open the folder as root in the grapical file manager, run the following command:

gksu nautilus /etc/apt/


If you wish to do your operations from the command line, the following command enters the intended directory and makes you root. However, you would be better off using the first method above.

cd /etc/apt; sudo -i
3
  • Thanks! That worked fine! I used the GUI version and deleted the two (very old) backup files. Apr 21, 2012 at 19:13
  • sudo -i is less typing and cleaner environmental variables ubuntuforums.org/showpost.php?p=6188826&postcount=4
    – Panther
    Apr 22, 2012 at 4:54
  • I disagree with SirCharlo that first method is better than using command line. Command line is way more powerfull.
    – OrangeTux
    Apr 22, 2012 at 12:50
15

Ubuntu 16.04 and above

sudo apt-get install nautilus-admin

Then

nautilus -q

Open Nautilus and you'll see an option Open as Administrator option in the context menu of every directory.

2
  • 1
    it is work 18.04
    – VJ Ranga
    Jun 9, 2018 at 12:25
  • Didn't seem to work in 18.04.2, although I see the context menu I'm unable to delete locked folders. Back to terminal I go.
    – Natetronn
    Feb 24, 2019 at 6:07
12

To install Open-as-Administrator in Ubuntu open Terminal (Press Ctrl+Alt+T) and copy the following commands in the terminal:

sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install open-as-administrator

After installation type this command to restart Nautilus:

nautilus -q

Reboot

enter image description here

Ubuntu 16.04

sudo apt-get install -y nautilus-admin

Then

nautilus -q
2
  • 3
    E: Unable to locate package open-as-administrator
    – Hooli
    Jun 23, 2016 at 10:19
  • Doesn't work on 16.04, same mistake as @Hooli mentioned. Would love to see it working.
    – Rav
    Sep 12, 2016 at 9:43
11

Nah ! do a simple thing first. Create a custom file manager. Its easy.

Here how you can do it:

First open gedit and paste all these:

[Desktop Entry]
Name=Nautilus
Comment=Browse the filesystem with administrator rights
Exec=gksudo nautilus
Icon=file-manager
Terminal=false
Type=Application
Categories=Application;System;

Now save the file as Nautilus.desktop on your desktop.

(desktop is the file extension).

Now Open:

   /home/your user name/.local/share/applications

and cut/paste Nautilus.desktop file into there.

Now open dash and search for "Nautilus". It will open up the default file manager with root permission. Now you can navigate to any directory and delete anything you want.

4

Just use

gksudo nautilus --or -- gksu nautilus

or any other file explorer of your choice.

See Also What is the difference between “gksudo nautilus” and “sudo nautilus”?

1
  • 2
    ..it's better to launch graphical application, with root privilege, using gksu that sudo...
    – rusty
    Jan 27, 2014 at 9:57
3

In a Terminal you can use:

sudo -e /etc/apt/sources.list

Note: If you prefer to use Graphical Software you should use gksudo in Gnome:

gksudo gedit /etc/apt/sources.list

or kdesudo in KDE:

kdesudo kate /etc/apt/sources.list

Enter your user password (not root) and you will edit file as root

2
  • 1
    or just sudo -e sudo -e /etc/apt/sources.list
    – Panther
    Apr 22, 2012 at 4:55
  • @bodhi.zazen thank you, smart option ... you are free to edit my answer for creating difference sudo -e <YourTextEditor> /etc/apt/sources.list
    – swift
    Apr 22, 2012 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .