After accidentally renaming /etc, how do I rename it back?












36















I'm using Ubuntu 18.04.



I renamed the /etc folder to apache2. That was my greatest mistake



Now I can't rename it back because I need to use sudo, but when I try I get the error



sudo: unknown uid 1000


How can I fix this problem? I don't have a live system to boot from, and in recovery mode the root terminal opens but then closes saying cannot open password database.










share|improve this question




















  • 17





    Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

    – AlexP
    Dec 18 '18 at 13:53











  • How to boot an installation medium?

    – Racoon
    Dec 18 '18 at 13:54











  • @Zanna, shift didn't show me any menu. Maybe other button can open it?

    – Racoon
    Dec 18 '18 at 13:57











  • @Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

    – Racoon
    Dec 18 '18 at 14:11













  • @Zanna, no, haven't :(

    – Racoon
    Dec 18 '18 at 14:25
















36















I'm using Ubuntu 18.04.



I renamed the /etc folder to apache2. That was my greatest mistake



Now I can't rename it back because I need to use sudo, but when I try I get the error



sudo: unknown uid 1000


How can I fix this problem? I don't have a live system to boot from, and in recovery mode the root terminal opens but then closes saying cannot open password database.










share|improve this question




















  • 17





    Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

    – AlexP
    Dec 18 '18 at 13:53











  • How to boot an installation medium?

    – Racoon
    Dec 18 '18 at 13:54











  • @Zanna, shift didn't show me any menu. Maybe other button can open it?

    – Racoon
    Dec 18 '18 at 13:57











  • @Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

    – Racoon
    Dec 18 '18 at 14:11













  • @Zanna, no, haven't :(

    – Racoon
    Dec 18 '18 at 14:25














36












36








36


7






I'm using Ubuntu 18.04.



I renamed the /etc folder to apache2. That was my greatest mistake



Now I can't rename it back because I need to use sudo, but when I try I get the error



sudo: unknown uid 1000


How can I fix this problem? I don't have a live system to boot from, and in recovery mode the root terminal opens but then closes saying cannot open password database.










share|improve this question
















I'm using Ubuntu 18.04.



I renamed the /etc folder to apache2. That was my greatest mistake



Now I can't rename it back because I need to use sudo, but when I try I get the error



sudo: unknown uid 1000


How can I fix this problem? I don't have a live system to boot from, and in recovery mode the root terminal opens but then closes saying cannot open password database.







sudo etc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 18 '18 at 15:57









Zanna

50.4k13133241




50.4k13133241










asked Dec 18 '18 at 13:46









RacoonRacoon

19827




19827








  • 17





    Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

    – AlexP
    Dec 18 '18 at 13:53











  • How to boot an installation medium?

    – Racoon
    Dec 18 '18 at 13:54











  • @Zanna, shift didn't show me any menu. Maybe other button can open it?

    – Racoon
    Dec 18 '18 at 13:57











  • @Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

    – Racoon
    Dec 18 '18 at 14:11













  • @Zanna, no, haven't :(

    – Racoon
    Dec 18 '18 at 14:25














  • 17





    Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

    – AlexP
    Dec 18 '18 at 13:53











  • How to boot an installation medium?

    – Racoon
    Dec 18 '18 at 13:54











  • @Zanna, shift didn't show me any menu. Maybe other button can open it?

    – Racoon
    Dec 18 '18 at 13:57











  • @Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

    – Racoon
    Dec 18 '18 at 14:11













  • @Zanna, no, haven't :(

    – Racoon
    Dec 18 '18 at 14:25








17




17





Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

– AlexP
Dec 18 '18 at 13:53





Boot from an installation medium, select "Try Ubuntu", mount your root file system on /mnt, do the renaming, reboot.

– AlexP
Dec 18 '18 at 13:53













How to boot an installation medium?

– Racoon
Dec 18 '18 at 13:54





How to boot an installation medium?

– Racoon
Dec 18 '18 at 13:54













@Zanna, shift didn't show me any menu. Maybe other button can open it?

– Racoon
Dec 18 '18 at 13:57





@Zanna, shift didn't show me any menu. Maybe other button can open it?

– Racoon
Dec 18 '18 at 13:57













@Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

– Racoon
Dec 18 '18 at 14:11







@Zanna, Recovery menu -> root opens terminal, but it says cannot open password database and closes

– Racoon
Dec 18 '18 at 14:11















