-bash: /etc/profile: Permission denied in Terminal

HI,


I am keep getting following on my terminal



-bash: /etc/profile: Permission denied

-bash-3.2$



Instead of showing my computername:~ username$ its shows -bash:

Posted on Nov 10, 2017 8:59 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 11, 2017 12:00 AM

Select the text below, ctrl-click it & choose Services - Reveal in Finder


/etc/profile


A Finder window should open, with that file selected. Press Command I or File menu - Get Info


If the Sharing & Permissions section includes everyone : No Access, then click the padlock icon, enter an Admin name & password when prompted, then change it to everyone : Read Only.

3 replies
Question marked as Top-ranking reply

Nov 11, 2017 12:00 AM in response to suketuvyas

Select the text below, ctrl-click it & choose Services - Reveal in Finder


/etc/profile


A Finder window should open, with that file selected. Press Command I or File menu - Get Info


If the Sharing & Permissions section includes everyone : No Access, then click the padlock icon, enter an Admin name & password when prompted, then change it to everyone : Read Only.

Nov 11, 2017 5:38 AM in response to suketuvyas

The permissions on /etc/profile are read-only for a reason. You don't change that file, or its permissions.


What is in your Bash startup files [.bash_profile, .bash_login, .bashrc, or .profile] in your home directory that is attempting to write to /etc/profile? Nothing should. The Terminal Preferences : Shell tab : Startup : Run command should be unchecked, and so should run inside shell. Bash is the default shell without these settings.


To debug the problem, you may have to create a new folder in your home directory, and move these individual files into it, quit Terminal, and launch it again.


-bash-3.2$ mkdir ~/old_dotfiles

-bash-3.2$ mv ~/.bash_* ~/old_dotfiles; mv ~/.profile ~/old_dotfiles


To set your Terminal prompt, put the following in your new ~/.bash_profile:


MyHost="$(networksetup -getcomputername)"

export PS1='$MyHost: \w\$ '


-bash-3.2$ source ~/.bash_profile

computername: ~$


I use networksetup above so that my computername always appears in the prompt, instead of some remote DNS name when I use VPN. Here is a reference to other PS1 prompt switches.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

-bash: /etc/profile: Permission denied in Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.