How do I change (permanently) default shell after login on specific TTYn in Linux?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












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?







share|improve this question


























    up vote
    3
    down vote

    favorite












    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?







    share|improve this question
























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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?







      share|improve this question














      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?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 8 at 18:18









      Kusalananda

      103k13202318




      103k13202318










      asked Feb 8 at 17:44









      Anonymous

      1335




      1335




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          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 ;;
          esac


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






          share|improve this answer






















          • Sounds reasonable, going to check it out - thx!
            – Anonymous
            Feb 8 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 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 at 18:32











          • @ilkkachu Thanks for the info and for the edit!
            – Kusalananda
            Feb 8 at 18:43










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422871%2fhow-do-i-change-permanently-default-shell-after-login-on-specific-ttyn-in-linu%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          8
          down vote



          accepted










          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 ;;
          esac


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






          share|improve this answer






















          • Sounds reasonable, going to check it out - thx!
            – Anonymous
            Feb 8 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 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 at 18:32











          • @ilkkachu Thanks for the info and for the edit!
            – Kusalananda
            Feb 8 at 18:43














          up vote
          8
          down vote



          accepted










          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 ;;
          esac


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






          share|improve this answer






















          • Sounds reasonable, going to check it out - thx!
            – Anonymous
            Feb 8 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 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 at 18:32











          • @ilkkachu Thanks for the info and for the edit!
            – Kusalananda
            Feb 8 at 18:43












          up vote
          8
          down vote



          accepted







          up vote
          8
          down vote



          accepted






          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 ;;
          esac


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






          share|improve this answer














          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 ;;
          esac


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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 8 at 18:42

























          answered Feb 8 at 17:58









          Kusalananda

          103k13202318




          103k13202318











          • Sounds reasonable, going to check it out - thx!
            – Anonymous
            Feb 8 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 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 at 18:32











          • @ilkkachu Thanks for the info and for the edit!
            – Kusalananda
            Feb 8 at 18:43
















          • Sounds reasonable, going to check it out - thx!
            – Anonymous
            Feb 8 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 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 at 18:32











          • @ilkkachu Thanks for the info and for the edit!
            – Kusalananda
            Feb 8 at 18:43















          Sounds reasonable, going to check it out - thx!
          – Anonymous
          Feb 8 at 18:03




          Sounds reasonable, going to check it out - thx!
          – Anonymous
          Feb 8 at 18:03




          1




          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 at 18:11




          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 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 at 18:32





          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 at 18:32













          @ilkkachu Thanks for the info and for the edit!
          – Kusalananda
          Feb 8 at 18:43




          @ilkkachu Thanks for the info and for the edit!
          – Kusalananda
          Feb 8 at 18:43












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f422871%2fhow-do-i-change-permanently-default-shell-after-login-on-specific-ttyn-in-linu%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?