@Zanna, no, haven't :(

– Racoon
Dec 18 '18 at 14:25





@Zanna, no, haven't :(

– Racoon
Dec 18 '18 at 14:25










3 Answers
3






active

oldest

votes


















61














An easy way to fix problems like this is often to boot from a live system, mount the root partition on /mnt and then rename the file.



If you don't have a live system or a means of making one, or you don't have physical access to the system but you can reboot and get the GRUB menu, you can use the GRUB editor to get a root shell and rename the file.



Reboot or power off, switch on and, if you don't normally see the GRUB menu on boot, press Shift or Esc to get to the GRUB menu.



Move the cursor down to Advanced Options for Ubuntu and press enter, then press e to edit the boot options (one time only - changes here will not be permanent, so we don't have to clean up afterwards).



You will see a screen that looks something like this1:



screenshot of GRUB menu editor



Move the cursor down to the line that starts with linux and then move the cursor to the end of that line, or anywhere among the kernel boot parameters there. Be sure you are on the correct line and type carefully here, as the system may fail to boot without /etc in place.



Add the text init=/bin/bash and press F10 to boot.



This will start the system with a Bash shell as init. You will get a root shell and the filesystem will be mounted read only.2 To make the filesystem writable, enter the command



mount -o remount,rw /


Now you can rename /etc (you may want to ls first)



mv /apache2 /etc


Now you can reboot, or complete the boot normally from here by having the root shell replace itself with the normal init system3:



exec systemd 


I tested this procedure on Ubuntu MATE 18.04.





1Many thanks to Kulfy for obtaining a good quality screenshot of the GRUB editor from VirtualBox!
2 Although PATH cannot be set from the config files in /etc in this scenario, Bash will automatically set one.
3 If exec systemd doesn't work for you, exec /sbin/init should do the trick. If not, readlink -e /sbin/init should give the path to whatever init program should be running, which you can then exec with its full path. If you can't proceed this way, simply enter reboot.






share|improve this answer





















  • 4





    Very thorough including screenshot +1 :)

    – WinEunuuchs2Unix
    Dec 18 '18 at 16:11






  • 3





    @Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

    – Zanna
    Dec 18 '18 at 17:58






  • 3





    I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

    – Kulfy
    Dec 18 '18 at 18:03








  • 1





    @Racoon You're very welcome, happy you got it fixed :)

    – Zanna
    Dec 19 '18 at 6:55











  • Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

    – Vijay
    Dec 19 '18 at 13:42



















8














If you have a live USB, you should be able to boot to it and mount your existing filesystem, then rename your /etc from there. Here is a tutorial on how to create a live USB should you need it.



Once booted to the live USB (If using a Ubuntu 18.04 drive), select "Try Ubuntu without installing" and it will essentially give you a full instance of an Ubuntu installation that won't persist after shutdown. Once booted, you have a few options:



Command-Line Way



Open a terminal and run lsblk. Look for the volume that would be your original installation's drive and note which number it is (/dev/sd#)



Then, create a mountpoint for the drive with mkdir -p /mnt/directory, then mount the drive with sudo mount /dev/sd# /mnt/directory. Navigate to the directory with cd /mnt/directory and you should now be in your installation's root directory, but now with a working sudo command. run sudo mv apache2 etc and reboot into your hypothetically working OS.



Graphical Way



Open the disks utility by searching for Disks. Select the volume that looks like your installation drive and mount it. Open the file manager and select the mounted volume, right click your /apache2 folder and rename it to /etc, then reboot.






share|improve this answer


























  • "Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

    – Vijay
    Dec 19 '18 at 13:45






  • 1





    @Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

    – AJMansfield
    Dec 19 '18 at 14:48






  • 2





    @AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

    – Zanna
    Dec 19 '18 at 20:43



















6















  1. Make Bootable USB as shown here.


  2. Boot from USB by pressing the key as shown here.


  3. Find out your file-system partition by running gparted. Suppose it is sdxy.


  4. Run on terminal sudo mount /dev/sdxy /mnt


  5. Run on terminal sudo mv /mnt/apache2 /mnt/etc


  6. Check your file system in /mnt for the name change.


  7. Run on terminal sudo reboot


  8. When prompted remove the USB and press enter







