-bash: /etc/bash.bashrc: Permission denied I have no name

7,791

In order to read /etc/bash.bashrc (and /etc/password) the permissions on the parent directories matter, too. In particular, you need +x on them. In your case (from the chat conversation) it turns out somehow the permissions on /etc were wrong.

The inability to read /etc/passwd is why bash and whoami can't find your username.

Debian's default for /etc is 0755; so chmod 0755 /etc (as root) will fix at least that immediate problem. You should also investigate how that happened, to determine if there might be other directories with incorrect permissions.

Share:
7,791

Related videos on Youtube

Canadian Luke
Author by

Canadian Luke

Updated on September 18, 2022

Comments

  • Canadian Luke
    Canadian Luke over 1 year

    I have a Debian Wheezy server running, and a test-backup was just run - However, it went the other way! I cleaned it up the best I could, but I'm getting a VERY annoying error now.

    Root login is disabled via SSH. The user has to log in as a regular user, then execute su to get Root access. When I log in as my user, I get the following message:

    -bash: /etc/bash.bashrc: Permission denied
    I have no name!@server:~$
    

    When I execute aa whoami:

    $ whoami
    whoami: cannot find name for user ID 1000
    

    Checking my /etc/passwd file, those user IDs do exist! The permissions on /etc/bash.bashrc and /etc/passwd are 644, owned by root:root. Checking on another server, the /etc/bash.bashrc files match up the same, no changes required.

    There is the silver lining in that I can su into the root user, and access what I need, but I shouldn't need to do this. I cannot find any relevant log entries under /var/log, as they just show the successful login attempts (auth.log), but no errors. What can I do to allow the regular users to login again? Below is an exert of my /etc/passwd file, showing that the user ID 1000 exists:

    lbarone:x:1000:1000:Luke Barone,,,:/home/lbarone:/bin/bash
    
    • Canadian Luke
      Canadian Luke almost 10 years
      @MaQleod correct, local authentication only
    • mtak
      mtak almost 10 years
      Is you nsswitch.conf set up correctly? There should be a line with passwd: files or passwd: compat.
    • mihi
      mihi almost 10 years
      permissions on /etc/bash.bashrc? On which filesystem does it reside? Any strange mount options for it? Does the output of id -G prints the correct group ids? - and for the "i have no name" - run hostname command and/or check file /etc/hostname
    • mihi
      mihi almost 10 years
      And another thing to check would be ldd $(which bash) and verify that all the dynamic libraries can be found and have the right permissions
    • Canadian Luke
      Canadian Luke almost 10 years
      644, Ext4, no weird mount options, hostname is normal. When executing id -n, it outputs id: cannot print only names or real IDs in default format. The ldd one lists only 5 files, all with links with 777 permissions
    • terdon
      terdon almost 10 years
      Could you pass your /etc/passwd through od -c to check for any weird characters? Clutching at straws here but you never know.
    • Canadian Luke
      Canadian Luke almost 10 years
      @terdon Nope, the only 2-character items are \n for the new lines
    • derobert
      derobert almost 10 years
      As your non-root user, can you cat /etc/passwd? Also, do you have SELinux or some other security layer enabled?
    • Canadian Luke
      Canadian Luke almost 10 years
      @derobert $ cat /etc/passwd cat: /etc/passwd: Permission denied