So I have some experience with linux and I was always wondering if it is possible to modify the terminal so that it executes a different interpreter (like python) rather than the default shell interpreter (like sh or bash).

(Note that this is not just "Where do I change my shell?" or "How to change from csh to bash as default shell". This is about running things that are not shells, per se, but are interpreters. I give python as an example to make things clearer, but I could have easily said php or any other interpreter.)

Is this possible, and if so, how would I do it?

  • And that's what the referred question explains so you can add the path to /etc/shells and use chsh to change the interpreter to a user or is that wrong ? – Hamdi Jun 4 '20 at 13:13
  • 2
    That is not wrong but there are reasons why python is not listed in /etc/shells. These reasons don't go away by just adding it. Python is not prepared to be a login shell. You lose the environment setup. – Hauke Laging Jun 4 '20 at 13:31
  • I agree that it is not a duplicate, given that it's not asking about substituting one shell for another. But it is rather broad, as it hasn't specified whether this means changing what a GUI terminal emulator runs or changing what is run after TUI login on a virtual or real terminal. The problem is the ambiguous "modify the terminal". Has the questioner made the usual far-too-often-made error of conflating terminals with something else? Or does xe really mean modifying the settings of a terminal emulator program? – JdeBP Jun 4 '20 at 16:44

As has been mentioned in the comments and the first answer: You can change only (at least with chsh) to those shells which are listed in /etc/shells. If you manually force a different shell into /etc/passwd (or a different user data base) then it may be run by login (I haven't tried that) but that would not solve the problems which are the reason for e.g. python not being listed in /etc/shells.

A login shell has certain tasks, mainly setting up the environment for the user. Thus only login shells read /etc/profile.

possible compromise

You could create a link (symlink or hard link, I currently habe no opinion which is better) to a regular shell like

cd /bin
ln -s bash bash-python

and add /bin/bash-python to /etc/shells and set it as default shell for a user. In /etc/profile (or /etc/bash.bashrc) you can check whether the shell has been started with this name and execute python:

[[ $0 =~ bash-python ]] && exec python
# or
[[ $0 =~ bash-python ]] && python

I am not convinced yet which is better. Maybe the variant without exec for wtmp logging but I am not sure whether that is done by the login shell; maybe it's PAM after the login shell exists.

  • A login shell is not required to be a prompt-read-execute-loop program, or have dealings in environment variables, and over the years there have been many people who have set up all sorts of things as login shells, from bespoke menu systems through dedicated single applications to BBSes and UUCP. – JdeBP Jun 5 '20 at 6:22

lets you switch your login-shell (restrictions apply, see also /etc/shells)


Yes, it’s possible. One approach is to configure your terminal appropriately; the specifics depend on your terminal emulator.

In GNOME Terminal, you’d edit the command in whatever profile you want:

GNOME Terminal preferences showing the Command tab

This allows you to open terminals with the chosen command instead of your default shell:

GNOME Terminal running IPython

This is less invasive than changing your default shell outright (which would also require administrative assistance if you’re not using one of the shells in /etc/shells).

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.