sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)' & sudo chmod 440 /etc/sudoers.d/$(logname)
I use the above one-liner to allow the current user to execute sudo without a password, on remotely connected hosts.
But what exactly is $(logname)?
On a local machine, echo $(logname) returns nothing, while echo $LOGNAME does, so it's not the environmental variable, although I have never seen the value to be any different on remote machines.
Also, are there any other similar $(foo) variables (or whatever they are called)?
echo $(logname)is in fact different toecho $LOGNAMEon remote hosts whensu'd into another account. – paradroid Aug 02 '19 at 14:10sudoin first place. – Archemar Aug 02 '19 at 14:51