share|improve this answer


























  • @Kulfy I tried but it does not work without sudo. See here.

    – Vijay
    Dec 18 '18 at 19:48













  • This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

    – Kulfy
    Dec 18 '18 at 20:06













  • Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

    – Vijay
    Dec 19 '18 at 6:19








  • 1





    AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

    – Zanna
    Dec 19 '18 at 8:42











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102836%2fafter-accidentally-renaming-etc-how-do-i-rename-it-back%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









61














An easy way to fix problems like this is often to boot from a live system, mount the root partition on /mnt and then rename the file.



If you don't have a live system or a means of making one, or you don't have physical access to the system but you can reboot and get the GRUB menu, you can use the GRUB editor to get a root shell and rename the file.



Reboot or power off, switch on and, if you don't normally see the GRUB menu on boot, press Shift or Esc to get to the GRUB menu.



Move the cursor down to Advanced Options for Ubuntu and press enter, then press e to edit the boot options (one time only - changes here will not be permanent, so we don't have to clean up afterwards).



You will see a screen that looks something like this1:



screenshot of GRUB menu editor



Move the cursor down to the line that starts with linux and then move the cursor to the end of that line, or anywhere among the kernel boot parameters there. Be sure you are on the correct line and type carefully here, as the system may fail to boot without /etc in place.



Add the text init=/bin/bash and press F10 to boot.



This will start the system with a Bash shell as init. You will get a root shell and the filesystem will be mounted read only.2 To make the filesystem writable, enter the command



mount -o remount,rw /


Now you can rename /etc (you may want to ls first)



mv /apache2 /etc


Now you can reboot, or complete the boot normally from here by having the root shell replace itself with the normal init system3:



exec systemd 


I tested this procedure on Ubuntu MATE 18.04.





1Many thanks to Kulfy for obtaining a good quality screenshot of the GRUB editor from VirtualBox!
2 Although PATH cannot be set from the config files in /etc in this scenario, Bash will automatically set one.
3 If exec systemd doesn't work for you, exec /sbin/init should do the trick. If not, readlink -e /sbin/init should give the path to whatever init program should be running, which you can then exec with its full path. If you can't proceed this way, simply enter reboot.






share|improve this answer





















  • 4





    Very thorough including screenshot +1 :)

    – WinEunuuchs2Unix
    Dec 18 '18 at 16:11






  • 3





    @Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

    – Zanna
    Dec 18 '18 at 17:58






  • 3





    I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

    – Kulfy
    Dec 18 '18 at 18:03








  • 1





    @Racoon You're very welcome, happy you got it fixed :)

    – Zanna
    Dec 19 '18 at 6:55











  • Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

    – Vijay
    Dec 19 '18 at 13:42
















61














An easy way to fix problems like this is often to boot from a live system, mount the root partition on /mnt and then rename the file.



If you don't have a live system or a means of making one, or you don't have physical access to the system but you can reboot and get the GRUB menu, you can use the GRUB editor to get a root shell and rename the file.



Reboot or power off, switch on and, if you don't normally see the GRUB menu on boot, press Shift or Esc to get to the GRUB menu.



Move the cursor down to Advanced Options for Ubuntu and press enter, then press e to edit the boot options (one time only - changes here will not be permanent, so we don't have to clean up afterwards).



You will see a screen that looks something like this1:



screenshot of GRUB menu editor



Move the cursor down to the line that starts with linux and then move the cursor to the end of that line, or anywhere among the kernel boot parameters there. Be sure you are on the correct line and type carefully here, as the system may fail to boot without /etc in place.



Add the text init=/bin/bash and press F10 to boot.



This will start the system with a Bash shell as init. You will get a root shell and the filesystem will be mounted read only.2 To make the filesystem writable, enter the command



mount -o remount,rw /


Now you can rename /etc (you may want to ls first)



mv /apache2 /etc


Now you can reboot, or complete the boot normally from here by having the root shell replace itself with the normal init system3:



exec systemd 


I tested this procedure on Ubuntu MATE 18.04.





1Many thanks to Kulfy for obtaining a good quality screenshot of the GRUB editor from VirtualBox!
2 Although PATH cannot be set from the config files in /etc in this scenario, Bash will automatically set one.
3 If exec systemd doesn't work for you, exec /sbin/init should do the trick. If not, readlink -e /sbin/init should give the path to whatever init program should be running, which you can then exec with its full path. If you can't proceed this way, simply enter reboot.






share|improve this answer





















  • 4





    Very thorough including screenshot +1 :)

    – WinEunuuchs2Unix
    Dec 18 '18 at 16:11






  • 3





    @Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

    – Zanna
    Dec 18 '18 at 17:58






  • 3





    I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

    – Kulfy
    Dec 18 '18 at 18:03








  • 1





    @Racoon You're very welcome, happy you got it fixed :)

    – Zanna
    Dec 19 '18 at 6:55











  • Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

    – Vijay
    Dec 19 '18 at 13:42














