I know that the chsh command is used to switch login shell for a user between installed shells, but it works regardless of where login comes from (tty1, tty2, ssh, ...). What I'd like to achieve is to have e.g. csh on logins from tty7 and e.g. bash on all other login sources.

Is this doable at all?


No and yes.

No, the login shell is tied to the user, not to the TTY where the user logs in. A user can only have one specific login shell.

Yes, the user may, in the login shell's initialization files, start any other program or utility depending on any condition.

For example, a user with bash as their current login shell could add something like the following to their .bash_profile file to run csh when logging in on virtual terminal 7:

case $(tty) in
    */tty7) exec csh -l ;;

exec csh -l would replace the current shell with csh, started as a login shell.

  • Sounds reasonable, going to check it out - thx! – Anonymous Feb 8 '18 at 18:03
  • 1
    omg it worked! btw, names are /dev/tty1 ... tty63 so I've changed pattern after 'in' to *tty7. SO MUCH THANK YOU! – Anonymous Feb 8 '18 at 18:11
  • The pseudo-terminals used by SSH and terminal emulators are /dev/pts/0..., the fixed virtual and serial terminals are tty1... and ttyS0... The numbers of the pts/N ones don't really mean anything, they're just allocated so that you get the next free one. – ilkkachu Feb 8 '18 at 18:32
  • @ilkkachu Thanks for the info and for the edit! – Kusalananda Feb 8 '18 at 18:43

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.