Sample Header Ad - 728x90

Why do all users start in /root instead of their home directories after su as root?

13 votes
2 answers
3410 views
I feel like this should be straightforward but I've never seen anyone ask this that I can tell. The situation is pretty straight forward. Whenever I become a user, ie su user it always starts in /root directory instead of it's home directory. Let me show you. [root@st-test2 ~]# grep "postgres" /etc/passwd postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql/:/bin/bash [root@st-test2 ~]# su postgres bash-4.2$ pwd /root [root@st-test2 ~]# ls -lhart /var/lib |grep postgres drwx------. 4 postgres postgres 86 May 5 16:07 pgsql So, you can see that the postgres user's home directory exists and that its set in /etc/passwd...but for some reason, they start in the root directory. This happens with every user that I have created and I have no idea why. I can't say that I've ever seen this happen before either.
Asked by Chris Jones (233 rep)
May 5, 2021, 08:55 PM
Last activity: May 10, 2021, 03:08 PM