61












61








61







An easy way to fix problems like this is often to boot from a live system, mount the root partition on /mnt and then rename the file.



If you don't have a live system or a means of making one, or you don't have physical access to the system but you can reboot and get the GRUB menu, you can use the GRUB editor to get a root shell and rename the file.



Reboot or power off, switch on and, if you don't normally see the GRUB menu on boot, press Shift or Esc to get to the GRUB menu.



Move the cursor down to Advanced Options for Ubuntu and press enter, then press e to edit the boot options (one time only - changes here will not be permanent, so we don't have to clean up afterwards).



You will see a screen that looks something like this1:



screenshot of GRUB menu editor



Move the cursor down to the line that starts with linux and then move the cursor to the end of that line, or anywhere among the kernel boot parameters there. Be sure you are on the correct line and type carefully here, as the system may fail to boot without /etc in place.



Add the text init=/bin/bash and press F10 to boot.



This will start the system with a Bash shell as init. You will get a root shell and the filesystem will be mounted read only.2 To make the filesystem writable, enter the command



mount -o remount,rw /


Now you can rename /etc (you may want to ls first)



mv /apache2 /etc


Now you can reboot, or complete the boot normally from here by having the root shell replace itself with the normal init system3:



exec systemd 


I tested this procedure on Ubuntu MATE 18.04.





1Many thanks to Kulfy for obtaining a good quality screenshot of the GRUB editor from VirtualBox!
2 Although PATH cannot be set from the config files in /etc in this scenario, Bash will automatically set one.
3 If exec systemd doesn't work for you, exec /sbin/init should do the trick. If not, readlink -e /sbin/init should give the path to whatever init program should be running, which you can then exec with its full path. If you can't proceed this way, simply enter reboot.






share|improve this answer















An easy way to fix problems like this is often to boot from a live system, mount the root partition on /mnt and then rename the file.



If you don't have a live system or a means of making one, or you don't have physical access to the system but you can reboot and get the GRUB menu, you can use the GRUB editor to get a root shell and rename the file.



Reboot or power off, switch on and, if you don't normally see the GRUB menu on boot, press Shift or Esc to get to the GRUB menu.



Move the cursor down to Advanced Options for Ubuntu and press enter, then press e to edit the boot options (one time only - changes here will not be permanent, so we don't have to clean up afterwards).



You will see a screen that looks something like this1:



screenshot of GRUB menu editor



Move the cursor down to the line that starts with linux and then move the cursor to the end of that line, or anywhere among the kernel boot parameters there. Be sure you are on the correct line and type carefully here, as the system may fail to boot without /etc in place.



Add the text init=/bin/bash and press F10 to boot.



This will start the system with a Bash shell as init. You will get a root shell and the filesystem will be mounted read only.2 To make the filesystem writable, enter the command



mount -o remount,rw /


Now you can rename /etc (you may want to ls first)



mv /apache2 /etc


Now you can reboot, or complete the boot normally from here by having the root shell replace itself with the normal init system3:



exec systemd 


I tested this procedure on Ubuntu MATE 18.04.





1Many thanks to Kulfy for obtaining a good quality screenshot of the GRUB editor from VirtualBox!
2 Although PATH cannot be set from the config files in /etc in this scenario, Bash will automatically set one.
3 If exec systemd doesn't work for you, exec /sbin/init should do the trick. If not, readlink -e /sbin/init should give the path to whatever init program should be running, which you can then exec with its full path. If you can't proceed this way, simply enter reboot.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 20 '18 at 15:50

























answered Dec 18 '18 at 14:53









ZannaZanna

50.4k13133241




50.4k13133241








  • 4





    Very thorough including screenshot +1 :)

    – WinEunuuchs2Unix
    Dec 18 '18 at 16:11






  • 3





    @Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

    – Zanna
    Dec 18 '18 at 17:58






  • 3





    I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

    – Kulfy
    Dec 18 '18 at 18:03








  • 1





    @Racoon You're very welcome, happy you got it fixed :)

    – Zanna
    Dec 19 '18 at 6:55











  • Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

    – Vijay
    Dec 19 '18 at 13:42














  • 4





    Very thorough including screenshot +1 :)

    – WinEunuuchs2Unix
    Dec 18 '18 at 16:11






  • 3





    @Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

    – Zanna
    Dec 18 '18 at 17:58






  • 3





    I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

    – Kulfy
    Dec 18 '18 at 18:03








  • 1





    @Racoon You're very welcome, happy you got it fixed :)

    – Zanna
    Dec 19 '18 at 6:55











  • Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

    – Vijay
    Dec 19 '18 at 13:42








