In bash, which file is executed for each new interactive shell?

Prepare for the LPI Linux Essentials Exam with multiple choice questions and detailed explanations. Enhance your Linux skills and boost your confidence for the real exam!

When starting a new interactive shell in Bash, the system looks for specific files to configure the environment for that terminal session. The correct answer, which is ~/.bashrc, is executed for each interactive shell.

This file is intended to contain shell configurations and functions specific to interactive sessions, such as aliases and interactive shell options. When a terminal session is initiated, Bash loads ~/.bashrc, allowing users to customize their shell experience immediately.

The other files mentioned serve different functions; for instance, ~/.bash_profile is typically executed for login shells rather than interactive non-login shells. Similarly, ~/.profile serves as a fallback for login shells but isn’t tied specifically to Bash. The /etc/profile file applies to all users and is used for system-wide configurations but is not executed specifically per user interactive session. Thus, for an interactive shell specific to a user's setup, ~/.bashrc is the correct file being executed.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy