What Is a Login Shell? (With Examples)

Understanding the difference between login and non-login shells is essential when configuring your shell environment correctly — especially for tools like pyenv.


Definition

A login shell is a shell session that acts as if you just logged into the system. It reads specific config files like .zprofile or .bash_profile, which are used to set environment variables and paths.


Examples of Login Shells

1. Opening Terminal.app (first window)

2. SSH into a remote server

ssh user@host

3. Explicit login shell using zsh -l

zsh -l

Not Login Shells

1. Run zsh without -l

zsh

2. Running a shell script

./myscript.sh

Summary Table

Action Login Shell? Loads .zprofile Loads .zshrc
Open Terminal.app (first time) ✅ Yes
SSH into server ✅ Yes
Run zsh ❌ No
Run zsh -l ✅ Yes

But! Why Do People Say .zshrc Doesn’t Run During SSH?

This is a common source of confusion when working with remote servers via SSH.


Typical SSH Session

When you run:

ssh user@host

You get:

Result:
Both .zprofile and .zshrc are executed.


When .zshrc Does Not Run

When you run a remote command with SSH, like:

ssh user@host "echo $PATH"

You get:

Result:


Summary Table

Command Login Shell Interactive Shell .zprofile .zshrc
ssh user@host
ssh user@host "echo $PATH"
ssh -t user@host "zsh -i" ✅ (forced)

✅ So yes — in a typical SSH terminal session, .zshrc does run.
❌ But in SSH remote command execution, it does not.

Keep your environment setup in .zprofile, and reserve .zshrc for interactive-only configs like aliases and prompts.

Best Practice

This ensures consistent behavior across all terminal types and scripts.