10

Answer on Question - I am facing error with my internet connection

Above is the link to a fix to help with a loss of connection after power saving mode. It says "open with sudo..." How does one do that if one is a complete novice and knows nothing?

Justine
  • 109
  • 2
    That means open that file with say the text editor nano but ensure you use root powers to edit it or it won't save. How, do: sudo nano /etc/NetworkManager/NetworkManager.conf. This is necessary because that file can only be edited by one with root power – George Udosen Apr 25 '17 at 10:54

2 Answers2

18

The answer you provided in the link wants you to open a file with root privileges, which can be achieved using these two commands

sudo nano /path/to/your/file.foo

in the command above you are opening file.foo in a command based text editing tool called nano, In your particular case this command should work.

sudo nano /etc/NetworkManager/NetworkManager.conf

or

gksu gedit /path/to/your/file.foo

In this command you're opening the same file with a GUI based text editor called Gedit (default on Ubuntu and Ubuntu GNOME), In your particular case, this command should work

gksu gedit /etc/NetworkManager/NetworkManager.conf

Note

Use sudo for command line programs (like nano), but use gksu or gksudo for GUI programs, which often use configuration files in the home directory. If you use plain sudo, the root user can take ownership or your user ID's configuration files and the program used that way will stop working (unless you continue using sudo). An alternative to gksu and gksudo is sudo -H


An explanation for commenting out is to add a hash # sign in front of the line, in the example you gave, the line

dns=dnsmasq

should become

#dns=dnsmasq
  • Thanks! I see now that I'm still clueless as to how to continue. To "Comment Out" do I just delete the line and then hit Alt X to exit? Sorry. I'm a total newb. – Justine Apr 25 '17 at 11:00
  • Isn't sudoedit the preferred method to edit configuration files? – jarleih Apr 25 '17 at 16:02
  • 1
    @Summet Deshmukh. No need; your answer is fine. – jarleih Apr 25 '17 at 16:12
  • 2
    @SumeetDeshmukh the editor it opens can be configured. It can be Vim, nano, gedit, sed, true, or whatever you want it to be. – muru Apr 26 '17 at 03:58
  • 1
    To make it slightly more confusing, if you are using Ubuntu GNOME (or I guess Ubuntu 17.10 when comes out, which will use GNOME) and are using the "GNOME on Wayland" session option you will not be able to use sudo -H gedit - because Wayland has stricter security policies and won't allow root to own a window in a non-root session. A workaround is to log out, then log in using the non-Wayland option. – seanlano Apr 27 '17 at 23:25
  • 1
    Use sudo for command line programs (like nano), but use gksu or gksudo for GUI programs, which often use configuration files in the home directory. If you use plain sudo, the root user can take ownership or your user ID's configuration files and the program used that way will stop working (unless you continue using sudo). An alternative to gksu and gksudo is sudo -H – sudodus May 06 '17 at 17:49
  • @sudodus could I add that exact comment as a side note in my answer? – Sumeet Deshmukh May 06 '17 at 17:51
  • 1
    Yes, if you wish :-) – sudodus May 06 '17 at 17:52
  • 1
    @sudodus whatever improves the answer, right? ;) – Sumeet Deshmukh May 06 '17 at 17:59
  • 1
    @sudodus You are right that one should not use sudo with GUI programs. However, gksu/gksudo has been deprecated and is not installed by default. I recommend using pkexec. See https://askubuntu.com/questions/156998/how-do-i-start-nautilus-as-root/868882#868882 Sumeet, feel free to add the text from and link this answer. – user68186 May 06 '17 at 18:10
  • 1
    @user68186, gksu/gksudo are still installed by default in many (all?) community flavours of Ubuntu. And they are easy to install, but you are right, it is possible to use pkexec and several people recommend it (you are not alone). But there is another recommendation too: "Do not use GUI application programs for elevated permissions. Use command line." But I know that many people prefer GUI programs. And GUI programs that must use elevated permissions have a built-in system, that prompt a password window, for example 'Synaptic'. – sudodus May 06 '17 at 18:19
  • Also see https://askubuntu.com/questions/284306/why-is-gksu-no-longer-installed-by-default/284717#284717 – user68186 May 06 '17 at 18:36
5

That means open that file with say the text editor nano but ensure you use root powers to edit it or it won't save. How, do:

sudo nano /etc/NetworkManager/NetworkManager.conf

This is necessary because that file can only be edited by one with root privilege. You will be asked for your password which you have to give so the file will open in nano editor.

After editing it to save it:

  1. ctrl + o
  2. enter
  3. ctrl + x
Jos
  • 29,224
George Udosen
  • 36,677