The following are the steps I performed:

  1. SSH to a CentOS 6.x machine that is in the local network with command

ssh root@

  1. Enter the root user password
  2. I was able to successfully login to the machine, but I only get the bash terminal instead of the root user terminal.

Last login: Wed Apr 25 18:04:32 2018 from

-bash: /root/.bashrc: Permission denied


I am trying to understand what is the problem here.

Additional info:

  1. I am able to login to any other machine in the local network without having this issue.
  2. Also, from the bash terminal, I am able to switch to the super user account with "su" command.

Few command executed on the remote machine which I'm trying to login and its output.

-bash-4.1# whoami

-bash-4.1# stat /root/.bashrc
File: `/root/.bashrc'
Size: 221           Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d  Inode: 32510289    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/      root)
Access: 2018-04-26 10:09:04.206129757 +0530
Modify: 2018-04-25 18:04:59.354903860 +0530
Change: 2018-04-25 18:04:59.389903855 +0530

-bash-4.1# file /root/.bashrc
/root/.bashrc: ASCII text

-bash-4.1# lsattr /root/.bashrc
-------------e- /root/.bashrc

Bashrc content:

#/bin/bash -x

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
export PATH="/opt/postgres/postgresql:$PATH"

Can anyone please help me understand this?

  • You might need to execute the ssh comand as root too. su ; ssh root@ or sudo ssh root@ You should also consider using privates key instead of password authentication (for your own security): digitalocean.com/community/tutorials/…
    – kcdtv
    Apr 25, 2018 at 14:14
  • Please try these commands that can help identify the issue (but won't fix the issue) and let us know what the outputs are: whoami, stat /root/.bashrc, file /root/.bashrc, lsattr /root/.bashrc
    – Deltik
    Apr 25, 2018 at 18:50
  • @Deltik I have added the output of the requested commands to the question... Apr 26, 2018 at 10:31
  • @kenorb I dont get permission denied error on executing the debug command... Apr 26, 2018 at 10:53
  • Can you add/modify the first line of that file to #/bin/bash -x, to apply tracing, and re-produce the issue again?
    – kenorb
    Apr 26, 2018 at 11:37

1 Answer 1


-bash: /root/.bashrc: Permission denied

  • Check the permissions of .bashrc file (which you did).

  • Check the permissions of all files which you're including (such as /etc/bashrc).

  • Check the permissions of all files which your global /etc/bashrc is including.

  • Check the permissions of your /etc folder (see this post). For example:

      chmod 0755 /etc # run as root
  • Consider adding -vvv when running ssh for more detailed output.


To further debug the problem, you can enable tracing (xtrace) in your shell. Here are 3 methods:

  1. Using shebang.

    Add the following line as the first one to your script:

     #!/bin/bash -x
  2. Add set -x line at the very start of your startup script file.

  3. Run bash with -x along with ssh command, e.g.

     \ssh -vvv root@ -t bash -x

After that, try to reproduce the issue again, then you should find the problematic line.

  • No, this isn't working... the permissions of .bashrc, /etc/bashrc are all correct and doesn't have any issues... the trace command that I added in the header is not working.. this is not a solution... Apr 26, 2018 at 13:36
  • If your shebang doesn't work for some reason, add set -x on the second line. This should work.
    – kenorb
    Apr 26, 2018 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.