I tried to change the login shell.
Here's what the first line of /etc/passwd
looks like (on a Debian Wheezy install):
rootx:0:0:root:/root:/:zsh
When I try to login as root
:
Cannot execute zsh: No such file or directory
I know zsh
is available:
$ which zsh
/usr/bin/zsh
Okay, it seems logical to replace zsh
by its full path. But how can I do it?
I have one other user on the system (user
), however it doesn't have root privileges and sudo
is not installed on the system.
Assume that for whatever reason (encryption, physical access, …) I cannot boot on a live CD to modify the file.
I do know, however, the credentials for the root
account.
My question is: Is there any way, even programatically, to launch a process with the root
account without launching its login shell first?
Best Answer
Have su permissions
You can use the following command to change any users' shell.
If you have physical access
During your Grub boot you can get into any system so long as you have console access and there isn't a password preventing you from gaining access to the Grub menu.
During the initial boot up of the system when the Grub menu shows up, if you enter the menu and edit (press e key) the kernel line, you can add one of the following things to make the kernel boot in single user mode.
The line will look something like this:
In Grub it should look similar to this:
Once you've made the changes boot the kernel (press key b).
This will give you temporary access to the system with a shell where you can use vi/vim to make whatever changes you need to your
/etc/passwd
file. Just typereboot
when you're done.