9

After getting a new VPS with Debian 9, I created a new user using root. I created a new username called joe with this command adduser joe. Then, I used usermod -aG sudo joe to grant administrative privileges. After that, I logged out and used Putty to login as joe. I entered the password for joe. After entering the password, it displayed this message:
Could not chdir to home directory /home/joe: Permission denied
-bash: /home/joe/.bash_profile: Permission denied

I checked the directory of /home/joe by using this command:

sudo ls -al /home/joe
total 20
drw-r--r-- 2 joe  joe  4096 Feb  7 16:32 .
drwxr-xr-x 4 root root 4096 Feb  7 16:32 ..
-rw-r--r-- 1 joe  joe   220 Feb  7 16:32 .bash_logout
-rw-r--r-- 1 joe  joe  3526 Feb  7 16:32 .bashrc
-rw-r--r-- 1 joe  joe   675 Feb  7 16:32 .profile

How can I enter into /home/joe directory after login as joe?

1
  • 1
    That's the wrong question. The right question is how do you stop account creation from doing that to new home directories in the first place. I am confident that that has already been asked here.
    – JdeBP
    Commented Feb 8, 2019 at 9:10

1 Answer 1

9

Apparently /home/joe doesn't have execute permission for the user. Execute permission for the directory allows to traverse it.

Try sudo chmod 755 /home/joe and then log in again.

7
  • There's no need for sudo if one has logged in as joe of course, as joe clearly owns the directory. Running sudo for everything as a matter of course is a bad habit.
    – JdeBP
    Commented Feb 8, 2019 at 9:08
  • @JdeBP But he can't log in as joe. I assume the creator was root when he created the user joe. But using sudo will work as long as that creating user in the sudo group. (There also is no need to use sudo to produce the listing above.)
    – Arjen
    Commented Feb 8, 2019 at 9:24
  • Xe can and did log in as joe. Xe showed you the messages from doing so. If xe couldn't, you would not be seeing that message from xyr log-in shell, running after xe had logged in and trying to open an rc file. Indeed, the question even explicitly says "after login as joe".
    – JdeBP
    Commented Feb 8, 2019 at 11:59
  • @JdeBP He can log in as any user and run ls -al /home/joe and get that output. He described how he created user joe - I assume while being root or using sudo - then logged out and tried to log in as joe and that didn't work. That was the reason for him asking the original question. The key phrase for me here is: " I entered the password for joe. After entering the password, it displayed this message: Could not chdir to home directory /home/joe: Permission denied" When I have time I will try to duplicate the situation.
    – Arjen
    Commented Feb 8, 2019 at 15:07
  • @JdeBP I duplicated the situation as much as possible on a Raspbian (Debian based) and Debian 9 (stretch). On Raspbian I logged in as myself, using sudo created user joe, added joe to sudo group using usermod -aF sudo joe, removed execute permissions from /home/joe (sudo chmod a-x /home/joe), logged out and tried to log in as joe - through a graphical shell/user-password dlg. Providing the correct password returns me immediately to the dialog box. When providing a wrong password also returns me to the dialog with a message that the password is wrong and I should try again.
    – Arjen
    Commented Feb 8, 2019 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .