# After the upgrade 11.1 to 11.2 I can log in as root



## pavlar (Dec 27, 2018)

I upgraded consistently from 11.0 to 11.1 to 11.2. But after this I can not go in as a root to do freebsd-update install

```
Shared object "libdl.so.1" not found, required by "bash"
```
Therefore, I got version 11.1-RELEASE-p15 and the kernel is loaded 11..2-RELEASE-p7 (GENERIC). What should I do to return the rights of the root


----------



## Emrion (Dec 27, 2018)

I would say that you are in or close to this case: https://forums.freebsd.org/threads/shared-object-libdl-so-1-not-found-required-by-bash.68251/


----------



## pavlar (Dec 27, 2018)

Emrion said:


> I would say that you are in or close to this case: https://forums.freebsd.org/threads/shared-object-libdl-so-1-not-found-required-by-bash.68251/




```
ssh -t - root@remote bin/sh
Password for root@remote:
Shared object "libdl.so.1" not found, required by "bash"
Connection to remote closed
```
And single user mod also requires root rights


----------



## chrcol (Dec 27, 2018)

if you cannot compile bash as a static binary, then its probably prudent to have a working toor account with the default shell, incase the root shell breaks.

The fix now is probably to boot into rescue OS and change the config so the root account isnt using bash which will then allow you to login again.


----------



## pavlar (Dec 27, 2018)

chrcol said:


> if you cannot compile bash as a static binary, then its probably prudent to have a working toor account with the default shell, incase the root shell breaks.
> 
> The fix now is probably to boot into rescue OS and change the config so the root account isnt using bash which will then allow you to login again.




```
-sh:toor:not found
```


----------



## SirDice (Dec 27, 2018)

And this is why you shouldn't change root's shell. Boot to single user mode and change root's shell back to csh(1).


----------



## pavlar (Dec 27, 2018)

SirDice said:


> And this is why you shouldn't change root's shell. Boot to single user mode and change root's shell back to csh(1).


 can you specify a command?


----------



## Deleted member 30996 (Dec 27, 2018)

This is how you get to Single User Mode:


```
fsck -y
mount -u /
mount -a -t ufs
swapon -a
```

Then edit your file using `ee` (Easy Editor).


----------



## pavlar (Dec 27, 2018)

but I already have sh:
echo $SHELL
/bin/sh


----------



## SirDice (Dec 27, 2018)

That's your current shell. Which you probably gave when you booted to single user mode. Use chsh(1) to change root's shell back to csh(1).

While still in single user mode, finish the `freebsd-update install`. Then upgrade/update all your packages/ports. Not strictly required but it's going to fix a bunch of broken dependencies.


----------



## Emrion (Dec 27, 2018)

You have all the commands you need in the link I provided. Since you have to mount your file system in read/write, it depends what fs you use. Just read carefully and you will recover your shell.


----------



## pavlar (Dec 27, 2018)

Understood, in a single mode i need in /etc/passwd   write ...../root: /bin/csh ?

I had there /usr/local/bin/bash


----------



## pavlar (Dec 27, 2018)

SirDice said:


> That's your current shell. Which you probably gave when you booted to single user mode. Use chsh(1) to change root's shell back to csh(1).
> 
> While still in single user mode, finish the `freebsd-update install`. Then upgrade/update all your packages/ports. Not strictly required but it's going to fix a bunch of broken dependencies.


in single user mode when I do freebsd-update install the same error appears 
Shared object "libdl.so.1" not found, required by "bash"


----------



## SirDice (Dec 27, 2018)

FreeBSD's freebsd-update(8) doesn't use Bash, at all. So you modified other things too. Did you replace /bin/sh with Bash? That's a really bad idea.


----------



## pavlar (Dec 27, 2018)

SirDice said:


> FreeBSD's freebsd-update(8) doesn't use Bash, at all. So you modified other things too. Did you replace /bin/sh with Bash? That's a really bad idea.


