Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: -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

Reply
Question marked as Solved
Answer:
Answer:

Thanks for response,


I solved it by giving 755 permission to /etc/profile


sudo chmod 755 /etc/profile

Posted on

Page content loaded

Nov 11, 2017 12:00 AM in response to suketuvyas 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 12:00 AM

Reply Helpful

Nov 11, 2017 5:38 AM in response to suketuvyas 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.

Nov 11, 2017 5:38 AM

Reply Helpful
Question marked as Solved

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

Thanks for response,


I solved it by giving 755 permission to /etc/profile


sudo chmod 755 /etc/profile

Nov 11, 2017 11:12 AM

Reply Helpful
User profile for user: suketuvyas

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