Score:0

Run sh script as root on Ubuntu every time a user logs-in

sh flag

I want to run a sh script as root on Ubuntu automatically, every time a user logs in. I tried to place the script in /etc/profile.d The script is being run but is run using the account of the user not as root. Is there any method to achieve this?

Score:2
jm flag

What works for me on CentOS 7 and worked in the distant past on Ubuntu is to add the line

session    optional     pam_exec.so  /etc/make_cluster_tmp

as the final line in /etc/pam.d/sshd. This is specifically for ssh logins as that is the only allowed access to the server. Add the same line to any config files you have for local access as appropriate.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.