{
	"id": "2243e718-87c8-48bc-a977-82e54da24193",
	"created_at": "2026-04-06T00:18:30.539801Z",
	"updated_at": "2026-04-10T13:11:26.002942Z",
	"deleted_at": null,
	"sha1_hash": "39f73b6795aef74876db26db6462cf468725ed58",
	"title": "Understanding a little more about /etc/profile and /etc/bashrc",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 55084,
	"plain_text": "Understanding a little more about /etc/profile and /etc/bashrc\r\nBy Benjamin Cane\r\nArchived: 2026-04-05 14:47:14 UTC\r\nThe Wayback Machine -\r\nhttps://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/\r\nRecently I was working on an issue where an application was not retaining the umask setting set in the root users\r\nprofile or /etc/profile . After looking into the issue a bit it seemed that the application in question only applied\r\nthe umask setting that was set in /etc/bashrc and would not even accept the values being the applications own\r\nstart scripts.\r\nAfter doing a bit of researched I learned a little bit more about what exactly these files do, the differences between\r\nthem and when they are executed. I figured this would be a good thing to share as it is not a topic that comes up\r\nvery often.\r\nWhat is /etc/profile used for?\r\nIf you have been using Linux for a while you are probably familiar with the .profile or .bash_profile files\r\nin your home directory. These files are used to set environmental items for a users shell. Items such as umask, and\r\nvariables such as PS1 or PATH .\r\nThe /etc/profile file is not very different however it is used to set system wide environmental variables on\r\nusers shells. The variables are sometimes the same ones that are in the .bash_profile , however this file is used\r\nto set an initial PATH or PS1 for all shell users of the system.\r\n/etc/profile.d\r\nIn addition to the setting environmental items the /etc/profile will execute the scripts within\r\n/etc/profile.d/*.sh . If you plan on setting your own system wide environmental variables it is recommended\r\nto place your configuration in a shell script within /etc/profile.d .\r\nWhat is /etc/bashrc used for?\r\nLike .bash_profile you will also commonly see a .bashrc file in your home directory. This file is meant for\r\nsetting command aliases and functions used by bash shell users.\r\nJust like the /etc/profile is the system wide version of .bash_profile . The /etc/bashrc for Red Hat and\r\n/etc/bash.bashrc in Ubuntu is the system wide version of .bashrc .\r\nhttps://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/\r\nPage 1 of 3\n\nInterestingly enough in the Red Hat implementation the /etc/bashrc also executes the shell scripts within\r\n/etc/profile.d but only if the users shell is a Interactive Shell (aka Login Shell)\r\nWhen are these files used?\r\nThe difference between when these two files are executed are dependent on the type of login being performed. In\r\nLinux you can have two types of login shells, Interactive Shells and Non-Interactive Shells. An Interactive shell is\r\nused where a user can interact with the shell, i.e. your typical bash prompt. Whereas a non-Interactive shell is used\r\nwhen a user cannot interact with the shell, i.e. a bash scripts execution.\r\nThe difference is simple, the /etc/profile is executed only for interactive shells and the /etc/bashrc is\r\nexecuted for both interactive and non-interactive shells. In fact in Ubuntu the /etc/profile calls the\r\n/etc/bashrc directly.\r\nInteractive Shell vs Non-Interactive Shell\r\nTo show an example of an interactive shell vs a non-interactive shell I will add a variable into both\r\n/etc/profile and /etc/bash.bashrc on my Ubuntu system.\r\n/etc/profile\r\n# grep TEST /etc/profile\r\nexport TESTPROFILE=1\r\n/etc/bash.bashrc\r\n# grep TEST /etc/bash.bashrc\r\nexport TESTBASHRC=1\r\nInteractive Shell\r\nThe below example is showing an interactive shell, in this case both the /etc/profile and /etc/bash.bashrc\r\nwas executed.\r\n# su -\r\n# env | grep TEST\r\nTESTBASHRC=1\r\nTESTPROFILE=1\r\nNon-Interactive Shell\r\nIn this example we are running a command through SSH that is non-interactive; because this is a non-interactive\r\nshell only the /etc/bash.bashrc file is executed.\r\nhttps://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/\r\nPage 2 of 3\n\n# ssh localhost \"env | grep TEST\"\r\nroot@localhost's password:\r\nTESTBASHRC=1\r\nConclusion\r\nIn my case the applications child processes are not recognizing the umask value set in /etc/profile but do\r\nrecognize the value in /etc/bashrc . This tells me that the subprocess is starting as a non-interactive shell. While\r\nthe suggested route of modifying environmental variables is to add a shell script into /etc/profile.d in my case\r\nit is better to set the umask value in the /etc/bashrc .\r\nSource: https://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbas\r\nhrc/\r\nhttps://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/\r\nPage 3 of 3",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"origins": [
		"web"
	],
	"references": [
		"https://web.archive.org/web/20220316014323/http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/"
	],
	"report_names": [
		"understanding-a-little-more-about-etcprofile-and-etcbashrc"
	],
	"threat_actors": [],
	"ts_created_at": 1775434710,
	"ts_updated_at": 1775826686,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/39f73b6795aef74876db26db6462cf468725ed58.pdf",
		"text": "https://archive.orkl.eu/39f73b6795aef74876db26db6462cf468725ed58.txt",
		"img": "https://archive.orkl.eu/39f73b6795aef74876db26db6462cf468725ed58.jpg"
	}
}