Skip to main content
Solved

Change default shell for user


dlondon
Forum|alt.badge.img+14
  • Honored Contributor
  • 375 replies

Wondering if there is a way to change the default shell for all users?

I see that a user can themselves type 

chsh -s shellname

e.g. csh -s zsh

but they have to authenticate.  I could run a script at login, once, but not sure how to tackle the need to provide their password.

Also, I'd like to change the system so that new users have the newer shell (zsh)

Best answer by dlondon

This will change the above directory binding.

/usr/sbin/dsconfigad -shell /bin/zsh

 

View original
Did this topic help you find an answer to your question?

5 replies

dlondon
Forum|alt.badge.img+14
  • Author
  • Honored Contributor
  • 375 replies
  • February 27, 2024

I think this is what I need to edit on the existing AD binding on a machine

I can change the settings in Jamf for future binding.  Just not sure where this lives on the local machine


dlondon
Forum|alt.badge.img+14
  • Author
  • Honored Contributor
  • 375 replies
  • Answer
  • February 27, 2024

This will change the above directory binding.

/usr/sbin/dsconfigad -shell /bin/zsh

 


Forum|alt.badge.img+17
  • Valued Contributor
  • 231 replies
  • February 27, 2024

This seemed to work for existing users:

 

dscl . -create /Users/𝘴𝘩𝘰𝘳𝘵𝘶𝘴𝘦𝘳𝘯𝘢𝘮𝘦 UserShell /bin/zsh

 

 


dlondon
Forum|alt.badge.img+14
  • Author
  • Honored Contributor
  • 375 replies
  • February 28, 2024

Thanks @joshuasee  - appreciate the help :)


dlondon
Forum|alt.badge.img+14
  • Author
  • Honored Contributor
  • 375 replies
  • March 20, 2024

So it turns out that Active Directory has a user attribute called loginshell.  That attribute overwrites the one in Directory Utility.  I ended up just making a login script that runs once per user per machine

#!/bin/bash # ChangeDefaultShellForUser.bash # Set this to run once per user at login on the target machine # Doing it this way because the AD user attribute loginshell is overiding our domain binding settings # Intended for computer labs # 2024-03-20 David London # In a jamf policy would enter /bin/zsh for the $4 parameter NewShell=$4 currentUser=$(stat -f%Su /dev/console) echo "Current default shell for $currentUser:" /usr/bin/dscl . -read "/Users/$currentUser" UserShell echo /usr/bin/dscl . -create "/Users/$currentUser" UserShell "$NewShell" echo "New default shell for $currentUser:" /usr/bin/dscl . -read "/Users/$currentUser" UserShell exit 0

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings