Search code examples
linuxbashterminalstartuparchlinux

Execute Scripts in /etc/profile.d/ at Startup as Root?


I'm currently using arch linux, and I have a script in /etc/profile.d/ that's successfully running at boot. However, I'm being prompted to enter my password after the first sudo command, and typing my password twice at login is a little annoying. I don't want my account to never ask for a password when executing sudo commands, if possible, just not for this startup script. Any ideas? Thanks in advance.


Solution

  • scripts in /etc/profile.d/ directory are executed as root. no need to sudo command in this scripts. but if you want to run a command as another user you should do it like below command.

    su - user -c 'command'