I ask in that way, because according to https://unix.stackexchange.com/a/46856/84749, when I start screen it's an "interactive, non-login" I'm doing. What's actually happening is I'm logging into a Bourne shell (not BASH) system, and when I do, it runs ~/.profile just fine, and sets up my aliases. But when I run screen these aliases are lost, and it doesn't seem to run ~/.profile or ~/.login or anything else I've tried.

I'm running LibreELEC on a Raspberry Pi 3.

  • @kusalananda Ok, i was mistaken then. Commented Jan 28, 2017 at 20:30

1 Answer 1


A login sh session reads the user's ~/.profile upon invocation. If the ENV variable is set to a filename after doing that, and if that file exists, the shell will use that file to further initialize the login session.

Interactive shells that are not login shells will only use $ENV if ENV is set, but will not read ~/.profile.

Non-interactive shell should not use either of these two files.

Usually, one exports ENV at the end of one's ~/.profile:

ENV="$HOME/.shrc"     # for example
export ENV            # may be done as export ENV="..." too, in most shells.

This is, for example, what bash does if it's invoked as sh or with bash --posix.

One may use these two files (~/.profile and $ENV) for whatever one wishes, but the profile is where you might want to set and export environment variables that only needs to be set once (PATH etc.), fire up any fetchmail process or other user daemon that you wish to use etc., while the $ENV file is where you set up specific things for this particular shell session/TTY, such as setting GPG_TTY (if you're using GnuPG), setting up aliases (since aliases are not inherited by subshells) etc.

The ksh93 shell uses ~/.profile and $ENV by default, but interprets $ENV in a specific way. If $ENV starts with /./ or ././, then no system-wide configuration file will be used (e.g. /etc/ksh.kshrc).

The file ~/.login is not used by sh, unless ENV is set to this filename or it is explicitly sourced from ~/.profile or $ENV.

  • I know you could export variables, but I didn't think you can do it w/aliases. According to superuser.com/a/447529/398620 you can't. In any case, I tried w/export alias l='ls -lF' in ~/.profile. Not only did it not make it to my non-login but the alias was lost in my login.
    – Opux
    Commented Jan 28, 2017 at 19:35
  • 1
    @PenguinLust No, you can't export aliases, but you can set ENV to a filename that contains your alias initializations.
    – Kusalananda
    Commented Jan 28, 2017 at 19:37

You must log in to answer this question.

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