bash: /path/.bash_aliases: Permission denied

8,366

Solution 1

Using the right command and file names ;), in your second command is a typo: ~/.bash_aliases and not ~/.base_aliases

sudo chown $USER:$USER ~/.bash_aliases

and so I can sleep peacefully (thank you @ByteCommander)

chmod 644 ~/.bash_aliases

And maybe it's time to correct the permissions for the whole folder:

sudo chown -R $USER:$USER $HOME

Solution 2

I do a similar thing in my .bashrc file. I use this compound statement and it works:

if [ -f ~/.bash_aliases ]; then
   source ~/.bash_aliases
fi

The key is the source command. I don't know if this is "bad form," but it works.

Share:
8,366

Related videos on Youtube

Vipul Bhatt
Author by

Vipul Bhatt

Working on Python, JavaScript as Jr. Application Developer @Odoo

Updated on September 18, 2022

Comments

  • Vipul Bhatt
    Vipul Bhatt over 1 year

    I don't know why this line appears first when I open my gnome-terminal.

    bash: /home/username/.bash_aliases: Permission denied
    laptop-dell:-$
    

    I tried this but still the problem remains there.

    chmod +x ~/.base_aliases
    chmod: cannot access `/home/username/.base_aliases': No such file or directory
    

    What should be the default permission of 'bash_aliases' ?
    How to fix this ?

    • Jos
      Jos over 8 years
      I suppose it doesn't literally say /path/, and that you made it up for the question, i.e. that the path is not the problem?
    • snoop
      snoop over 8 years
      Default permission should be -rw-r--r-- same as .bash_profile or .bashrc.
    • Rinzwind
      Rinzwind over 8 years
      @jos doubt it. ... Vipul: please provide the actual commands and errors. If these are it ... "path/" ... ?
    • Vipul Bhatt
      Vipul Bhatt over 8 years
      @Jos, Yes, you are right, I just made it for the question. that's not the real problem.
    • kos
      kos over 8 years
      @VipulBhatt Please just change the username if you don't want to show your real username, otherwise it ends up being rather misleading for people reading the question.
  • A.B.
    A.B. over 8 years
    @ByteCommander Yes, you're right.
  • Vipul Bhatt
    Vipul Bhatt over 8 years
    Hello @A.B., My terminal is not opening after performing these commands !!!
  • A.B.
    A.B. over 8 years
    Switch to TTY1 via Ctrl-Alt-F1 and login. What is the output of echo $USER (Back to your GUI via Ctrl-Alt-F7)
  • Vipul Bhatt
    Vipul Bhatt over 8 years
    My username, @A.B.
  • chicks
    chicks over 8 years
    why aren't the perms 755?
  • A.B.
    A.B. over 8 years
    @chicks executable rights are not necessary.
  • polendina
    polendina about 2 years
    As in my case i was using the wrong "command", as i was having $Editor instead of $EDITOR