Ubuntu Server 20.04 – How to Repair User Directory

Ubuntu

For a project I have two servers, staging and production. The project is very old and I had not upgraded the OS from Ubuntu 14.04. As upgrading was out of question, recently I migrated the production server to a new VPS with Ubuntu 20.04.2. I am not sure where I went wrong, but these are now the symptoms:

Worong Promot
Whenever I SSH into the server as root all is normal, but when I switch to the normal user with su appuser the prompt becomes a bare $, no username, no host name and no path in the prompt.

No auto-completion
Also, I am unable to autocomplete paths in commands. I.e. when I type /ho and hit TAB, instead of the line becoming /home a literal tab character is added like /ho .

No command history
When I hit the UP key, instead of getting the last executed command, the line becomes $ ^[[A.

Cron jobs not executed
I have several cronjobs and I am sure there is no issue with the defining line or the service they call as they worked in the old production server and still work in the staging server. The jobs are not executed at all on the new server.

Missing files
I compared the list of files on the staging server and the new production server and noticed a number of files are missing in the new server. For example, there was no .bashrc file in the new servers's /home/appuser directory. I added the file manually but nothing changed. So I thought I should seek help.

How can I repair the appuser?

Best Answer

The default shell looks like it's a "minimal" shell. If you wish the appuser to have the same shell as root you should change the default shell to /bin/bash.
You can do this by editing the /etc/passwd file and replace the /bin/sh with /bin/bash using your preferred text editor (such as vi, vim or nano), or the other option is using the chsh command, like:

chsh appuser -s /bin/bash

Hope it helps!

Related Topic