Yes, even in version 10.2.  /usr/local/bin/bash Since that time, I have made successive upgrades and this error has just now appeared.


----------



## SirDice (Dec 27, 2018)

Just installing shells/bash is not a problem. Replacing FreeBSD's /bin/sh with bash is. Do NOT do things like that, ever. There's absolutely no reason for it and it will break normal system scripts. As you already found out.


----------



## pavlar (Dec 27, 2018)

Trihexagonal said:


> This is how you get to Single User Mode:
> 
> 
> ```
> ...


Thanks. I changed root in  /etc/passwd to

```
root:*:0:0:Charlie &:/root:/bin/csh
```
But again when trying to log in as root  
	
	



```
Shared object "libdl.so.1" not found, required by "bash"
```


----------



## pavlar (Dec 28, 2018)

May be https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226200


----------



## pavlar (Dec 28, 2018)

Trihexagonal said:


> This is how you get to Single User Mode:
> 
> 
> ```
> ...


I read that /etc/passwd is not edited using  ee but using vipw. Maybe this is the problem
While if you use a third-party editor instead of "vipw" and "pw", you need
edit both / etc / passwd and /etc/master.passwd, and then run pwd_mkdb


----------



## pavlar (Dec 28, 2018)

Problem solved. Here's how to do it right:
1. single-user mode
2. fsck_ffs -y /
3. mount -u -w /
4. vipw change /usr/local/bin/bash to /bin/csh
5.reboot
Thanks to all


----------



## Emrion (Dec 28, 2018)

Glad you finally found the solution that worked for you.


----------



## Deleted member 30996 (Dec 28, 2018)

pavlar said:


> I read that /etc/passwd is not edited using  ee but using vipw. Maybe this is the problem
> While if you use a third-party editor instead of "vipw" and "pw", you need
> edit both / etc / passwd and /etc/master.passwd, and then run pwd_mkdb



I've got all my 3rd party programs installed and already hit the desktop by the time I edit /etc/passwd so I use editors/leafpad. I can do the same thing with `ee` or editors/vim but am a lot faster with Leafpad and use it as my default text editor.


----------



## SirDice (Dec 28, 2018)

Never edit /etc/passwd with a "plain" editor. Use vipw(8) (it respects the EDITOR variable so you can change the actual editor that's used), chsh(1) or the pw(8) commands to manipulate it. The reason is that the passwd file is never actually used, it's only there for historical reasons. The actual user database is stored in /etc/master.passwd. These tools will make sure both files are kept in sync while a "plain" editor would not.


----------



## Deleted member 30996 (Dec 28, 2018)

As always, you are correct, Sir. I checked /etc/master.passwd and the toor line was still there.


----------



## _martin (Dec 28, 2018)

This is probably the textbook example why not to change root's shell. But I understand why users do want to have different shell than csh. I myself don't like csh. I really tried and no, I don't want it. (I'm used to ksh on HPUX, or bash on Linux, and nowadays on Solaris too). 

There are few implications when changing root's shell. As you have found out there can be issues with lib dependencies which are not shipped with FreeBSD. Depending on your setup there can also be a problem when booting to single mode and /usr not being mounted (when bash is in /usr/local/bin). 

To avoid issues with lib dependency I suggest you to use bash-static. Either use one from pkg:

`pkg install bash-static` 

or compile bash from ports and select option STATIC from the menu. You can verify that by


```
cd /usr/ports/shells/bash
make config
```
And make sure STATIC option is selected. Remove current bash (either by `pkg delete bash` or `make uninstall` in port's directory) and compile new one.

Of course, as mentioned by SirDice, never ever change /bin/sh to anything else.


----------



## SirDice (Dec 28, 2018)

_martin said:


> To avoid issues with lib dependency I suggest you to use bash-static. Either use one from pkg:
> 
> pkg install bash-static


I had a client that insisted on changing root's shell to bash, and I kept insisting not to do this for all the reasons shown above. This was the best compromise we came up with.


----------

