You will get errors in login and variables and the environment you set for the bash profile also not work in this case. Even you will not redirect to the user home directory.
Change the ownership of the user home directory to fix the issue:
Now your login issue has also been resolved. You will get no error login.
Change User Ownership of Directory
You have created a service user and you want this user to have any specific home directory user ownership. We will do this in case of the user who is nologin or any application we deploy with nologin user and want to give all access to service or generic account to have control over the application.
Change the only UID of the home directory
Note: This will again show the same error message for the user like case 1
Change Group Ownership of Directory
This case also similar to case 2 but here we will not get an error message. In this case, we will change the group ownership of the directory.
This will change the only group ownership of any directory. This is a correct method also because you have the control over users also to add them or remove them from a specific group. No effect on user account and application after configuration
Now you have successfully resolved your ownership issue. This is not only for the home directory. This will work on any directory so be careful about it.
Note: Do not run the below command
# chown -R abc:abc /
This will corrupt your system and after reboot, it is very hard to recover the system, Because mostly directories required only specific ownership and this will affect your system
Change home directory of the user
If you required to change any user’s home directory if they login. In case of any different name where the same name is not possible or for any security reason. You can change the home directory also.
For this, you have to follow the same procedure to change directory ownership. But you will face issues like case1 because in the passwd section home directory defined is as /home/user.
So you need to change the user home directory also.
# chown -R xyz:xyz abc
# usermod -d /home/xyz abc
Now at this point, you become perfect in changing ownership of the directory without any error. Share this article to show your care.