I have a rhel 7 server that users will be connecting to, and I created ALL the users/groups then realize I needed to add a command to /etc/skel/.bashrc such that it executes upon login, but this doesn't seem to apply to the users I've already created. I created a new user and the commands execute upon logging in, just not for the existing users. Is there a way to update/force this upon existing users?

  • Are you concerned about overwriting the existing users' ~/.bashrc files? – Jeff Schaller May 1 at 14:53
  • Interactive login shells will read /etc/profile. Add the command there. – William Pursell May 1 at 15:03
  • @JeffSchaller no they can be overwritten, is that possible? – JJC8008 May 1 at 15:16

Don't add the command to the skeleton .bashrc. Instead, put it in /etc/profile, which will be read upon startup for all interactive login (bash) shellsand non-interactive (bash) shells invoked with --login.

Even better (thanks, @glennjackman!) is to add a link in /etc/profile.d that ends with .sh with the necessary command.

  • 4
    or add a .sh file to /etc/profile.d – glenn jackman May 1 at 15:05
  • +2 to glenn jackman's suggestion. Down vote this response. Don't ever edit /etc/profile.d, but make sure that /etc/profile.d sources things in /etc/profile.d . (which rhel 7 will do, although the mechanism is a bit kludgy IMO) – William Pursell May 1 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.