4

To be able to connect to wifi, I use nm-applet. When i run nm-applet it puts an icon in the i3 bar where I can select the network to which I want to connect...

But there are no wifi networks... To solve this I use sudo systemctl restart network-manager.

But I want that every time I start i3, for the icon of wifi networks to be already there.

So in config, I put exec nm-applet and to show me wifi networks, I try to use sudo systemctl restart network-manager.

So, the problem is that: I can't execute commands that need sudo. How can I solve this?

Thanks in advance.

mao
  • 11,321
  • 2
  • 13
  • 29
Cristian Gira
  • 113
  • 2
  • 8
  • You're looking at the wrong thing. The fact that you need to restart the service means there's something broken in your system. Fix that instead of working around it. – Ingo Bürk Dec 23 '17 at 13:04
  • Good point. I tried that thing.. After searching 1 hour over internet about that problem, nothing worked.. But .. Before installing network-manager-gnome i installed wicd-gtk .. but this didnt worked so i deleted it .. After trying everything i didnt know what to do .. I thought that maybe some files from wicd didnt deleted .. So i run purge again .. And said that 2 files doesnt need and i used autoremove on them ( 1 of this was : wicd-daemon or something like this) .. After doing that everything works , without running restart. – Cristian Gira Dec 23 '17 at 14:04

1 Answers1

4

You could make it so that your user account does not require a password to use sudo.

Do as root:

EDITOR=vim visudo

Then add to the file:

yourusername ALL=NOPASSWD: ALL

i3 (and any other program, such as your shell), should now be able to execute commands without requiring your password. Please note that there are some security considerations for this, but on most laptops and desktops (things which would use a GUI like i3), it should be fine.

Note: This solution is dangerous and compromises the whole system's security. Removing password control is even worse than using a standard password

Slightly more secure: You can also make it so that only certain commands can use sudo:

Cmnd_Alias PASSWORDLESS = /usr/bin/systemctl restart network manager
yourusername ALL=(ALL) ALL
yourusername ALL=(ALL) NOPASSWD: PASSWORDLESS
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61
  • Hmm but i have question . Can i disable password for just one command for example ? – Cristian Gira Dec 23 '17 at 12:54
  • 1
    @CristianGira Yes you can, see this answer on the Unix Stack Exchange. https://unix.stackexchange.com/a/248495 – Fredrick Brennan Dec 23 '17 at 12:55
  • So .. i tried this and worked , thank you very much . – Cristian Gira Dec 23 '17 at 14:00
  • 3
    Don't even think of following this advice. Disabling the password for all sudo commands is very dangerous on *any* system and not at all "fine" on "most laptops and desktops". The second part of this question is way less dangerous. – mzuther Jun 26 '19 at 15:51
  • @mzuther Nonsense. If you don't run untrusted binaries it's perfectly fine. In Linux, by default, with a GUI, spyware can be installed without root; all keystrokes can be recorded, etc. You don't need root to mess with a Linux system running Xorg. This isn't wise for servers but for GUI environments it's fine for most people who aren't malware researchers. Of course I recommend, and even mentioned, `Cmnd_Alias`, but my first advice is not "very dangerous", not any more so than running untrusted binaries in the first place. – Fredrick Brennan Jun 27 '19 at 08:36
  • 1
    @FredrickBrennan Even trusted binaries may contain bugs that can be exploited. If an exploit allows an attacker to gain *user* access to the system, it does of course make a difference whether the path to privilege escalation is hindered by a password or wide open. But you don't need to think that far - a user might jump to the conclusion that the command or script he just entered might be dangerous when it *asks him for his password*. – mzuther Jun 28 '19 at 21:34