• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Understanding /etc/profile Configuration File in Linux

by admin

The /etc/profile file provides system-wide environment variables. This may be more effective for administrators to configure if there are settings that apply to all users.

During the initial login process for a user, the system reads the /etc/profile file first for Bash shell configurations, and then any user-specific Bash customizations are pulled from the .profile file located in the user’s home directory. The .profile file runs each time a new shell is started, whereas /etc/profile is only run at login. This approach enables administrators to define global shell settings, but still allow user-specific customizations.

Note: The global file is /etc/profile (without the “dot” as the first character of the file name), while the user-specific file is .profile, indicating that the file is hidden.

The profile file located in /etc is read automatically by everyone when they log in. This file will generally contain:

  • global or local environment variables
  • PATH information
  • terminal settings
  • security commands
  • message of the day or disclaimer information

An example of a .profile is as follows:

# cat /etc/profile
PATH=$PATH:$HOME/bin:/scripts
MAIL=/var/mail/$LOGNAME
EDITOR=emacs
export PATH MAIL EDITOR

The first line defines the paths of executable files; the second line defines the path for where incoming email messages are stored; and the third line defines the default text editor. The last line actually ensures these variables are implemented in the environment.

The /etc/profile.d/ Directory

The /etc/profile.d/ directory serves as a storage location for scripts administrators may use to set additional system-wide variables. It is recommended you set the environment variables via scripts contained in /etc/profile.d/ rather than editing the /etc/profile file directly.

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git mailinfo” Command Examples
  2. espanso: Cross-platform Text Expander written in Rust
  3. nova Command Examples in Linux
  4. Linux OS service ‘auditd’
  5. CentOS / RHEL 6 : How do I find my current runlevel?
  6. “docker volume” Command Examples
  7. dart: The tool for managing Dart projects
  8. “git symbolic-ref” Command Examples
  9. btrfs balance Command Examples in Linux
  10. iostat: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright