5

I have this server running Centos 7. Every time I log in (remotely or locally) with every user I get an error. If I log in as root I get

-bash: /root/.bashrc: Permission denied

If I log in as a normal user I get

-bash: /home/normal_user/.bashrc: Permission denied

The permission for the .bashrc is

-rw-r--r--.  1 root root   176 Dec 29  2013 .bashrc

And its content is

# .bashrc

# 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
fi

Can't figure out what is going on. Plus everything is working as intended.

EDIT: @terdon

[root@dmbi-va ~]# grep -F .bashrc /root/.profile /root/.bash_profile /root/.bash_login /etc/profile /etc/bashrc
grep: /root/.profile: No such file or directory
/root/.bash_profile:if [ -f ~/.bashrc ]; then
/root/.bash_profile:    . ~/.bashrc
grep: /root/.bash_login: No such file or directory

@roaima @ikkachu

[root@dmbi-va ~]# ls -Zld /etc /etc/bashrc .bashrc
-rw-r--r--.   1 system_u:object_r:admin_home_t:s0 root root  176 Dec 29  2013 .bashrc
drwxr-xr-x. 139 system_u:object_r:etc_t:s0       root root 8192 Jun 21 09:37 /etc
-rw-r--r--.   1 system_u:object_r:etc_t:s0       root root 2835 Aug 12  2015 /etc/bashrc
  • 1
    Please edit your question and post the output of grep -F .bashrc /root/.profile /root/.bash_profile /root/.bash_login /etc/profile /etc/bashrc. It looks like something is attempting to execute (instead of source) /root/.bashrc. – terdon Jun 21 '16 at 8:43
  • @terdon FYI, OP hasn't said which distribution they're using; with Red Hat-based distros, bash is compiled to source /etc/bashrc on start-up. – Anthony Geoghegan Jun 21 '16 at 8:52
  • 1
    @AnthonyGeoghegan ah, I see. I didn't know that, thanks. I edited my previous comment to avoid confusion. – terdon Jun 21 '16 at 8:54
  • 5
    That dot in the end of the permission bits hints at SELinux. Perhaps ls -Z might tell something – ilkkachu Jun 21 '16 at 12:02

Your Answer

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

Browse other questions tagged or ask your own question.