4




4





Very thorough including screenshot +1 :)

– WinEunuuchs2Unix
Dec 18 '18 at 16:11





Very thorough including screenshot +1 :)

– WinEunuuchs2Unix
Dec 18 '18 at 16:11




3




3





@Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

– Zanna
Dec 18 '18 at 17:58





@Kulfy thank you so much! that's wonderful :D I can't use VB as I don't have enough RAM. Very kind of you to help improve my answer

– Zanna
Dec 18 '18 at 17:58




3




3





I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

– Kulfy
Dec 18 '18 at 18:03







I think I took screenshot way too big :P ;-) and thanks for the screenshot credits :)

– Kulfy
Dec 18 '18 at 18:03






1




1





@Racoon You're very welcome, happy you got it fixed :)

– Zanna
Dec 19 '18 at 6:55





@Racoon You're very welcome, happy you got it fixed :)

– Zanna
Dec 19 '18 at 6:55













Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

– Vijay
Dec 19 '18 at 13:42





Trying to test it but not working in Ubuntu 18.04.Desktop. Followed the instructions verbatim. Not working. After F10 only a few lines appear and stops at blank screen. Can you suggest something?

– Vijay
Dec 19 '18 at 13:42













8














If you have a live USB, you should be able to boot to it and mount your existing filesystem, then rename your /etc from there. Here is a tutorial on how to create a live USB should you need it.



Once booted to the live USB (If using a Ubuntu 18.04 drive), select "Try Ubuntu without installing" and it will essentially give you a full instance of an Ubuntu installation that won't persist after shutdown. Once booted, you have a few options:



Command-Line Way



Open a terminal and run lsblk. Look for the volume that would be your original installation's drive and note which number it is (/dev/sd#)



Then, create a mountpoint for the drive with mkdir -p /mnt/directory, then mount the drive with sudo mount /dev/sd# /mnt/directory. Navigate to the directory with cd /mnt/directory and you should now be in your installation's root directory, but now with a working sudo command. run sudo mv apache2 etc and reboot into your hypothetically working OS.



Graphical Way



Open the disks utility by searching for Disks. Select the volume that looks like your installation drive and mount it. Open the file manager and select the mounted volume, right click your /apache2 folder and rename it to /etc, then reboot.






share|improve this answer


























  • "Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

    – Vijay
    Dec 19 '18 at 13:45






  • 1





    @Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

    – AJMansfield
    Dec 19 '18 at 14:48






  • 2





    @AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

    – Zanna
    Dec 19 '18 at 20:43
















8














If you have a live USB, you should be able to boot to it and mount your existing filesystem, then rename your /etc from there. Here is a tutorial on how to create a live USB should you need it.



Once booted to the live USB (If using a Ubuntu 18.04 drive), select "Try Ubuntu without installing" and it will essentially give you a full instance of an Ubuntu installation that won't persist after shutdown. Once booted, you have a few options:



Command-Line Way



Open a terminal and run lsblk. Look for the volume that would be your original installation's drive and note which number it is (/dev/sd#)



Then, create a mountpoint for the drive with mkdir -p /mnt/directory, then mount the drive with sudo mount /dev/sd# /mnt/directory. Navigate to the directory with cd /mnt/directory and you should now be in your installation's root directory, but now with a working sudo command. run sudo mv apache2 etc and reboot into your hypothetically working OS.



Graphical Way



Open the disks utility by searching for Disks. Select the volume that looks like your installation drive and mount it. Open the file manager and select the mounted volume, right click your /apache2 folder and rename it to /etc, then reboot.






