Accidentally modified .bashrc and now I cant login despite entering password correctly
Use LiveUSB or LiveDVD.
Boot into live session, mount your hard-drive, and copy your original .bashrc
file over the modified.
Then you can safely reboot (eject USB or DVD).
General info: In case you wouldn't have backup of .bashrc
file, you can use the one from liveUSB/DVD.
You should be able to boot into recovery mode, which will let you drop into a root shell and then correct the problem from there. This avoids the need to download an additional OS.
Instructions taken from Ubuntu wiki:
- Switch on your computer.
- Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
Quickly press and hold the Shift key, which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you've missed the point where you can enter the GRUB menu.)
Select the line which starts with "
Advanced options
".Select the line ending with "
(recovery mode)
", probably the second line, something like:
Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)
Press Return and your machine will begin the boot process.
After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be "
Drop to root shell prompt
". Press Return with this option highlighted.The root partition is mounted read-only. To mount it read/write, enter the command
mount -o remount,rw /
If you have /home, /boot, /tmp, or any other mount point on a separate partition, you can mount them with the command
mount --all
(This must be done following step 8 so that
/etc/mtab
is writable.)
If you do not have the recovery option, you can press e in GRUB to edit the standard boot option and add recovery
at the end of the linux
line (second-last line by default, just before initrd
). Then press F10 to run it.
Use a live CD
- Boot using live CD/DVD. In case you do not have the iso and do not want to download the large iso, download Tiny Core - 10MB.
- On a command line type
sudo mount /dev/sdXn /mnt
wheresdXn
is your Ubuntu partition. - Type
cd /mnt/home/<your user name>/Downloads
. - Now restore your
.bashrc
as your new.bashrc
using this commandmv ../.bashrc ../.bashrc_old && cp ./.bashrc ../
. - Now restart into your system and you should be good to go.