Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 5032  / 2 Years ago, mon, october 3, 2022, 11:37:08

I created a new user by executing



sudo useradd -m harry



When I try to substitute the user by "su - harry" then everything I can see is a "$" (dollar) sign, the autocompletion isn't working and the shell builtins (e.g. source) are not available.



I checked .bashrc and .profile and detected that .bashrc is not getting sourced because $BASH_VERSION is not set.



The code inside .profile looks like follows:



# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi


The command echo $BASH_VERSION returns nothing.



$ echo $BASH_VERSION

$


Shell builtins (source .bashrc, . .bashrc) don't work either.



The SHELL variable value was '/bin/sh' which is alias of dash. I changed it to /bin/bash (export SHELL=/bin/bash) but it didn't have any effects.



When I hardcode ". .bashrc" in .profile (of course, just to check if it would work) I receive several errors:



admin@host:~$ sudo su - harry
-su: 13: /home/harry/.bashrc: shopt: not found
-su: 21: /home/harry/.bashrc: shopt: not found
-su: 105: /home/harry/.bashrc: shopt: not found
-su: 28: /etc/bash_completion: [[: not found
-su: 34: /etc/bash_completion: [[: not found
-su: 51: /etc/bash_completion: Bad substitution
[e]0;u@h: wa]u@h:w$


Any ideas how to fix it?



Thank you in advance.
jepetko


More From » 12.04

 Answers
2

This user's shell is /bin/sh. This is a smaller shell, which uses fewer resources than bash but offers fewer programming features and next to no interactive features.



Run sudo chsh -s /bin/bash harry to change the user's login shell to bash. This changes the user entry in /etc/passwd (don't edit that file directly unless you know what you're doing).



Setting the SHELL environment variable tells applications to run a different shell but has no effect on the currently running shell.


[#28073] Wednesday, October 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rialhirt

Total Points: 422
Total Questions: 113
Total Answers: 120

Location: France
Member since Sun, May 15, 2022
2 Years ago
rialhirt questions
Mon, May 24, 21, 18:24, 3 Years ago
Tue, May 10, 22, 21:43, 2 Years ago
Thu, Feb 16, 23, 16:32, 1 Year ago
Mon, Jun 13, 22, 03:02, 2 Years ago
;