bashrc Permission denied

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
chrissixxx1

bashrc Permission denied

Post by chrissixxx1 »

I have edited the file

Code: Select all

bash.bashrc
to include the

Code: Select all

export PATH="$HOME/bin:$PATH"
I had to become a superuser to do this using

Code: Select all

sudo -s
However, when I try to run a script in

Code: Select all

/bin
(the script is called WHAT!) I get

Code: Select all

bash: /home/chris/bin/WHAT!: Permission denied
.

What is the best way to resolve this, by safely changing permissions I guess. what is the best

Code: Select all

chmod
command? any other way to resolve this would be welcome.

Thanks so much!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: bashrc Permission denied

Post by gm10 »

The usual place you'd modify the path is in ~/.profile or ~/.bashrc. No superuser needed.

Check your script's permissions:

Code: Select all

ls -l /home/chris/bin/WHAT!
chrissixxx1

Re: bashrc Permission denied

Post by chrissixxx1 »

Hi

Code: Select all

rw-rw-r-- 1 chris chris 244 Apr 17 15:16 '/home/chris/bin/WHAT!'
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: bashrc Permission denied

Post by catweazel »

chrissixxx1 wrote: Mon Oct 01, 2018 5:10 am Hi

Code: Select all

rw-rw-r-- 1 chris chris 244 Apr 17 15:16 '/home/chris/bin/WHAT!'
sudo chown $USER:$USER /home/chris/bin/WHAT!
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
chrissixxx1

Re: bashrc Permission denied

Post by chrissixxx1 »

Thanks though, I just added execute and it is now working sweet! THANKING YOU !
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: bashrc Permission denied

Post by catweazel »

chrissixxx1 wrote: Mon Oct 01, 2018 5:16 am Thanks though, I just added execute
Ooops. My bad. I didn't see that missing bit.

Cheers.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: bashrc Permission denied

Post by rene »

Ideally revert the manual edit to /etc/bash.bashrc though: both ~/bin and (on Mint 19) ~/.local/bin are if they exist added onto your PATH by the default ~/.profile.
gm10

Re: bashrc Permission denied

Post by gm10 »

rene wrote: Mon Oct 01, 2018 10:58 am Ideally revert the manual edit to /etc/bash.bashrc though: both ~/bin and (on Mint 19) ~/.local/bin are if they exist added onto your PATH by the default ~/.profile.
Not if he's on LMDE3 btw, see my 2 posts here: viewtopic.php?p=1532063#p1532063
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: bashrc Permission denied

Post by rene »

A little odd, so took It as an excuse to allocate a VM to LMDE3; wanted to look at it anyway...

LMDE3 adds ~/bin to PATH in the default ~/.profile also (not ~/.local/bin as on Mint 19) which seems to say that ~/.profile not being sourced by default on LMDE3 is likely to be considered a bug; what's the point otherwise after all...

On Mint 19, supposedly 18.x+ for whichever x introduced lightdm, sourcing /etc/profile, /etc/xprofile, ~/.profile and ~/.xprofile is done by /usr/sbin/lightdm-session, itself launched from /usr/sbin/lightdm as the default "session-wrapper". LMDE3 does not have /usr/sbin/lightdm-session nor does it set "session-wrapper" to something else. From /var/log/lightdm/lightdm.log:

Mint 19: [+0.76s] DEBUG: Session pid=1054: Running command /usr/sbin/lightdm-session cinnamon-session-cinnamon
LMDE3: [+2.01s] DEBUG: Session pid=778: Running command /etc/X11/Xsession cinnamon-session-cinnamon

Seeing as how in the linked thread it is implied that ~/.profile was sourced on LMDE2 one would expect the session wrapper would've needed to be removed on purpose but giving the change in behavior between the Ubuntu and Debian edition and, apparently, even between LMDE3 and LMDE2 and the on LMDE3 at the moment "less than optimally useful" default ~/.profile, this still feels like a bug. Shall go figure out where to report it as such.

Note, I see that LMDE3 also uses gnome-terminal: a work-around is setting Edit -> Profile Preferences -> <Profile> -> Command -> "Run command as a login shell" since in that case bash sources ~/.profile itself. Not a good work-around: /etc/profile and ~/.profile are supposed to to be sourced once per session only (although with the default LMDE3 ~/.profile it's okay).

[EDIT] Finding it completely unclear where to report an issue with LMDE3; on GitHub only the beta is mentioned. If anyone who reads this wants to report the issue and knows how/where: power to him or her...
gm10

Re: bashrc Permission denied

Post by gm10 »

rene wrote: Mon Oct 01, 2018 2:47 pm
Good investigation. As I had said in the linked thread "I would think it used a different display manager and that handled that" but you tracked it down in detail. :)

As to bug reports, if you find nothing better, the catch-all is https://github.com/linuxmint/linuxmint/issues. Otherwise I would have suggested the post in the LMDE3 forums that you already did. That forum section seems to have some dev activity.
chrissixxx1

Re: bashrc Permission denied

Post by chrissixxx1 »

rene wrote: Mon Oct 01, 2018 10:58 am Ideally revert the manual edit to /etc/bash.bashrc though: both ~/bin and (on Mint 19) ~/.local/bin are if they exist added onto your PATH by the default ~/.profile.
Thanks for this advice, that sounds simpler for future scripts. I am on Mint 19. I first did this on Mint 17 a few years back after (mostly) following this, so just tried repeating the steps after a fresh install. https://askubuntu.com/questions/465109/ ... 3#465113

Just to be clear for the future- if I put the file in

Code: Select all

 ~/bin
or

Code: Select all

 ~/.local/bin
it will work by default?

Sorry for the newbieness! And thanks again.
gm10

Re: bashrc Permission denied

Post by gm10 »

chrissixxx1 wrote: Tue Oct 02, 2018 9:59 am Just to be clear for the future- if I put the file in

Code: Select all

 ~/bin
or

Code: Select all

 ~/.local/bin
it will work by default?
On a default Mint 19 install it will, correct, as long as it is flagged as executable. I won't vouch for all the modifications you may have done in the meantime. ;)
Locked

Return to “Scripts & Bash”