Pradeep's Knowledge Hub

Curated notes on tech, health, and life — in one place.

Introduction

Shell profile files are scripts that configure your environment when a shell session starts. Understanding their execution order and purpose is essential for anyone working with UNIX/Linux systems.

Shell Types

Profile Files Overview

Common profile files include:

Execution Precedence

The order in which files are read depends on the shell type:

Shell Type Files Read
Login (bash) /etc/profile, then ~/.bash_profile or ~/.profile
Non-login (bash) ~/.bashrc
POSIX sh /etc/profile, ~/.profile

Best Practices

Forcing a Specific Shell

To change your login shell (requires root):

sudo chsh -s /bin/bash username

Without root, add this to ~/.profile:

if [ -x /bin/bash ]; then
    exec /bin/bash
fi

Key Things to Know