0

I have a situation. We have Solaris 8 machines. For every users we have to change the shell from /bin/sh to .../sdshell. So far we have been doing it by editing the /etc/passwd file manually. Is there a better way to do so? Because I am trying to write a script to do these task. what i have tried:

useradd -s ... its not working, it says the shell is not valid. I have added the shell to /etc/shells file as well. But we can modify the password file and it works fine.

Or is there any way to change the default shell. I came across a file /usr/sdam/defadduser. but i am not sure

Please help.

Thanks

2
  • Most Linux systems have a /etc/shells listing "valid login shells". Maybe Solaris has something similar and you just need to amend it? useradd must have some reason to say the shell is not valid; you could always run useradd through strace to see which files it looks at before erroring out. Something like strace -f useradd -s ... | tee useradd.strace should get you started, but check the man page first.
    – user
    Aug 19, 2015 at 9:28
  • @MichaelKjörling I was trying to find out how to trace a exec in linux. Like check what files it writes to and reads from. THANK YOU sooo much but it seems complicated. Will find time later to go through it. Aug 19, 2015 at 9:58

1 Answer 1

1

You could use the passwd utility in particular

passwd -e may be helpful

Changes the login shell. For the files repository, this only works for the super-user. Normal users may change the ldap, nis, or nisplus repositories. The choice of shell is limited by the requirements of getusershell(3C). If the user currently has a shell that is not allowed by getusershell, only root may change it.

It should be fairly easy to script this too but you should filter the userlist so that you don't change the shell for system accounts and services etc.

1
  • Thank you bro, that worked. But one question is still in my mind, what files does useradd takes the default shell from. I mean i will have to change the shell every time, we want to change the default shell itself for all newly added user. ALso why does it rejects the shell as invalid? i tried adding it to /etc/shells, but still same error. Anyway to find that out? can strace figure that out? Aug 19, 2015 at 9:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .