I have a problem using win-kex basic mode for Kali on WSL2, it has a connection fail. I can solve it running this command before launch: sudo mount -o remount rw /tmp/.X11-unix
(Source: https://stackoverflow.com/questions/70577819/how-to-fix-the-error-error-connecting-to-the-kex-server)
I want to write a NOPASSWD line on sudoers just for avoid the password request everytime just for this command. So, searching info I found this post: Add NOPASSWD in /etc/sudoers for only some specific commands. The person who asked, edited the post and shared an answer, but when I tried to use it, visudo "explodes" the screen with a lot of errors (syntax errors, mostly) and is just because of I don't understand very well all about User_Alias, Cmnd_Alias, and others sudoers configurations.
The issue is in the sudoers.d file, so I would like an example about that point for use it as guideline.
Edit:
I already created the "win_kex" file as root on /usr/local/bin/
with this:
#!/bin/bash
mount -o remount rw /tmp/.X11-unix
#
And I created another file "winkex" on sudoers.d
following the steps on the post shared before: (myusername=kapichy97)
User_Alias winkex=myusername
Cmnd_Alias WK=/home/globalisation/r
winkex ALL=NOPASSWD WK
Then added the lines on sudoers:
myusername ALL=(ALL:ALL) ALL
myusername ALL=(ALL:ALL) NOPASSWD: /usr/local/bin/winkex
sudoers.d
is NOT a file, it's a directory