Profile Files
Profile files are
hidden files
(starting with a dot) in Linux/RHEL that define yourshell environment
. They control settings likeenvironment variables, aliases
(shortcuts for commands), andterminal behavior
. These files are processed in a specific order when you log in or open a terminal window.
Types of Profile Files
system-wide profiles
user-specific profiles.
System-wide Profiles (/etc
directory):
/etc/profile
: This file contains system-wide environmentvariables and settings
that apply to all users. It's executed when a user logs in.
/etc/inputrc
: This file defineskeyboard mappings and shortcuts
for the readline library, which is used by Bash for command-line editing.
/etc/bashrc
: This file contains system-wideBash configurations and functions
that are applied to all users when they start a new Bash shell.
User Profiles ($HOME
directory):
.bash_profile
(or.profile
for non-bash shells): Executed for login shells (when you first log in through a terminal). It sets permanent environment variables and aliases.
.bashrc
: Executed for all interactive shells (including login shells and subsequent terminal windows). It sets aliases and customizations that you want in all interactive shells.
Create Own Alias
- Open a text editor (e.g.,
nano ~/.profile.d/my_
alias.sh
) and add the following line, replacingcommand
with the actual command you want to shorten andalias_name
with your preferred alias:
alias alias_name='command'
- Save the file and source it using the following command (replace
my_
alias.sh
with your filename if different):
source ~/.profile.d/my_alias.sh
- Now, whenever you type
alias_name
, the actualcommand
will be executed.
Loading in Home Directory Bash Files:
When you log in or open a terminal:
/etc/profile
(if not modified)
/etc/profile.d
scripts (alphabetical order)
~/.bash_profile
(or~/.profile
)For subsequent interactive shells:
~/.bashrc
Impact Based on Shell:
Different shells have different profile files. For example, Bash uses
.bash_profile
and.bashrc
, while other shells like Zsh may use.zshrc
. Customizations made in these files will only affect the behavior of the respective shell.
/etc/skel
Directory:
This directory contains skeleton files used to create new user home directories. When a new user is added, files from
/etc/skel
are copied to the user's home directory. This ensures consistency in user environments. Common files found in/etc/skel
include:
.bash_logout
(executed when logging out)
.bash_profile
(or.profile
)
.bashrc
Subscribe to my newsletter
Read articles from Afridi Shaik directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by