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:

  1. Switch on your computer.
  2. Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
  3. 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.)

  4. Select the line which starts with "Advanced options".

  5. 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)

  6. Press Return and your machine will begin the boot process.

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

  8. The root partition is mounted read-only. To mount it read/write, enter the command

    mount -o remount,rw /

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

  1. 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.
  2. On a command line type sudo mount /dev/sdXn /mnt where sdXn is your Ubuntu partition.
  3. Type cd /mnt/home/<your user name>/Downloads.
  4. Now restore your .bashrc as your new .bashrc using this command mv ../.bashrc ../.bashrc_old && cp ./.bashrc ../.
  5. Now restart into your system and you should be good to go.