share|improve this answer


























  • "Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

    – Vijay
    Dec 19 '18 at 13:45






  • 1





    @Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

    – AJMansfield
    Dec 19 '18 at 14:48






  • 2





    @AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

    – Zanna
    Dec 19 '18 at 20:43














8












8








8







If you have a live USB, you should be able to boot to it and mount your existing filesystem, then rename your /etc from there. Here is a tutorial on how to create a live USB should you need it.



Once booted to the live USB (If using a Ubuntu 18.04 drive), select "Try Ubuntu without installing" and it will essentially give you a full instance of an Ubuntu installation that won't persist after shutdown. Once booted, you have a few options:



Command-Line Way



Open a terminal and run lsblk. Look for the volume that would be your original installation's drive and note which number it is (/dev/sd#)



Then, create a mountpoint for the drive with mkdir -p /mnt/directory, then mount the drive with sudo mount /dev/sd# /mnt/directory. Navigate to the directory with cd /mnt/directory and you should now be in your installation's root directory, but now with a working sudo command. run sudo mv apache2 etc and reboot into your hypothetically working OS.



Graphical Way



Open the disks utility by searching for Disks. Select the volume that looks like your installation drive and mount it. Open the file manager and select the mounted volume, right click your /apache2 folder and rename it to /etc, then reboot.






share|improve this answer















If you have a live USB, you should be able to boot to it and mount your existing filesystem, then rename your /etc from there. Here is a tutorial on how to create a live USB should you need it.



Once booted to the live USB (If using a Ubuntu 18.04 drive), select "Try Ubuntu without installing" and it will essentially give you a full instance of an Ubuntu installation that won't persist after shutdown. Once booted, you have a few options:



Command-Line Way



Open a terminal and run lsblk. Look for the volume that would be your original installation's drive and note which number it is (/dev/sd#)



Then, create a mountpoint for the drive with mkdir -p /mnt/directory, then mount the drive with sudo mount /dev/sd# /mnt/directory. Navigate to the directory with cd /mnt/directory and you should now be in your installation's root directory, but now with a working sudo command. run sudo mv apache2 etc and reboot into your hypothetically working OS.



Graphical Way



Open the disks utility by searching for Disks. Select the volume that looks like your installation drive and mount it. Open the file manager and select the mounted volume, right click your /apache2 folder and rename it to /etc, then reboot.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 18 '18 at 15:56

























answered Dec 18 '18 at 13:55









MintyMinty

36917




36917













  • "Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

    – Vijay
    Dec 19 '18 at 13:45






  • 1





    @Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

    – AJMansfield
    Dec 19 '18 at 14:48






  • 2





    @AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

    – Zanna
    Dec 19 '18 at 20:43



















  • "Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

    – Vijay
    Dec 19 '18 at 13:45






  • 1





    @Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

    – AJMansfield
    Dec 19 '18 at 14:48






  • 2





    @AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

    – Zanna
    Dec 19 '18 at 20:43

















"Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

– Vijay
Dec 19 '18 at 13:45





"Graphical Way" doesn't work because there is no option "Rename" on Rt. click.

– Vijay
Dec 19 '18 at 13:45




1




1





@Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

– AJMansfield
Dec 19 '18 at 14:48





@Vijay That's likely because of file permissions, you will need to open the file manager as root to do it graphically. To do that, run the command sudo nautilus from the terminal. (Ubuntu uses "nautilus" as its file manager in the same way Windows uses "explorer".)

– AJMansfield
Dec 19 '18 at 14:48




2




2





@AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

– Zanna
Dec 19 '18 at 20:43





@AJMansfield of course it doesn't matter on a live system, but in general we should use sudo -H nautilus to avoid having root become the owner of config files in $HOME, potentially making them inaccessible by programs run as an ordinary user. You're probably aware of this, but I'm mentioning for other readers.

– Zanna
Dec 19 '18 at 20:43











6















  1. Make Bootable USB as shown here.


  2. Boot from USB by pressing the key as shown here.


  3. Find out your file-system partition by running gparted. Suppose it is sdxy.


  4. Run on terminal sudo mount /dev/sdxy /mnt


  5. Run on terminal sudo mv /mnt/apache2 /mnt/etc


  6. Check your file system in /mnt for the name change.


  7. Run on terminal sudo reboot


  8. When prompted remove the USB and press enter







share|improve this answer


























  • @Kulfy I tried but it does not work without sudo. See here.

    – Vijay
    Dec 18 '18 at 19:48













  • This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

    – Kulfy
    Dec 18 '18 at 20:06













  • Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

    – Vijay
    Dec 19 '18 at 6:19








  • 1





    AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

    – Zanna
    Dec 19 '18 at 8:42
















6















  1. Make Bootable USB as shown here.


  2. Boot from USB by pressing the key as shown here.


  3. Find out your file-system partition by running gparted. Suppose it is sdxy.


  4. Run on terminal sudo mount /dev/sdxy /mnt


  5. Run on terminal sudo mv /mnt/apache2 /mnt/etc


  6. Check your file system in /mnt for the name change.


  7. Run on terminal sudo reboot


  8. When prompted remove the USB and press enter







share|improve this answer


























  • @Kulfy I tried but it does not work without sudo. See here.

    – Vijay
    Dec 18 '18 at 19:48













  • This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

    – Kulfy
    Dec 18 '18 at 20:06













  • Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

    – Vijay
    Dec 19 '18 at 6:19








  • 1





    AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

    – Zanna
    Dec 19 '18 at 8:42














6












6








6








  1. Make Bootable USB as shown here.


  2. Boot from USB by pressing the key as shown here.


  3. Find out your file-system partition by running gparted. Suppose it is sdxy.


  4. Run on terminal sudo mount /dev/sdxy /mnt


  5. Run on terminal sudo mv /mnt/apache2 /mnt/etc


  6. Check your file system in /mnt for the name change.


  7. Run on terminal sudo reboot


  8. When prompted remove the USB and press enter







share|improve this answer
















  1. Make Bootable USB as shown here.


  2. Boot from USB by pressing the key as shown here.


  3. Find out your file-system partition by running gparted. Suppose it is sdxy.


  4. Run on terminal sudo mount /dev/sdxy /mnt


  5. Run on terminal sudo mv /mnt/apache2 /mnt/etc


  6. Check your file system in /mnt for the name change.


  7. Run on terminal sudo reboot


  8. When prompted remove the USB and press enter








share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 18 '18 at 19:51

























answered Dec 18 '18 at 13:54









VijayVijay

1,5101618




1,5101618













  • @Kulfy I tried but it does not work without sudo. See here.

    – Vijay
    Dec 18 '18 at 19:48













  • This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

    – Kulfy
    Dec 18 '18 at 20:06













  • Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

    – Vijay
    Dec 19 '18 at 6:19








  • 1





    AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

    – Zanna
    Dec 19 '18 at 8:42



















  • @Kulfy I tried but it does not work without sudo. See here.

    – Vijay
    Dec 18 '18 at 19:48













  • This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

    – Kulfy
    Dec 18 '18 at 20:06













  • Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

    – Vijay
    Dec 19 '18 at 6:19








  • 1





    AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

    – Zanna
    Dec 19 '18 at 8:42

















@Kulfy I tried but it does not work without sudo. See here.

– Vijay
Dec 18 '18 at 19:48







@Kulfy I tried but it does not work without sudo. See here.

– Vijay
Dec 18 '18 at 19:48















This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

– Kulfy
Dec 18 '18 at 20:06







This is because sda2 was mounted with sudo, therefore only sudo can perform actions. But if you mount drive by nautilus (without any special permission) you can perform tasks without sudo.

– Kulfy
Dec 18 '18 at 20:06















Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

– Vijay
Dec 19 '18 at 6:19







Checked it `ubuntu@ubuntu:~$ mount /dev/sda2 /mnt mount: only root can do that ubuntu@ubuntu:~$

– Vijay
Dec 19 '18 at 6:19






1




1





AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

– Zanna
Dec 19 '18 at 8:42





AFAIK the mount program is very strict and always has to be run as root; the only exception to this is when the filesystem is in fstab and has the user option. The program udisksctl allows normal users to mount devices, using for example udisksctl mount -b /dev/sda1 (it creates a suitable mount point in /media/$USER/). I have not tried using udisksctl from a live system, but on a live system one is always a privileged user able to run sudo with no password so there is no need for utilities like udisksctl which are otherwise so useful

– Zanna
Dec 19 '18 at 8:42


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102836%2fafter-accidentally-renaming-etc-how-do-i-rename-it-back%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Plaza Victoria

Puebla de Zaragoza

Musa