Accidentally moved sudoers file
up vote
0
down vote
favorite
I accidentally moved /etc/sudoers to Documents.
I need to move it back to /etc, but I can't since I need to be sudo to move files...
sudo mv Documents/sudoers /etc
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
sudo raspberry-pi
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
|
show 3 more comments
up vote
0
down vote
favorite
I accidentally moved /etc/sudoers to Documents.
I need to move it back to /etc, but I can't since I need to be sudo to move files...
sudo mv Documents/sudoers /etc
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
sudo raspberry-pi
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
1
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I accidentally moved /etc/sudoers to Documents.
I need to move it back to /etc, but I can't since I need to be sudo to move files...
sudo mv Documents/sudoers /etc
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
sudo raspberry-pi
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I accidentally moved /etc/sudoers to Documents.
I need to move it back to /etc, but I can't since I need to be sudo to move files...
sudo mv Documents/sudoers /etc
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
sudo raspberry-pi
sudo raspberry-pi
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Dec 6 at 14:35
terdon♦
127k31245422
127k31245422
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Dec 6 at 14:23
Light Yugen
1
1
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Light Yugen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
1
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58
|
show 3 more comments
2
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
1
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58
2
2
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
1
1
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58
|
show 3 more comments
2 Answers
2
active
oldest
votes
up vote
2
down vote
UPDATE 2 - if you are using raspberry pi:
Power down and pull the SD card out from your Pi and put it into your computer.
Open the file cmdline.txt and add init=/bin/sh to the end or for newer versions: systemd.unit=emergency.target. (UPDATE 2) . This will cause the machine to boot to single user mode.
Put the SD card back in the Pi and boot.
When the prompt comes up, type su to log in as root (no password needed).
mv sudoers-newname sudoers
Shut the machine down, then pull the card out again and put the cmdline.txt file back the way it was by removing the init=/bin/sh bit or for newer versions: systemd.unit=emergency.target. (UPDATE 2)
(Text adapted for sudoers deletion from here: http://mapledyne.com/ideas/2015/8/4/reset-lost-admin-password-for-raspberry-pi)
OLD ANSWER:
If you have root password just issue "su" but if you don't have root password, use a live cd, dvd or pendrive to just move the file back again.
For using su just:
#su
Password: Type root password
Via the Live-CD open the terminal and:
$ sudo fdisk -l (to get a list of partitions)
You will see the partition of your linux installation, as something like:
/dev/sda1 * 2048 1936918527 1936916480 923,6G 83 Linux
So if in your case it is /dev/sda1 too, just
sudo -i
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/etc/sudoers-newname /mnt/sda1/etc/sudoers
cd /
umount /mnt/sda1
If you have your linux installed in multiple partitions, just try mounting one by one until you find the correct one or the one that have the etc files.
That is it. Reboot.
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, presseand edit as described in the "single user mode" section.
– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
|
show 2 more comments
up vote
2
down vote
Booting into single user mode to move the file back to where it belongs is a solution to this problem, and the easiest for a regular PC.
In this case however, the file system is on a SD card. You just need a card reader, that you also need if you want to modify the boot options, and use that to attach the SD card to a regular PC running Linux. If you don't already have a Linux on a PC, get any Linux live CD. Then mount the file system on the card and move the file to the correct place.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
UPDATE 2 - if you are using raspberry pi:
Power down and pull the SD card out from your Pi and put it into your computer.
Open the file cmdline.txt and add init=/bin/sh to the end or for newer versions: systemd.unit=emergency.target. (UPDATE 2) . This will cause the machine to boot to single user mode.
Put the SD card back in the Pi and boot.
When the prompt comes up, type su to log in as root (no password needed).
mv sudoers-newname sudoers
Shut the machine down, then pull the card out again and put the cmdline.txt file back the way it was by removing the init=/bin/sh bit or for newer versions: systemd.unit=emergency.target. (UPDATE 2)
(Text adapted for sudoers deletion from here: http://mapledyne.com/ideas/2015/8/4/reset-lost-admin-password-for-raspberry-pi)
OLD ANSWER:
If you have root password just issue "su" but if you don't have root password, use a live cd, dvd or pendrive to just move the file back again.
For using su just:
#su
Password: Type root password
Via the Live-CD open the terminal and:
$ sudo fdisk -l (to get a list of partitions)
You will see the partition of your linux installation, as something like:
/dev/sda1 * 2048 1936918527 1936916480 923,6G 83 Linux
So if in your case it is /dev/sda1 too, just
sudo -i
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/etc/sudoers-newname /mnt/sda1/etc/sudoers
cd /
umount /mnt/sda1
If you have your linux installed in multiple partitions, just try mounting one by one until you find the correct one or the one that have the etc files.
That is it. Reboot.
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, presseand edit as described in the "single user mode" section.
– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
|
show 2 more comments
up vote
2
down vote
UPDATE 2 - if you are using raspberry pi:
Power down and pull the SD card out from your Pi and put it into your computer.
Open the file cmdline.txt and add init=/bin/sh to the end or for newer versions: systemd.unit=emergency.target. (UPDATE 2) . This will cause the machine to boot to single user mode.
Put the SD card back in the Pi and boot.
When the prompt comes up, type su to log in as root (no password needed).
mv sudoers-newname sudoers
Shut the machine down, then pull the card out again and put the cmdline.txt file back the way it was by removing the init=/bin/sh bit or for newer versions: systemd.unit=emergency.target. (UPDATE 2)
(Text adapted for sudoers deletion from here: http://mapledyne.com/ideas/2015/8/4/reset-lost-admin-password-for-raspberry-pi)
OLD ANSWER:
If you have root password just issue "su" but if you don't have root password, use a live cd, dvd or pendrive to just move the file back again.
For using su just:
#su
Password: Type root password
Via the Live-CD open the terminal and:
$ sudo fdisk -l (to get a list of partitions)
You will see the partition of your linux installation, as something like:
/dev/sda1 * 2048 1936918527 1936916480 923,6G 83 Linux
So if in your case it is /dev/sda1 too, just
sudo -i
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/etc/sudoers-newname /mnt/sda1/etc/sudoers
cd /
umount /mnt/sda1
If you have your linux installed in multiple partitions, just try mounting one by one until you find the correct one or the one that have the etc files.
That is it. Reboot.
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, presseand edit as described in the "single user mode" section.
– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
|
show 2 more comments
up vote
2
down vote
up vote
2
down vote
UPDATE 2 - if you are using raspberry pi:
Power down and pull the SD card out from your Pi and put it into your computer.
Open the file cmdline.txt and add init=/bin/sh to the end or for newer versions: systemd.unit=emergency.target. (UPDATE 2) . This will cause the machine to boot to single user mode.
Put the SD card back in the Pi and boot.
When the prompt comes up, type su to log in as root (no password needed).
mv sudoers-newname sudoers
Shut the machine down, then pull the card out again and put the cmdline.txt file back the way it was by removing the init=/bin/sh bit or for newer versions: systemd.unit=emergency.target. (UPDATE 2)
(Text adapted for sudoers deletion from here: http://mapledyne.com/ideas/2015/8/4/reset-lost-admin-password-for-raspberry-pi)
OLD ANSWER:
If you have root password just issue "su" but if you don't have root password, use a live cd, dvd or pendrive to just move the file back again.
For using su just:
#su
Password: Type root password
Via the Live-CD open the terminal and:
$ sudo fdisk -l (to get a list of partitions)
You will see the partition of your linux installation, as something like:
/dev/sda1 * 2048 1936918527 1936916480 923,6G 83 Linux
So if in your case it is /dev/sda1 too, just
sudo -i
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/etc/sudoers-newname /mnt/sda1/etc/sudoers
cd /
umount /mnt/sda1
If you have your linux installed in multiple partitions, just try mounting one by one until you find the correct one or the one that have the etc files.
That is it. Reboot.
UPDATE 2 - if you are using raspberry pi:
Power down and pull the SD card out from your Pi and put it into your computer.
Open the file cmdline.txt and add init=/bin/sh to the end or for newer versions: systemd.unit=emergency.target. (UPDATE 2) . This will cause the machine to boot to single user mode.
Put the SD card back in the Pi and boot.
When the prompt comes up, type su to log in as root (no password needed).
mv sudoers-newname sudoers
Shut the machine down, then pull the card out again and put the cmdline.txt file back the way it was by removing the init=/bin/sh bit or for newer versions: systemd.unit=emergency.target. (UPDATE 2)
(Text adapted for sudoers deletion from here: http://mapledyne.com/ideas/2015/8/4/reset-lost-admin-password-for-raspberry-pi)
OLD ANSWER:
If you have root password just issue "su" but if you don't have root password, use a live cd, dvd or pendrive to just move the file back again.
For using su just:
#su
Password: Type root password
Via the Live-CD open the terminal and:
$ sudo fdisk -l (to get a list of partitions)
You will see the partition of your linux installation, as something like:
/dev/sda1 * 2048 1936918527 1936916480 923,6G 83 Linux
So if in your case it is /dev/sda1 too, just
sudo -i
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/etc/sudoers-newname /mnt/sda1/etc/sudoers
cd /
umount /mnt/sda1
If you have your linux installed in multiple partitions, just try mounting one by one until you find the correct one or the one that have the etc files.
That is it. Reboot.
edited Dec 6 at 17:50
answered Dec 6 at 14:33
Luciano Andress Martini
3,415931
3,415931
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, presseand edit as described in the "single user mode" section.
– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
|
show 2 more comments
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, presseand edit as described in the "single user mode" section.
– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
i'm using a raspberry pi with sd card, how can i fix that?
– Light Yugen
Dec 6 at 14:47
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
A minute please.
– Luciano Andress Martini
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, press
e and edit as described in the "single user mode" section.– terdon♦
Dec 6 at 14:48
@LightYugen you should be able to boot from the same SD card you originally used to install the OS. If not, see the question I linked to in my comment under your question. When you get to grub, press
e and edit as described in the "single user mode" section.– terdon♦
Dec 6 at 14:48
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
See my edit on the answer.
– Luciano Andress Martini
Dec 6 at 14:51
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
snag.gy/XzlQcE.jpg did i put it correctly? when i boot it still asks user and password
– Light Yugen
Dec 6 at 14:59
|
show 2 more comments
up vote
2
down vote
Booting into single user mode to move the file back to where it belongs is a solution to this problem, and the easiest for a regular PC.
In this case however, the file system is on a SD card. You just need a card reader, that you also need if you want to modify the boot options, and use that to attach the SD card to a regular PC running Linux. If you don't already have a Linux on a PC, get any Linux live CD. Then mount the file system on the card and move the file to the correct place.
add a comment |
up vote
2
down vote
Booting into single user mode to move the file back to where it belongs is a solution to this problem, and the easiest for a regular PC.
In this case however, the file system is on a SD card. You just need a card reader, that you also need if you want to modify the boot options, and use that to attach the SD card to a regular PC running Linux. If you don't already have a Linux on a PC, get any Linux live CD. Then mount the file system on the card and move the file to the correct place.
add a comment |
up vote
2
down vote
up vote
2
down vote
Booting into single user mode to move the file back to where it belongs is a solution to this problem, and the easiest for a regular PC.
In this case however, the file system is on a SD card. You just need a card reader, that you also need if you want to modify the boot options, and use that to attach the SD card to a regular PC running Linux. If you don't already have a Linux on a PC, get any Linux live CD. Then mount the file system on the card and move the file to the correct place.
Booting into single user mode to move the file back to where it belongs is a solution to this problem, and the easiest for a regular PC.
In this case however, the file system is on a SD card. You just need a card reader, that you also need if you want to modify the boot options, and use that to attach the SD card to a regular PC running Linux. If you don't already have a Linux on a PC, get any Linux live CD. Then mount the file system on the card and move the file to the correct place.
answered Dec 6 at 18:03
RalfFriedl
5,2473925
5,2473925
add a comment |
add a comment |
Light Yugen is a new contributor. Be nice, and check out our Code of Conduct.
Light Yugen is a new contributor. Be nice, and check out our Code of Conduct.
Light Yugen is a new contributor. Be nice, and check out our Code of Conduct.
Light Yugen is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486384%2faccidentally-moved-sudoers-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:35
I'm using raspberry pi with sd card
– Light Yugen
Dec 6 at 14:47
That doesn't answer any of the three questions I asked :) Do you have physical access to the machine? Is there a keyboard & screen attached to it? Can you boot into single user mode?
– terdon♦
Dec 6 at 14:49
Sorry i'm new to linux, i'm using Putty for an ssh connection so yes i have keyboard and terminal, it doesn't have what you describe as single user mode
– Light Yugen
Dec 6 at 14:51
1
@roaima I think the code you see is actually the user's failed attempt at restoring the file.
– hymie
Dec 6 at 17:58