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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. iw Command Examples in Linux
  2. btrfs rescue Command Examples in Linux
  3. Understanding The /proc File System
  4. firewall-offline-cmd Command Examples in Linux
  5. flatpak: command not found
  6. How to Compress and Decompress .bz2 files in Linux Using bzip2 Command
  7. Understanding How an Email System Works
  8. CentOS / RHEL 7 : How to check the status of a service using systemd
  9. How to enable/disable wayland on Ubuntu 20.04
  10. pwdx Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright